I edited the class below to reference the class for my browser using the following lines of code to show the window:
 
a = Browser()
a.show()
 
Two things happen.. first the window does not stay "parented" to the main Maya window and will disappear under Maya.
 
Second... using the compiled version of calculatorform that comes with Qt works fine. However, when I used uic.compileUi to complile the calculatorform.ui. I get the following error:
 
# Error: ... global name '_' is not defined #
 
The compiler added a '_' that doesn't belong. For example:
 
CalculatorForm.setWindowTitle(_( u"Calculator Form"))
 
If I removed the '_', it will open.
 
Also, on a ui that I created I had to comment out the following lines because:
test.setCentralWidget(self.centralwidget)
test.setMenuBar(self.menubar)
test.setStatusBar(self.statusbar)
 
They cause a Attribute Error such as:
# Error: AttributeError ... 'Browser' object has no attribute 'setCentralWidget' #
 
Is there a way to get a compiled version of a Ui to open without having to edit the file?
 
Thanks,
-brian
 
-------- Original Message --------
Subject: Re: [Maya-Python] Calling a compiled QT file in Maya
From: David Moulder <[email protected]>
Date: Thu, August 05, 2010 8:09 am
To: [email protected]

I use multiple inheritance...

import ui_Browser
class Browser(QtGui.QWidget, ui_Browser.Ui_Form):
    def __init__(self, parent=None):
        super(Browser, self).__init__(parent)
        self.setupUi(self)
        self.setObjectName('Browser')
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

-Dave

On Thu, Aug 5, 2010 at 2:39 PM, meljunky <[email protected]> wrote:
Trying to get QT Ui file to work in Maya I could use the loadUI
command for example:

import maya.cmds as cmds
dialog = cmds.loadUI(f=r'C:/Python26/Lib/site-packages/PyQt4/examples/
designer/calculatorform/calculatorform.ui')
cmds.showWindow(dialog)

Don't expect the calculator to actually work but the UI opens in Maya.
But, I want to be able to edit UI elements so I used uic.compileUi to
convert the file into a Python file in hopes to make method calls to
add and remove UI elements while the window is open.

The first four lines are:
from PyQt4 import QtCore, QtGui

class Ui_CalculatorForm(object):
   def setupUi(self, CalculatorForm):
       ...

At this point I don't know how to call the Ui_CalculatorForm class
method setupUi since it needs a different class called CalculatorForm.

Thanks in advance.

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



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

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

Reply via email to