My 2cents is that it ends up being more of a pain to try and mix the two
(PyQt and Maya UI) and I would go with one or the other. The only time I
mess with Maya UI from PyQt is when i want to embed some existing type of
specialized Maya UI component, like a viewport.
The documentation for the Maya API also explains that there is a pretty
limited conversion set from the Maya UI widgets to a PyQt equivalent, which
means you would't have as rich of access to them anyways. Mainly for
embedding.

In terms of being able to get equivalent functionality from your favorite
Maya UI components, there is already a form layout in Qt, and to create a
Frame Layout is actually pretty simple. You would just make a QFrame, with
a QVBoxLayout.. Then add a widget containing some arrow button and a title,
and then your desired content widget goes in the bottom of the layout. You
can then make the arrow button toggle the visibility of the content widget.
That could pretty easily be wrapped up into a reuseable FrameWidget class.

Since Maya is an application with specialized use cases, it would be
natural that they would expose canned layout types like that. Plus that
fact that the UI components aren't classes that are easy to subclass and
extend. Whereas Qt is a framework with all the basic tools you would need
to compose any kind of custom layout widget. Just takes a little more work
to get there :-)




On Tue, Sep 17, 2013 at 8:38 PM, Joe Weidenbach <[email protected]> wrote:

> Yep, I'm officially being silly.  It hadn't occurred to me that since I've
> already got references to the maya names for my UI controls, I could just
> wrap the offending controls(the ones that only support MEL callbacks) into
> PyQt with sip and hook them up that way.  At least I think that'll work,
> will have to try it tomorrow.  Which leads to this question: is there going
> to be any performance hits/stability issues I need to be aware of if my old
> code keeps the maya UI, at least enough that it would be worth my while to
> bother reworking it to native PyQt?  Or is it ok to mix them whereever I
> need?
>
> Thanks again,
>
> Joe
>
> Sent from my iPhone
>
> On Sep 17, 2013, at 12:01 AM, Joe Weidenbach <[email protected]> wrote:
>
> Well, after writing that wall of text, I tried the children method of the
> frame object, and it does give me the child objects and layout.  I guess
> the big question is has anyone made a reference up of maya's UI objects and
> how they are encoded in the Qt objects, or do most of you just use trial
> and error to figure it out?
>
> I'm seeing how to do it, I guess I'm just figuring that if there's a
> reference somewhere I'd rather save myself the time--and if there's not a
> reference I'll get on to writing one for the community (and myself for
> future reference of course).
>
> On 9/16/2013 11:48 PM, Joe Weidenbach wrote:
>
> Call me old fashioned, but I do like Maya's UI for most in-app tools.
> However, I've hit against its limitations far too often (mostly in trying
> to build responsive UI's for my rigging tools--it seems like more and more
> of the command connections just aren't ported to python, and trying to
> encode MEL commands in breaks my object-oriented systems.  So, I've made
> the leap to PyQt.  So far I'm loving it, although I've had my issues
> understanding the systems (Several previous posts should document this).
> The question I have is partially practical, partially philosophical, but
> I'd love some feedback from the community.  The odds are good I'm too
> deeply immersed in Maya's way of handling UI to see something obvious, so
> hopefully it's something easy.
>
> I've got a ton of work done on my Master's thesis in Maya's UI, and PyQt
> doesn't have a lot of the built-in layouts (by maya's terminology--most of
> them are just widgets in PyQt) I've grown to love for my tools.  I posted
> earlier about my attempts to recreate the frameLayout, and although I've
> mostly replicated it (which was great for learning some of the internals),
> I feel like I might be taking the overall wrong approach--I am on a
> timeline for my current project (my Master's Thesis), and the crunch is
> starting to catch up to me.  I've figured out how to build frameLayouts and
> so forth using Maya's tools, and then connect them into a PyQt build--that
> part was easy, thanks to Justin's videos and Nathan Horne's blog. What I'm
> struggling with on that end is what to do from there.  Do I have access to
> the old command slots through PyQt now?  If so, is there a reference
> somewhere that I've missed in my google searches?
>
> So far, here's what I've done in my latest experiments (using the
> aforementioned FrameLayout):
>
> from PyQt4 import QtCore, QtGui
> import sip
>
> import maya.OpenMayaUI as mui
> import maya.cmds as cmds
>
> def getMainWindow():
>     ptr = mui.MQtUtil.mainWindow()
>     mainWin = sip.wrapinstance(long(ptr), QtCore.QObject)
>     return mainWin
>
> win = QtGui.QWidget(parent=getMainWindow())
> win.setWindowFlags(QtCore.Qt.Tool)
>
> fl = cmds.frameLayout(label="Joe's FrameLayout", width=300, height=500,
> collapsable=True)
> ptr = mui.MQtUtil.findControl(fl)
> frame = sip.wrapinstance(long(ptr), QtCore.QObject)
>
> frame.setParent(win)
>
> win.show()
> win.raise_()
>
> Like I said, nothing particularly special.  But, it gives me a functional
> frameLayout Widget.  However, I'm not sure how to dig into that widget once
> I have it and access its slots, or the slots of its child controls, or to
> access their values.  I imagine I can query it's children to get the
> subwidgets, so that part shouldn't be too much trouble.  I did link this
> into my wing instance so I could look at it in the debugger, but again
> that's like finding a needle in a haystack since I don't know exactly what
> I'm looking for, and it's mostly showing up as just internal functions.
> Any advice on this--using reflection or any other tools available would
> help.
>
> So, the question is this.  If there are ways to hook in to the tools from
> Maya on this, what are they?  A point in the right direction is mostly what
> I need--I'm pretty good at figuring things out once I've got that.  If not,
> am I better off just building the mayaUI components from maya (with the
> command connections) and then connecting the master layout into my PyQt
> setup?  Or should I spend the time and completely rebuild the elements I
> want (form and framelayout mostly, although I do also prefer Maya's column
> and row layouts over Q{V,H}BoxLayouts) natively in PyQt?
>
> Also, as a fair option, am I going down the wrong road entirely here, and
> should I just try to rethink my UI from the ground up to utilize just the
> layouts that Qt provides?  I know that as I get more comfortable in Qt I'll
> probably want to think more on those lines, but I'm still struggling with
> the switch.
>
> Again, if you've taken the time to read this far, Thank You!  Any thoughts
> you have would be most appreciated.
>
> Thanks,
>
> Joe
>
>
>  --
> 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 post to this group, send email to [email protected].
> 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 post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to