UI in Python, New window everytime I run script ??? :(

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 04 April 2013   #1
UI in Python, New window everytime I run script ??? :(

Okay, title is pretty bad but i'll try to explain my problem...

I have created a UI in Maya Python for my code, Every time I run my entire code with the UI integrated, another UI pops up, is there any way I can set a command that deletes the previous UI and basically refreshes it, rather then it keep opening a fresh window each time I run?


I believe it has something to do with this command...

if (cmds.window("Domino Effect", exists=True)):
cmds.deleteUI("Domino Effect")



The start of my UI currently like this...

win = window( title="Domino Effect", iconName="D'Effect", w = 300, h = 300, )
layout = columnLayout()
btn1 = button( label="Gravity", command='buttonPressed()' )
btn2 = button( label="RigidBody(Ground)", command='rigidBody()' )
btn3 = button( label="Duplicate Objects", command='duplicateObj()' )


..... So my basic question is, does anyone know how I can set my code so it doesn't open a NEW window everytime I open it, instead it will just REFRESH the current one?

Thanks for any tips and tricks... If someone knows the command for this, and where I should place this command, i'd be forever grateful
 
Old 04 April 2013   #2
Quote: if (cmds.window("Domino Effect", exists=True)):
cmds.deleteUI("Domino Effect")


you answered your own question... have you tried this?
 
Old 04 April 2013   #3
Your method is correct, however your syntax is not. It seems like you're using a mix of python and pymel.

Your main problem is you're not giving your window a unique identifier.

win = window( title="Domino Effect", iconName="D'Effect", w = 300, h = 300, ) #wrong
win = cmds.window("dominoEffect_Window", title="Domino Effect", iconName="D'Effect", w = 300, h = 300) #correct


Full Fix below.

import maya.cmds as cmds

if (cmds.window("dominoEffect_Window", q=True, exists=True)):
    cmds.deleteUI("dominoEffect_Window", window=True)

win = cmds.window("dominoEffect_Window", title="Domino Effect", iconName="D'Effect", w = 300, h = 300)

layout = cmds.columnLayout()
btn1 = cmds.button( label="Gravity", command='buttonPressed()' )
btn2 = cmds.button( label="RigidBody(Ground)", command='rigidBody()' )
btn3 = cmds.button( label="Duplicate Objects", command='duplicateObj()' )
cmds.setParent("..")
cmds.showWindow(win)
 
Old 04 April 2013   #4
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 09:05 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.