Umm.... Maybe i should stick with PyQt's widget and limited on using Maya's UI element, since it might bring so much trouble. Thank Justin, for helping me out with my silly question. And Happy New Year , you working hard even on these days, don't you :D
On Sun, Dec 30, 2012 at 12:40 PM, Justin Israel <[email protected]>wrote: > When Maya tries to translate Qt widgets into Maya UI objects, it has this > really narrow range of objects that it actually maps. Maya also does some > different stuff to handle layouts. It slots in extra widgets, and also > creates internal layouts (you can read about it here: > http://download.autodesk.com/global/docs/mayasdk2012/en_us/index.html). I > am not claiming to be fully versed on the inner working of this topic. Only > that I know it has quirks. Sometimes it doesn't like certain structures to > give you a clean mapping. Maybe its a bug when you try to set a Maya UI > parent to a nested layout. > > For the second question, I am not really sure what you mean. If you > created a dialog layout, and are subclassing it in code, then you are > defining an accept() method in which the dialog is "self". Maybe give me a > snippet of your accept() method where you are having problems. > > > > On Sat, Dec 29, 2012 at 8:54 PM, Tuan Nguyen <[email protected]>wrote: > >> Sorry for trouble you so much, i understand the problem now. But still, i >> have a question about it: >> >> What is the difference beetween a Layout and one which had been morph >> into a widget? Can i see the it as a normal Layout and add widget into it >> anymore? >> >> And just a small problem, please help me out. I had created a QDialog in >> QtDesign ( Dialog without Button )to call later, but when i try to >> reimplement the accept function, i don't know how to call the dialog out >> itself (like self.dialog) to write ( if i build it by code, i will have >> dialog = QtGui.QDialog through) . >> >> Thanks :) >> >> >> On Sun, Dec 30, 2012 at 7:52 AM, Justin Israel <[email protected]>wrote: >> >>> Ok so I debugged your UI a bit and figured out the problem. It has to do >>> with another confusing quirk when trying to combine PyQt widgets with Maya >>> UI command as parent/child. >>> >>> Maya does not like layouts nested in layouts. It makes the path >>> completely break to be able to reference them. So what I had to do was >>> restructure your UI to put widgets between layouts: >>> widget -> layout -> widget -> layout >>> >>> Also I had to add some import statements to your main python script: >>> import maya.OpenMayaUI as mui >>> import sip >>> >>> I've attached the UI file. There were two spots where I had to fix the >>> layouts. You had nested layouts at the very top of the window, and also in >>> the Color_HLayout. They now have just widget ->layout -> widget. Keep in >>> mind that this is perfectly legal to do in PyQt. It is just the Maya quirk >>> when doing this specific operation of adding Maya UI to your PyQt layout: >>> >>> b = CModifyWUI.CModifyUI(parent = CModifyWUI.getMainWindow()) >>> b.show() >>> layout_pointer = long(sip.unwrapinstance(b.Color_HLayout)) >>> path = mui.MQtUtil.fullName(layout_pointer) >>> >>> # this should not crash now >>> cmds.setParent(path) >>> # this should properly add the button >>> b = cmds.button() >>> >>> >>> -- justin >>> >>> >>> >>> On Fri, Dec 28, 2012 at 8:42 PM, Tuan Nguyen <[email protected]>wrote: >>> >>>> Btw, not that I think you are doing this anyways but though it is worth >>>>> mentioning... that part at the bottom of your python ui module (in the >>>>> __main__) block is only meant for standalone (outside of Maya) apps. You >>>>> shouldn't be creating a QApplication anywhere. >>>>> >>>>> Thanks, i didn't notice that, its auto-generation after converted from >>>> UI file. >>>> >>>> And yes, if i just call out the UI file, everything is fine, both 2011 >>>> and 2012. But if i try to insert a Maya's UI element (i tested on 2012 ) , >>>> it crash right away . It only happens with my UI file, the example you gave >>>> me is fine, no crash, and the Maya UI parented to QtUI. >>>> >>>> So after i subclass UI file, this is what i do next >>>> >>>> import maya.cmds as cmds >>>> import sip >>>> import maya.OpenMayaUI as mui >>>> >>>> #Call out UI >>>> b = CModifyWUI.CModifyUI(parent = CModifyWUI.getMainWindow()) >>>> b.show() >>>> # its an emty HBoxLayout i save for insert element later >>>> layout_pointer = long(sip.unwrapinstance(b.Color_HLayout)) >>>> path = mui.MQtUtil.fullName(layout_pointer) >>>> button = cmds.button(parent = path) >>>> >>>> :( >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Python Programming for Autodesk Maya" group. >>>> To post to this group, send email to >>>> [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]. >>>> >>>> >>>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Python Programming for Autodesk Maya" group. >>> To post to this group, send email to [email protected] >>> . >>> To unsubscribe from this group, send email to >>> [email protected]. >>> >>> >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Python Programming for Autodesk Maya" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> >> >> > > -- > You received this message because you are subscribed to the Google Groups > "Python Programming for Autodesk Maya" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > > > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected].
