I don't know if this is already protected for by Pymel, but if you were to
delete a bit of UI, like a shelfButton, you might want to put the deleteUI
into an execute deferred.
The bit below edits a shelf button that has been created "butt", to add to
the script to be executed by the shelf button an extra bit that deletes the
shelf button afterwards.

without the execute deferred, crashing may occur.

deleter = 'utils.executeDeferred(\'cmds.deleteUI("%s")\');'%(butt)

script = script + deleter

butt = cmds.shelfButton(butt, edit=True, command = script)


On Tue, Mar 31, 2009 at 12:59 PM, chadrik <[email protected]> wrote:

>
> looks really good. the only thing i think i would change would be to
> make the window name constant.  as it is, it seems that under certain
> circumstances the self.myWin attribute might not exist when the window
> actually does.
>
>
> class myUI(object):
>    winName = 'myUI'
>    def __init__(self):
>
>        try:
>            deleteUI(self.winName)
>        except:
>            pass
>
>        self.myWin = window(self. winName)
>         columnLayout()
>
>        for i in range(5):
>            button('b'+str(i),l='button_'+str(i), c = Callback
> (self.checkButton,i))
>        self.myWin.show()
>
>    def checkButton(self,id):
>        print button('b'+str(id),query=True,label=True)
>
>
> -chad
>
>
>
> On Mar 31, 2009, at 4:51 AM, marcin wrote:
>
> >
> > I've question about creating dynamic ui in pymel. Is there a way to
> > make
> > this code more pythonic in pymel ?
> >
> > from pymel import *
> >
> > class myUI(object):
> >    def __init__(self):
> >
> >        try:
> >            deleteUI(self.myWin)
> >        except:
> >            pass
> >
> >        self.myWin = window()
> >        columnLayout()
> >
> >        for i in range(5):
> >            button('b'+str(i),l='button_'+str(i), c = Callback
> > (self.checkButton,i))
> >        self.myWin.show()
> >
> >    def checkButton(self,id):
> >        print button('b'+str(id),query=True,label=True)
> >
> >
> >
> > >
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---

Reply via email to