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.