Good morning,
I was wonder how I can access my pyqt ui within maya.
Basically I’ve got a window with a QTreeWidget in it. I want to be able to clear, populate and select items in that qTreeWidget from within Maya.
Using this method: My_Sweet_UI.QTreeWidget.clear()
Here’s how I’m getting the ui into Maya:
form_class, base_class = uic.loadUiType(uiFile)
def getMayaWindow(): #Get the maya main window as a QMainWindow instance
ptr = OpenMayaUI.MQtUtil.mainWindow()
return sip.wrapinstance(long(ptr), QtCore.QObject)
class UI(base_class, form_class):
def init(self, parent=getMayaWindow()): #init our ui using the MayaWindow as parent
super(base_class, self).init(parent) #uic adds a function to our class called setupUi, calling this creates all the widgets from the .ui file
self.setupUi(self)
self.setObjectName( ‘My_Sweet_UI’ ) #Populate the UI
self.Initialize_Acc_UI()
Thanks in advanced. I can provide more info if needed.
Best,
Adrian
btribblt: I’ve tried doing that… my_ui = my.ui.open()
but I get “NoneType” as my variable
tokejenson: It’s so I can create a script job that is listening to the users inputs and acts on the UI if the user does something. ie when a animator selects a control on the rig, I want the UI to select that control in the UI and build to correct lists
guessing your open function doesn’t return the instance of the UI?
class UI(base_class, form_class):
def __init__(self, parent=getMayaWindow()):
#init our ui using the MayaWindow as parent
super(base_class, self).__init__(parent)
#uic adds a function to our class called setupUi, calling this creates all the widgets from the .ui file
self.setupUi(self)
self.setObjectName( 'My_Sweet_UI' )
#Populate the UI
self.Initialize_Acc_UI()
def open(self):
self.show()
return self
or just show the ui in init?
class UI(base_class, form_class):
def __init__(self, parent=getMayaWindow()):
#init our ui using the MayaWindow as parent
super(base_class, self).__init__(parent)
#uic adds a function to our class called setupUi, calling this creates all the widgets from the .ui file
self.setupUi(self)
self.setObjectName( 'My_Sweet_UI' )
#Populate the UI
self.Initialize_Acc_UI()
self.show()