I have a class for that:

from PyQt4 import QtGui



########################################################################
class QApplication( QtGui.QApplication ):
    """a singleton QApplication class
    """

    #----------------------------------------------------------------------
    def __new__(cls, *args):
        if cls.instance() == None:
            # create a QApplication
            QtGui.QApplication(*args)

        # return the instance
        return cls.instance()

I derive my QApplications from that class, and it works under both 2009 and
2011...

E.Ozgur Yilmaz
Lead Technical Director
eoyilmaz.blogspot.com
www.ozgurfx.com


On Mon, Jun 28, 2010 at 6:55 AM, John Creson <[email protected]> wrote:

> pumpThread is meant for pre-2011 Maya.
> When Maya was not Built with Qt and one needed to negotiate which
> event list is in control.
> It is still in the release due to some customers needing those files
> available where they were in previous releases.
>
> The advice to eliminate the pumpthread and QtGui.Application from your
> script is good.
>
> If you'd like a script that can run inside of or outside of Maya, you
> might be able to do a check before starting QtGui.Application, and if
> you are inside of Maya, don't start start QtGui.Application.
>
> JohnCreson
> MayaQA
>
>
> On Sun, Jun 27, 2010 at 10:07 PM, Amorano <[email protected]> wrote:
> > There is no disadvantage in 2011 per se. It really depends on what you
> > want to accomplish.
> >
> > For example: I have a ton of utilities that access various data stores
> > which need to run inside and outside of Maya.
> >
> > Using a mechanism like pumpthread in pre-2011 world allows my PyQT
> > apps to run without blowing up or stalling Maya.
> >
> > Obviously they have written a better way to hook your stuff (written
> > with PyQT) into 2011, but we will most likely never use it because we
> > need the extra control of running it outside of Maya.
> >
> >
> >
> > On Jun 26, 1:41 pm, efecto <[email protected]> wrote:
> >> Hi there.
> >>
> >> Thanks for your solution.
> >>
> >> Eliminating a line with pumpThread seems to have worked!
> >>
> >> I'm very new to pumpThread.. what's the disadvantage of not having
> >> pumpThread with pyQT in Maya? Why was it causing to crash?
> >>
> >> Thanks!
> >>
> >> On Jun 26, 11:58 pm, Jimmy Caron <[email protected]> wrote:
> >>
> >>
> >>
> >> > try this without pumpthread and no QtGui.Application. In maya 2011 all
> my
> >> > custom gui work like this on Window and OSX and work well.
> >>
> >> > import sys
> >> > from PyQt4 import QtGui as qt
> >>
> >> > hello = qt.QLabel("Hello world!", None)
> >> > hello.show()
> >>
> >> > On Sat, Jun 26, 2010 at 6:14 AM, efecto <[email protected]> wrote:
> >> > > Hello tehre.
> >>
> >> > > Thank you for your response.
> >>
> >> > > I have made the environment variable and now I seem to be able to
> >> > > 'import pumpThread' without any errors.
> >>
> >> > > However, when I try to run a script in /devkit/ import mysample.py;
> >> > > mysample.mysample() it launches an UI but then maya completely
> >> > > freezes. Does anyone know how to solve this problem?
> >>
> >> > > Cheers,
> >> > > D
> >>
> >> > > On Jun 26, 8:33 pm, Erkan Özgür Yılmaz <[email protected]> wrote:
> >> > > > You need to add this path:
> >>
> >> > > > for windows:
> >> > > > C:\Program Files\Autodesk\Maya2011\devkit\other\PyQtScripts\qt
> >>
> >> > > > for linux:
> >> > > > /usr/autodesk/maya/devkit/other/PyQtScripts/qt
> >>
> >> > > > to your PYTHONPATH environment variable (in the system
> environments or in
> >> > > > Maya.env file), or append it to sys.path by
> >> > > > import sys
> >> > > > sys.append( the_path )
> >>
> >> > > > just before your code
> >>
> >> > > > E.Ozgur Yilmaz
> >> > > > Lead Technical Director
> >> > > > eoyilmaz.blogspot.comwww.ozgurfx.com
> >>
> >> > > > On Sat, Jun 26, 2010 at 8:59 AM, efecto <[email protected]>
> wrote:
> >> > > > > Hello.
> >>
> >> > > > > I have been trying to run the example in Maya 2011 eg)
> devkit\other
> >> > > > > \PyQtScripts\qt\myMakeStuff.py
> >>
> >> > > > > but I got some problems. I have also tried from zGUI.makeStuff
> import
> >> > > > > Ui_Dialog but got the same error.
> >>
> >> > > > > import sys
> >> > > > > from PyQt4 import QtCore, QtGui
> >> > > > > from makeStuff import Ui_Dialog
> >> > > > > import maya.cmds as cmds
> >> > > > > import pumpThread as pt
> >>
> >> > > > > Error: ImportError: No module named makeStuff
> >> > > > > # Error: ImportError: No module named pumpThread #
> >>
> >> > > > > This simple code works though.
> >> > > > > import sys
> >> > > > > from PyQt4 import QtGui as qt
> >> > > > > app = qt.QApplication(sys.argv)
> >> > > > > hello = qt.QLabel("Hello world!", None)
> >> > > > > hello.show()
> >>
> >> > > > > Does anyone know what I'm missing?
> >>
> >> > > > > Thanks!
> >>
> >> > > > > --
> >> > > > >http://groups.google.com/group/python_inside_maya
> >>
> >> > > --
> >> > >http://groups.google.com/group/python_inside_maya- Hide quoted text
> -
> >>
> >> - Show quoted text -
> >
> > --
> > http://groups.google.com/group/python_inside_maya
>
> --
> http://groups.google.com/group/python_inside_maya
>

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

Reply via email to