hi all, i'm a new python user . i got confused by various tutorials on
the internet, i'm using 2008 and 2011
i've got 2 questions.
1. is this part necessary ?
    global app
    app=QtGui.qApp
    app.connect(app, QtCore.SIGNAL("lastWindowClosed()"),
                        app, QtCore.SLOT("quit()"))

i deleted this part, my script still works . what does it do ? it
looks fine both in 2008 and 2011. maya doesn't freeze.i'm under linux


2. is this the right way to make sure only one window exists ? i don't
think so but i don't know what is the recommended way of doing it.

    try:
        myWindow.close()
    except:
        pass

thanks !

#!/usr/bin/env python2
import os
import maya.cmds as cmds
import maya.OpenMayaUI as mui
import maya.mel as mel

from PyQt4 import QtGui, QtCore, uic
from functools import partial

#Get the absolute path to my ui file
uiFile = os.path.join(cmds.internalVar(userAppDir=True),
'scripts','ui', 'myExample.ui')
print 'Loading ui file:', os.path.normpath(uiFile)

#Load the ui file, and create my class
form_class, base_class = uic.loadUiType(uiFile)

class Window(base_class, form_class):
    # def __init__(self, parent=getMayaWindow()):
    def __init__(self, parent=None):
        '''A custom window with a demo set of ui widgets'''
        #init our ui using the MayaWindow as parent
        super(base_class, self).__init__(parent)
        #uic adds a function to our class called setupUi, calling this
creates all the widgets from the .ui file
        self.setupUi(self)


def main():
    mayaVer = mel.eval("getApplicationVersionAsFloat()")

    if mayaVer<2011:
        import  pumpThread as pt
        pt.initializePumpThread()

    try:
        myWindow.close()
    except:
        pass

    global app
    app=QtGui.qApp
    app.connect(app, QtCore.SIGNAL("lastWindowClosed()"),
                        app, QtCore.SLOT("quit()"))

    global myWindow
    myWindow = Window()
    myWindow.show()

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to