There's a window Title, and a window name (every gui element has a name).
This ui name has to conform to the same rules of naming variables in python,
so "World Co-Ords" is thus invalid (spaces, dash...). 

Try this:

class WCForm(pm.Window):
    '''
    World Coords UI Form.
    '''
    winTitle = 'World Co-Ords'
    winName = "worldCoOrds"


    def __new__(cls):
        if pm.window(cls.winName, exists=True):
            pm.deleteUI(cls.winName)
        self = pm.window(cls.winName, title=cls.winTitle)
        return pm.Window.__new__(cls, self)

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of thirstydevil
Sent: Thursday, September 24, 2009 1:48 AM
To: python_inside_maya
Subject: [Maya-Python] Pymel __new__(cls)


Trying to do some UI stuff in pymel.  Wondering why pm.window
(cls.winName, exists=True) is always
failing.  It seems the UI is not getting the Window name. Using Pymel
9.2.0

Cheers
-Dave

PS
I understand the concept of __new__() but I'm fuzzy on why these lines
are needed?
        self = pm.window(cls.winName, title=cls.winName)
        return pm.Window.__new__(cls, self)

# example UI code:
def DisplayUI():
    '''
    calls the window.
    '''
    win = WCForm()

class WCForm(pm.Window):
    '''
    World Coords UI Form.
    '''
    winName = 'World Co-Ords'

    def __new__(cls):
        if pm.window(cls.winName, exists=True):
            pm.deleteUI(cls.winName)
        self = pm.window(cls.winName, title=cls.winName)
        return pm.Window.__new__(cls, self)

    def __init__(self):
        super(WCForm, self).__init__()
        self.show()


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

Reply via email to