cmds.loadUI() is a really limited approach to loading Qt Designer UI files.
It immediately converts everything to Maya controls and gives you back a
path. This approach kind of expects that you will do the thing where you
create dynamic properties inside of Designer, on your widgets, that will be
treated as flags when Maya goes to create that equivalent control. Like if
you were to create a QPushButton and then add a property called "+command",
with a value of "<some python callback>"
In your second approach, it's not really valid code right now. You
have Interface class defined to inherit from two objects that don't exist,
which you are creating privately from within your function. Typically the
approach of using uic to load a UI file dynamically would happen in the
root of the module (or importing from another module that is doing it), so
that it is available for your to inherit from in your class definition.
There is also another way, using uic.loadUi() to have it load onto your own
class. So if you design a QDialog, and then create a QDialog subclass, it
might look like:
class MyClass(QtGui.QDialog):
def __init__(self, *args, **kwargs):
super(MyClass, self).__init__(*args, **kwargs)
uic.loadUi("test.ui", self)
This would be loading the UI every single time a MyClass instance is
constructed, as opposed to at import time. Its up to you how you want to
organize your approach.
Like Jesse, I don't use Designer anymore, so I don't have too much more to
say about it. But when I was using it, I was pre-converting my UI files to
py so that I didn't have to deal with resource loading, and just pure
python. It gets a lot easier when you end up dropping Designer and writing
the UI's directly in your own code.
On Sat, Mar 1, 2014 at 2:13 PM, Jesse Kretschmer <[email protected]> wrote:
>
> On Fri, Feb 28, 2014 at 1:52 PM, lala <[email protected]> wrote:
>
>> lastly, approach 1, window ui shows nicely. it won't go behind maya ui,
>> as i click in viewport
>> where as even in template script (makeCube_ui.py) it works. but goes back
>> (behind) maya windows when i click in viewports .
>>
>
> There is a window flag for tool mode to keep a window on top of maya. I
> usually use QDialog, but it should work on any QWidget. Example:
> someDialog.setWindowFlags( QtCore.Qt.Tool )
>
> Here's a full example with that flag: http://pastebin.com/uzu2faY6
>
> I don't often use designer, so I can't comment on a good workflow.
>
> cheers,
> jesse
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CANESWi3KLsPxh86XF16ZZywutkb5V2hCw84ro%2BPAPf4TX%2BUEbA%40mail.gmail.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3vCOB9rnrp8nWOeiy%3Dfe9EMmV9Ez-QdSS5jNumgW6opw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.