Is your confusion that another example used a QMainWindow and mine used a 
QDialog?
They are both reasonable choices. QMainWindow has more features than QDialog if 
you need a window like that. It supports dock widgets and comes with more 
methods immediately intended for a main window like tool bars and menu bars and 
status bars. That is not to say you cant do the same with a dialog. 
If what you are creating needs to be a large app that creates its own dialogs 
and you need the main window features, then use it. I use a dialog for apps 
that just pop up like a dialog look to the maya main window. 
They both take the parent keyword argument. In the other example, they set the 
maya main window as the default parent. In mine, I just take all the original 
args and let you pass the parent yourself. 
You can check out the docs to read about the specific differences between 
qdialog and qmainwindow. 

- justin

On Dec 4, 2012, at 4:04 AM, san <[email protected]> wrote:

> 
> Hello Justin,
> 
> I had little bit of confusion in the example code of template for PyQt app 
> for maya , Since i am also referring the Maya Python Book,
> in which they make window class that inherits QtGui.QMainWindow while the one 
> in your code the window class inherits QtGui.QtDialogs
> 
> from PyQt4 import QtCore,QtGui
> import SIP
> 
> import maya.cmds as cmds
> import maya.OpenMayaUI as mui
> 
> def getMayaMainWindow(QtGui.QMainWindow):
>     accessMainWindow=mui.MQUtil.mainWindow()
>     return sip.wrapinstance(long(accessMainWindow),QtCore.QObject)
> 
> class Window(QtGui.QMainWindow):
>     def __init__(self,parent=getMayaMainWindow(),
>                  uniqueHandle='PyQtWindow'):
>         QtGui.QMainWindow.__init__(self.parent)
>         self.setWindowTitle('PyQtWindow')
>         self.setObjectName(uniqueHandle)
>         self.resize(400,200)
>         self.setWindow()
>     def setWindow(self):
>         #add PyQt window congtrols here in inherited class
>         pass
>     
> while in case of your example given in PyQt tutorial.
> 
> class Window(QtGui.QDialog):
>     def __init__(self,*args,**kwargs):
>         super(Window,self).__init__(*args,**kwargs)
>         # custom code here
>         self.resize(800,600)
> 
> ##everything else is same 
> 
> -- 
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings: 
> http://groups.google.com/group/python_inside_maya/subscribe

-- 
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