View Full Version : the annoying window size
Bob216 07-16-2006, 05:20 AM Hi there,
I would like to have text at the top of the window which describes the instuctions how to use the script's features, and below that, have a rowLayout of 3 columns to hold 3 buttons. I got the script for this part to work, but the problem is that the buttons do not space out evenly to what ever the window width is set to. For example if the window's true width is 400 even though I set the width to 300 in the initial window setup, and each of the 3 columns are set to 100 each, their is still a gap from the last button to the right side of the window beacuase the window is still bigger than 300. In addition here is my code that I have worked out so far....
if (`window -exists myWindow`) {
deleteUI myWindow;
}
window -width 300 myWindow;
columnLayout -width 300 ColumnOne;
text -label "This is a test";
rowLayout -numberOfColumns 3 columnWidth3 100 100 100 RowOne;
button -l "Button1" ButtonOne;
button -l "Button2" ButtonTwo;
button -l "Button3" ButtonThree;
now doing this code, my window is still bigger than 300 even though I set the width to 300. So how can I fix this?
Thanks
Bob
|
|
drGonzo
07-16-2006, 06:38 AM
//delete previous stored window prefs
windowPref -ra;
if (`window -exists myWindow`)
deleteUI myWindow;
window -width 300 myWindow;
//mind the -adj flag
columnLayout -width 300 -adj 1 ColumnOne;
text -label "This is a test";
button -l "Button1" ButtonOne;
button -l "Button2" ButtonTwo;
button -l "Button3" ButtonThree;
showWindow myWindow;
Bob216
07-16-2006, 02:20 PM
Hi,
Thank you for replying. I first tried just changing the columnLayout like you said to do but the buttons did not change. So then I looked in the help files if rowLayout does the same feature which it does so I changed my script to this...
if (`window -exists myWindow`) {
deleteUI myWindow;
}
window -width 300 myWindow;
columnLayout -width 300 ColumnOne;
text -label "This is a test";
rowLayout -numberOfColumns 3 columnWidth3 100 100 100 -ad3 1 -ad3 2 -ad3 3 RowOne;
button -l "Button1" ButtonOne;
button -l "Button2" ButtonTwo;
button -l "Button3" ButtonThree;
showWindow;
however, two things happened.
1. I get a warning that the ad3 flag can not be used more than once
2. it did channge the first column inside the rowLayout but it resized the button to fit the entire column and I did not want that. I just want the buttons to be distributted evenly. If this is not possible, then I would not mind if I could just make a window that is exactly 300 in width and it is not resizable so that this way I can layout the buttons a certain way so that my controls inside the window looks evenly distributed.
Bob216
07-16-2006, 05:01 PM
Ok, for some reason after calling columnLayout, I added this line of code...
window -e -width 300
... the window resizes to the correct width, so in other words my entire code looks like this....
if (`window -exists myWindow`) {
deleteUI myWindow;
}
window -width 300 myWindow;
columnLayout -width 300 ColumnOne;
window -e -width 300;
text -label "This is a test";
rowLayout -numberOfColumns 3 columnWidth3 100 100 100 -ad3 1 -ad3 2 -ad3 3 RowOne;
button -l "Button1" ButtonOne;
button -l "Button2" ButtonTwo;
button -l "Button3" ButtonThree;
showWindow;
.... but why do I have to do it that way? It sounds dumb that you have to add that even though you assigned the width of the window in the initial window setup. Any ideas?
drGonzo
07-16-2006, 05:20 PM
.... but why do I have to do it that way? It sounds dumb that you have to add that even though you assigned the width of the window in the initial window setup. Any ideas? This is "normal" behavior. That is to say, it shouldnt be, but it is. For some reason Maya sometimes keeps the window prefs into memory.
To remedy, you can either restart Maya, or execute this command:
windowPref -ra;
BlackHwk4
07-16-2006, 09:45 PM
Try going to Window->Settings/Preferences->Preferences and in the Interface category uncheck the part that says Windows Remember Size and Position
Mikademius
07-17-2006, 09:56 AM
If you go for the change pref method, do it like this. You NEVER want to change users preferences without ASKING or CHANGING THEM BACK.
1. Get the current state. Is "remember size and pos" "on" or "off"? Store this in a variable.
2. Change it to off if it's not already turned off.
3. Change it back to "on" ( variable you got ealier ) if that was what the user had set. If the user had "off" you won't need to set it back of course.
//check pref- store
//if on:
// - turn off
// -open win
// -turn on
//else - do nothing
//open window
Bob216
07-17-2006, 04:17 PM
Thanks for the replies. However, I would never want to be playing with someone elses prefrences, so I think I will stick with the annoying window behaviours. In addition, I looked at another type of mel script that uses a different type of layout, called formLayout, which is sort of what I am looking for. After doing some searching on the internet with the formLayout, basically I found out that the formLayout gives you better results of where you want to position your controls.
So Thanks for the help.
Bob
BlackHwk4
07-17-2006, 08:58 PM
You don't need to change someone else's preferences. I meant that you just change the Windows Remember Size and Position option for you, so you'll be able to edit your window size without Maya reverting back to the size and position it already remembered it having from the first time you created the window.
Mikademius
07-17-2006, 10:22 PM
You don't need to change someone else's preferences...
?? Didn't you just tell him to do exactly that?
Try going to Window->Settings/Preferences->Preferences and in the Interface category uncheck the part that says Windows Remember Size and Position
...I looked at another type of mel script that uses a different type of layout, called formLayout, which is sort of what I am looking for. After doing some searching on the internet with the formLayout, basically I found out that the formLayout gives you better results of where you want to position your controls.
That's correct. The formLayout gives you much more freedom, but it also requires that you spend more time creating it. Ask yourself which layout solves your situation. If you need it to be spread out, yes, use formLayouts, but if your formLayout looks like a columnLayout... Save time by choosing the right layout :)
Robken
07-18-2006, 09:19 AM
you can delete the windowPreferences for YOUR particular window...that way you won't be messing around with user preferences at ALL
in the "if" statement where you check if your UI exists, after using the "deleteUI" command, use this.
windowPref -remove nameOfWindow;
that way the preferences for YOUR window will get removed each time you want to display the window.
CGTalk Moderation
07-18-2006, 09: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.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.