Heya

Right that sort of explains a lot ! I have to run few tests and try it out 
more in depth.... 

In any case I'm bit lost with ur explanation... I'm getting Unexpected 
indent in my __init__ function for some reason, I thought I can just type 
there anything I want to have in __ini__ as my template or so :S

I also finally got an idea how I link buttons... or I think. I define the 
link of button name and option in __init__ and then I can create function 
for it later on...  gotta read manual instead of spamming u gurys here :)

anyway here is a bit of work attempt I did... 

from PyQt4 import QtCore, QtGui, uic
import maya.OpenMayaUI as mui
import sip

baseUI = "C:\Users\dmakowski\Desktop\PyQTtests\My\ui\ui3.ui"
baseUIClass, baseUIWidget = uic.loadUiType(baseUI)

class Ui_MainWindow(baseUIWidget, baseUIClass):
def __init__(self,parent=None):
super(baseUIWidget, self).__init__(parent)
self.setupUi(self)
self.btallsettings.clicked.connect(self.btallClicked)



def getMayaWindow():
ptr = mui.MQtUtil.mainWindow()
return sip.wrapinstance(long(ptr), QtCore.QObject)

def mayaMain():
maya_ui1_window = Ui_MainWindow(getMayaWindow())
maya_ui1_window.show()

def btallClicked(self):
# do whatever you want
cmds.sphere() 

mayaMain()

On Friday, 9 November 2012 12:14:48 UTC, Panupat Chongstitwattana wrote:
>
> Hey Daz.
>
> self.setupUI() <---- should use a small letter i. Sorry.
>
> self.seuoUi()
>
> On Fri, Nov 9, 2012 at 6:35 PM, Panupat Chongstitwattana <
> [email protected] <javascript:>> wrote:
>
>> Hey Daz.
>>
>> No worry. I'm a newbie myself. Believe me, when I just started, I bombard 
>> this group with tons of questions and everyone was very helpful :) 
>>
>> So first, the getMayaWindow() function is there to tell PyQt that the UI 
>> we're creating is a child of Maya's UI. Without it, your UI will still 
>> work. But it can, and will, go behind Maya's windows. Making it kinda 
>> annoying to find. Don't worry about the content of it much, just use it the 
>> way it is.
>>
>> Next, what you do, is you sub class one of PyQt's UI class. For example
>>
>> testUI = QtGui,QMainWindow()
>> testUI.show()
>>
>> Similar idea, instead of typing out the base class yourself, you let uic 
>> do it for you (plus loads the ui in the process)
>>
>> baseUI = "path/to/ui/file"
>> from_class, base_class = uic.loadUiType(baseUI)
>>
>> Then you subclass your own class from those 2.
>>
>> class myUI( base_class , from_class ):
>>
>>     def __init__(self, parent=getMayaWindow()):
>>         super(base_class, self).__init__(parent)
>>         self.setupUI()
>>
>> And that's where you tell your UI to become child of Maya's window. You 
>> can replaced the getMayaWindow() with None to see what happens.
>>
>> Now to display your UI :
>>
>> test = myUI()
>> test.show()
>>
>> Next. You have a QPushButton named "btallsettings". We want it to fire 
>> off a command when clicked. So, add this to your __init__
>>
>> self.btallsettings.clicked.connect(self.btallClicked)
>>
>> and add a new def within the class
>>
>> def btallClicked(self):
>>         # do whatever you want
>>         cmds.sphere()
>>
>>  You can read more about each class in nokia's website. 
>> http://doc.qt.nokia.com/4.7/index.html I found it a ton easier to 
>> understand than PyQt's riverbank site.
>>
>> I hope that helps clarify some basics! :)
>>
>> Best regard,
>> Panupat.
>>
>
>

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