PDA

View Full Version : GUI Questions


huxy
02-27-2009, 10:36 AM
Hi,

I'm currently in the middle of working on a GUI in maya. I'm finally getting my head around the layout and positioning of all the buttons/forms/layouts etc... But I'm having some problems with certain aspects of the GUI and am hoping someone might be able to give some advice, these are the two problems I have at the moment

1. I have some sliders that I want to connect to the attributes of a node. These two in particular control the number of sub divisions on a plane. The problem I have is that when the GUI is launched the node doesn't exist yet (it gets created by the GUI later) so I tried to use the Attr Slider Group but it complains that the node does not exist and therefore the connection fails causing the GUI to not launch. Ok, so that failed so I tried to use Int Group Slider and then manually link it using connectControl command. This seems to work (well at least there's no errors) but the control does not appear to link correctly. Is there any way of creating a Attr Slider Group which can be linked to a node that doesn't exist yet or loads in a disabled state?

2. I have a button that loads an external file and links it to a node. At the same time I made it a symbol button so that when the user selects the file, it changes the image of the button to match the file. The problem I have with this button is that when it assigns the image to the button it does not resize it and only shows the pixel portion of it that I have specified. Is there anyway to get a symbol button to rescale the image so it fits? or alternatively is it possible to place a Texture Preview control (like that of the file node) on the GUI?


Any ideas?

Thanks in advance!

Robert Bateman
02-27-2009, 12:50 PM
1. I have some sliders that I want to connect to the attributes of a node. These two in particular control the number of sub divisions on a plane. The problem I have is that when the GUI is launched the node doesn't exist yet (it gets created by the GUI later) so I tried to use the Attr Slider Group but it complains that the node does not exist and therefore the connection fails causing the GUI to not launch. Ok, so that failed so I tried to use Int Group Slider and then manually link it using connectControl command. This seems to work (well at least there's no errors) but the control does not appear to link correctly. Is there any way of creating a Attr Slider Group which can be linked to a node that doesn't exist yet or loads in a disabled state?

I'd go back to using attr slider groups tbh. It's going to be a bit of an arse pain, but you should be able to do something like:


window;
columnLayout MySpecificLayoutThing;
showWindow;

if( size(`ls -type MyPluginNodeType`) )
{
setParent MySpecificLayoutThing;

// now create the controls.
}

You'd probably want a more complex GUI than that, but it demonstrates the basic principle anyway. By explicitly naming the layout, you can use setParent at a later date to add more controls to it.

You should be able to use scriptJob to get notifications when new nodes are created. You can attach these to a GUI item (such as your window) so that the script job only exists when the GUI is active.

\edit You can also create a scriptJob for nodes deleted, so that you can delete the attr controls whenever your plugin node is deleted. That should be a simple case of doing:


deleteUI `columnLayout -q -ca MySpecificLayoutThing`;


2. I have a button that loads an external file and links it to a node. At the same time I made it a symbol button so that when the user selects the file, it changes the image of the button to match the file. The problem I have with this button is that when it assigns the image to the button it does not resize it and only shows the pixel portion of it that I have specified. Is there anyway to get a symbol button to rescale the image so it fits? or alternatively is it possible to place a Texture Preview control (like that of the file node) on the GUI?

Not done too much myself in that area myself, but I suspect they are created with the SwatchRendering stuff (i.e the swatchDisplayPort mel command).

\edit

yup. swatchDisplayPort is probably what you want. It's not really a button control as such, but it does have a clicked command you can execute. Maya doesn't tend to use the swatches as buttons too much though, and always tends to have a second button to reload the textures etc.


window;
columnLayout r;
swatchDisplayPort -wh 256 256 -sn "file1" slPP;
showWindow;

huxy
03-02-2009, 01:19 AM
Thanks for the help again. I'll have a look at your suggestions and work with them as soon as I can!

Regards

CGTalk Moderation
03-02-2009, 01:19 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.