Actually in your case using loadUi you could just do this for now:

self.ui = uic.loadUi("uifile.ui", self)

This will use your main window as the base class





On May 2, 2012, at 7:57 AM, Panupat Chongstitwattana <[email protected]> wrote:

> Thanks for the tips Justin!  I think I read Nathan's post about super 
> classing the ui to gain access to the ui.setup method. I'll experiment with 
> it :)
> 
> Thanks
> 
> On Wed, May 2, 2012 at 9:54 PM, Justin Israel <[email protected]> wrote:
> Also, I just wanted to point out that the way you are using your UI file is 
> less than desirable. There are a couple recommended approaches you can use 
> here:  http://doc.qt.nokia.com/4.7-snapshot/designer-using-a-ui-file.html
> 
> But if you just load it into self.ui and then start doing self.ui.show(), 
> your main window has not been set up by the ui. That is, your main window is 
> never really showing. Only the new widgets set up in the ui. No show events, 
> resize events etc. 
> Ideally you would do something like:  
> self.ui.setupUi(self)
> Now your main window would be set up and you can do self.show()
> Just a suggestion.  
> 
> 
> 
> On May 2, 2012, at 1:49 AM, Panupat Chongstitwattana <[email protected]> 
> wrote:
> 
>> Ah got it. It's working now, thanks :)
>> 
>> On Wed, May 2, 2012 at 3:48 PM, David Moulder <[email protected]> 
>> wrote:
>> python garbage collection doing it's work.  "test" is dying after the 
>> function is finished and your UI is automatically closed.  You need a global 
>> to keep it alive. 
>> 
>> On Wed, May 2, 2012 at 9:16 AM, Panupat Chongstitwattana 
>> <[email protected]> wrote:
>> Maya 2012 x64 on Windows here. Here's a simple class loading the ui file.
>> 
>> class UI(QtGui.QMainWindow):
>>     def __init__(self, parent=None):
>>         QtGui.QWidget.__init__(self, parent)
>>         self.ui = uic.loadUi(PATH)
>> 
>> If I execute these command on their own, the UI shows up no problem.
>> 
>> test = loginUI()
>> test.ui.show()
>> 
>> But if I wrap those in a function, the UI would show up for an instant and 
>> closes itself.
>> 
>> def testui():
>>     test = loginUI()
>>     test.ui.show()
>> testui()
>> 
>> What could be the cause of it? Am I missing something?
>> Thanks
>> 
>> -- 
>> 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
> 
> -- 
> 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

Reply via email to