http://pastebin.com/czT9EBXM

This should be enough to get you going.

On Tue, Jan 10, 2012 at 10:34 AM, Panupat Chongstitwattana <
[email protected]> wrote:

> Thank you Dave.
>
> It's still acting weird I tried putting "global myUI"  at different
> places, the UI only shows up if it's inside the function mySimple UI. But
> when calling the fuction again it would give me this error whether I've
> closed the first UI or not.
>
> # Error: TypeError: 'MySimpleUI' object is not callable #
>
> Putting myUI = None around the code doesn't fix it.
>
> Everything works fine tho if I remove the function and just have these 2
> lines by themselves.
>
> myUI = MySimpleUI()
> myUI.ui.show()
>
> anyway around this? :O Sorry for asking so many question.
>
> best regard,
> Panupat C.
>
> On Tue, Jan 10, 2012 at 5:23 PM, David Moulder 
> <[email protected]>wrote:
>
>> This is now down to pythons garbage collection destroying the ui.
>>
>> If you make a global variable and assign you ui to that then you'll be
>> fine.
>>
>> ie:
>>
>> global myUI
>> myUI = None
>>
>> def mySimpleUI():
>>     myUI = MySimpleUI()
>>     myUI.ui.show()
>>
>> -Dave
>>
>>
>> On Tue, Jan 10, 2012 at 10:03 AM, Panupat Chongstitwattana <
>> [email protected]> wrote:
>>
>>> Justin, thank you for the link.
>>>
>>> I'm a little curious, how do I properly use the pumpThread? With
>>> pumpThread, my UI would disappear as soon as it appeared. Am I putting the
>>> pumpThread at the right place?
>>>
>>>
>>> import pumpThread
>>> from PyQt4 import uic
>>>
>>> class MySimpleUI(object):
>>>     def __init__(self):
>>>         pumpThread.initializePumpThread()
>>>         self.ui = uic.loadUi('D:\\ui\\hello.ui')
>>>
>>> def mySimpleUI():
>>>     myUI = MySimpleUI()
>>>     myUI.ui.show()
>>>
>>>
>>> hello.ui is only a widget with a text.
>>>
>>>
>>> On Mon, Jan 9, 2012 at 11:36 PM, Kurian O.S <[email protected]> wrote:
>>>
>>>> Aha I didnt see that and it wont work previous version and he should
>>>> use pumbthread in that case ..
>>>>
>>>>
>>>> On Mon, Jan 9, 2012 at 11:19 AM, Justin Israel 
>>>> <[email protected]>wrote:
>>>>
>>>>> It should be in the sdk directory and not in your path just yet. But
>>>>> if you cant find it:
>>>>>
>>>>> http://code.google.com/p/svnformaya/source/browse/trunk/pumpThread.py?r=3
>>>>>
>>>>>
>>>>>
>>>>> On Jan 9, 2012, at 8:14 AM, Justin Israel <[email protected]>
>>>>> wrote:
>>>>>
>>>>> Kurian, he is using maya 2010 before they rewrote it in qt. so I don't
>>>>> believe MQtUtil even exists. The pumpThread utility is what he needs. It
>>>>> creates a fakey event loop that keeps processing events from qt as they
>>>>> stack up and also takes care of the global qapp that will be shared. There
>>>>> is actually no global qapp being used by maya.
>>>>>
>>>>>
>>>>>
>>>>> On Jan 9, 2012, at 6:07 AM, "Kurian O.S" <[email protected]> wrote:
>>>>>
>>>>> O otherwise you can try using this
>>>>>
>>>>> import sip
>>>>> import maya.OpenMayaUI as mui
>>>>> from PyQt4.QtCore import *
>>>>> from PyQt4.QtQtGui import *
>>>>>
>>>>> def getMayaWindow():
>>>>>     ptr = mui.MQtUtil.mainWindow()
>>>>>     return sip.wrapinstance(long(ptr), QObject)
>>>>>
>>>>> class Form(QDialog):
>>>>>     def __init__(self, parent=None):
>>>>>         super(Form, self).__init__(parent)
>>>>>         self.setObjectName('mainUI')
>>>>>         self.mainLayout = QVBoxLayout(self)
>>>>>         self.myButton = QPushButton('myButton')
>>>>>         self.mainLayout.addWidget(self.myButton)
>>>>>
>>>>> global app
>>>>> global form
>>>>> app = qApp
>>>>> form = Form(getMayaWindow())
>>>>> form.show()
>>>>>
>>>>> PS :  PyQt4.QtCore import * is not really a good idea at all.
>>>>>
>>>>> On Mon, Jan 9, 2012 at 9:01 AM, Panupat Chongstitwattana <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> David - does pumpThread come with Maya 2010?
>>>>>>
>>>>>> I'll try it out once I get to my studio tomorrow, thanks :)
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Mon, Jan 9, 2012 at 7:57 PM, David Moulder <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>> You are using pumpThread right?
>>>>>>>
>>>>>>> If so you shouldn't do sys.exit(app.exec_())
>>>>>>>
>>>>>>> just myapp.show()
>>>>>>>
>>>>>>> If your not using pumpThread you have to in Maya 2010.
>>>>>>>
>>>>>>> You can find pumpThread in the sdk folder.  From memory you need to
>>>>>>> import it and initialize it before any Qt Gui is created.
>>>>>>>
>>>>>>> import pumpThread as pt
>>>>>>> pt.initializePumpThread()
>>>>>>>
>>>>>>> -Dave
>>>>>>>
>>>>>>>
>>>>>>> On Mon, Jan 9, 2012 at 12:31 PM, Panupat Chongstitwattana <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>>>> Kamil
>>>>>>>>
>>>>>>>> The UI class is Ui_AddPlayblast.py. The set title line looks like
>>>>>>>> this
>>>>>>>>
>>>>>>>> AddPlayblast.setWindowTitle(QtGui.QApplication.translate("AddPlayblast",
>>>>>>>> "Manual Add Playblast", None, QtGui.QApplication.UnicodeUTF8))
>>>>>>>>
>>>>>>>> I tried using both "AddPlayblast" and "Manual Add Playblast" to no
>>>>>>>> avail. Is there anything else I should try?
>>>>>>>>
>>>>>>>>
>>>>>>>> Kurian - the UI script will be run exclusively in Maya. As I
>>>>>>>> understand, the __name__ = __main__ only works if you run the py file
>>>>>>>> directly? Initally I'm launching the UI with these commands
>>>>>>>>
>>>>>>>> app = QtGui.QApplication(sys.argv)
>>>>>>>> myapp = AddPlayblast()
>>>>>>>> myapp.show()
>>>>>>>> sys.exit(app.exec_())
>>>>>>>>
>>>>>>>> I tested it out in another function, and it is this line that
>>>>>>>> freezes Maya
>>>>>>>>
>>>>>>>> myapp = AddPlayblast()
>>>>>>>>
>>>>>>>>
>>>>>>>> best regard,
>>>>>>>> Panupat C.
>>>>>>>>
>>>>>>>>
>>>>>>>> On Mon, Jan 9, 2012 at 7:04 PM, Kurian O.S <[email protected]>wrote:
>>>>>>>>
>>>>>>>>> you can use
>>>>>>>>>
>>>>>>>>> class MyApp (QApplication):
>>>>>>>>>      ....
>>>>>>>>>
>>>>>>>>> if __name__ == '__main__':
>>>>>>>>>     app = MyApp( sys.argv)
>>>>>>>>>     if app.isRunning():
>>>>>>>>>         ... do whatevr u want
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Mon, Jan 9, 2012 at 5:30 PM, Ricardo Viana <
>>>>>>>>> [email protected]> wrote:
>>>>>>>>>
>>>>>>>>>> Humm. It should. Check you have your naming right on the .ui for
>>>>>>>>>> window widget.
>>>>>>>>>>
>>>>>>>>>> Best regards
>>>>>>>>>> Ricardo Viana
>>>>>>>>>>
>>>>>>>>>> On Jan 9, 2012, at 11:56 AM, Panupat Chongstitwattana <
>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>
>>>>>>>>>>  Hi Kamil.
>>>>>>>>>>
>>>>>>>>>> Thanks for suggestion. But the cmds deleteUI/window modules can't
>>>>>>>>>> seem to detect the PyQt window's titles :(
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Mon, Jan 9, 2012 at 5:31 PM, Kamil Hepner <
>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>
>>>>>>>>>>> It's very simple:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> winName = "myWindow"
>>>>>>>>>>> if pm.windows.window(winName, exists=True):
>>>>>>>>>>>        pm.windows.deleteUI(winName)
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> 2012/1/9 Panupat Chongstitwattana <[email protected]>
>>>>>>>>>>>
>>>>>>>>>>>> In Maya 2010, if I run the script to start a UI that is already
>>>>>>>>>>>> running, it would crash Maya D: How can I check if the UI is 
>>>>>>>>>>>> already
>>>>>>>>>>>> running and close it?
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> 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
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>  --
>>>>>>>>>> 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
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> --:: Kurian ::--
>>>>>>>>>
>>>>>>>>>  --
>>>>>>>>> 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
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> David Moulder
>>>>>>> http://www.google.com/profiles/squish3d
>>>>>>>
>>>>>>> --
>>>>>>> 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
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> --:: Kurian ::--
>>>>>
>>>>>  --
>>>>> 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
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> --:: Kurian ::--
>>>>
>>>>  --
>>>> 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
>>>
>>
>>
>>
>> --
>> David Moulder
>> http://www.google.com/profiles/squish3d
>>
>> --
>> 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
>



-- 
David Moulder
http://www.google.com/profiles/squish3d

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