PDA

View Full Version : What's the opposite of showWindow?


Mooncalf
01-09-2004, 07:50 AM
Hi y'all,

I've searched the forums as best I can and couldn't find an answer...

Is there a command I can execute from inside a window that will close the window? I've looked for anything like

closeWindow

or

hideWindow

or

killWindow

but to no avail. (and I've gotta say, while the MEL Reference in the help menu is darned comprehensive, I wish there was somewhere I could go for definitions and usages of other terms MEL uses, like "string" and "global proc"... am I just not seeing this?)


Thanks!


- M

nendo
01-09-2004, 10:18 AM
deleteUI -window $myWindow;

safakoner
01-09-2004, 01:29 PM
If your window is already open, close the window and open again. ( Not open same window twice )

if (`window -q -exists yourwindow`) deleteUI yourwindow;

Mooncalf
01-09-2004, 04:51 PM
Thanks for the responses, y'all...

I should have mentioned that deleteUI was the first thing I tried, but all it seems to do is clear the window, not close it. That is, the window remains open, only all textFields, sliders, buttons, etc. are gone. It's just a big, grey window.

I also tried my usual trick of "Echo All Commands" in the Script Editor. ctrl-W seems to return the echo: "closeFrontWindow". But when I put that into my script, Maya executes about 50,000 other commands and then crashes.

Any ideas?

(does it matter that I'm on a Mac? I know sometimes that'll account for tiny differences)

- M

mhovland
01-09-2004, 06:23 PM
When you create your window, make sure you give it a Maya internal name:



window -t "Test" -h 100 -w 200 -tlc 150 150 myNewTestWindow;

showWindow myNewTestWindow;



If you have a Maya internal name that you know, you can do all kinds of cool things like this:



//delete the window

deleteUI -window myNewTestWindow;


Or:


//check to see if the window already exists
//if it does, delete it. Put this at the top of all your UI
//procedures that build a window. This will keep you
//from getting errors that say the window name is not unique

if(`window -exists myNewTestWindow`)
{
deleteUI -window myNewTestWindow;
}

window -t "Test" -h 100 -w 200 -tlc 150 150 myNewTestWindow;

showWindow myNewTestWindow;

Mooncalf
01-09-2004, 06:36 PM
Hey Mike,

I've got all the Maya Internal Names going on... I believe you cautioned me about that before, and it stuck. ;)

Here's what I've got going on:


if (`window -exists rename`) deleteUI rename;

window -t "Rename" -w 650 -h 130 rename;

string $form = `formLayout rename`;

string $newType = `textField
-ec ("string $newName = `textField -q -tx newType`; \ rename $newName; \ deleteUI rename;")
newType`;

formLayout -e
-attachForm $newType left 25
-attachForm $newType top 25
$form;

showWindow rename;




The window closing part is in the middle there... essentially, I'm trying to say:

"When enter is pressed:

1) Query what's in the text field

2) Rename the current object to that

3) Close the window"


Is it possible my trouble is because of where I'm trying to close the window from?


- M

mhovland
01-09-2004, 07:31 PM
Your errors were happening in the deleteUI portions. You weren't telling Maya what type of UI element to delete. You need to add the -window flag. The following works as expected:


if (`window -exists rename`) deleteUI -window rename;

window -t "Rename" -w 650 -h 130 rename;

string $form = `formLayout rename`;

string $newType = `textField
-ec ("string $newName = `textField -q -tx newType`; \ rename $newName; \ deleteUI -window rename;")
newType`;

formLayout -e
-attachForm $newType left 25
-attachForm $newType top 25
$form;

showWindow rename;

mhovland
01-09-2004, 07:40 PM
Interestingly enough, I looked into both the deleteUI command, and your code and figured out what was happening.

First in the code, you are naming two UI controls the same thing.

window -t "Rename" -w 650 -h 130 rename;

and

string $form = `formLayout rename`;

So from seeing what Maya was doing I figure that the formLayout name was what Maya saw as "rename". Why, I can only guess that the order of creation of the UI controls matters, in that you created a window named "rename" and Maya knew that, then you told Maya that the formLayout was what was REALLY named "rename". The net result was that Maya deleted the UI control it thought was named "rename" (the formLayout, are you confused yet?)

So.....you should rename the formLayout to be something like

formLayout renameForm;

and the window

window -t "Rename" -w 650 -h 130 renameWin;

Hope that clears it up a little.

Mooncalf
01-12-2004, 07:29 PM
There you go saving me again, Mike.

Seriously, someone needs to get you a cape and a secret identity as a mild-mannered reporter or something. :)

Thanks so much for looking through my code like that... above and beyond the call, I say.

Hopefully these foolish mistakes will wear off soon...


- M

CGTalk Moderation
01-17-2006, 03:00 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.