Maya's UI

74 views
Skip to first unread message

illunara

unread,
Aug 19, 2014, 12:08:37 PM8/19/14
to python_in...@googlegroups.com
Hi everybody
I wonder if we can add some event/listener to Maya's Primitive UI? Like, when some value get change? or edit the floatSlider to fire some command with -cc flag?
Thanks

Fredrik Averpil

unread,
Aug 19, 2014, 2:53:37 PM8/19/14
to python_in...@googlegroups.com
Perhaps you can achieve what you need via scriptJob?


// Fredrik


--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/0e752d10-1f3e-4ab9-b380-93c55f9e26f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

illunara

unread,
Aug 19, 2014, 3:11:22 PM8/19/14
to python_in...@googlegroups.com
Thank for reply
Yes, ofc, its possible. But I just want to try different way :D

Justin Israel

unread,
Aug 19, 2014, 3:21:09 PM8/19/14
to python_in...@googlegroups.com

You can try looking them up through Qt (MQtUtil) and using their signals or events. 

On 20/08/2014 7:11 AM, "illunara" <cb.il...@gmail.com> wrote:
Thank for reply
Yes, ofc, its possible. But I just want to try different way :D

--
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 python_inside_m...@googlegroups.com.

Marcus Ottosson

unread,
Aug 19, 2014, 3:44:20 PM8/19/14
to python_in...@googlegroups.com

You could try locating their QWidget instance and monkey-patch the method responsible for updating it. :)

# E.g.
def setText(self, text):
    super(...)
    print "Gotcha!

some_widget_you_found.setText = setText



For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Justin Israel

unread,
Aug 19, 2014, 3:58:07 PM8/19/14
to python_in...@googlegroups.com


On 20/08/2014 7:44 AM, "Marcus Ottosson" <konstr...@gmail.com> wrote:
>
> You could try locating their QWidget instance and monkey-patch the method responsible for updating it. :)
>
> # E.g.
> def setText(self, text):
>     super(...)
>     print "Gotcha!
>
> some_widget_you_found.setText = setText
>
>

I think that would only work for virtual methods of the widget, and also probably not have any effect on the underlying Qt in Maya since it wouldn't know about the virtual method of your local python object.

It does work when you own the widgets in your app.


>
>
> On 19 August 2014 21:21, Justin Israel <justin...@gmail.com> wrote:
>>
>> You can try looking them up through Qt (MQtUtil) and using their signals or events. 
>>
>> On 20/08/2014 7:11 AM, "illunara" <cb.il...@gmail.com> wrote:
>>>
>>> Thank for reply
>>> Yes, ofc, its possible. But I just want to try different way :D
>>>
>>> --
>>> 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 python_inside_m...@googlegroups.com.
>>> To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/9338dbc4-bac7-4aca-888a-b2203aa40518%40googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> 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 python_inside_m...@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2Xf%2B3bZBAYa-VNNDbGGLcjgOwQK5LV78kkGGOctru-xA%40mail.gmail.com.
>>
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> Marcus Ottosson
> konstr...@gmail.com
>
> --
> 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 python_inside_m...@googlegroups.com.

> To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODb0%2Bo0%3DrPFjta2RmeUZ30HB%3DDakSy6_yskJy8T8B5Nkw%40mail.gmail.com.

Tuan Nguyen

unread,
Aug 20, 2014, 12:26:35 AM8/20/14
to python_in...@googlegroups.com
Eh, i thought Maya's primitive UI build using MEL (Panel, slider, field.....)? I used QT before, but that's complete different story, right?
If we got the element's name, then we can use Maya's command to edit it using flags to do things we want.


Marcus Ottosson

unread,
Aug 20, 2014, 12:36:53 AM8/20/14
to python_in...@googlegroups.com

Eh, i thought Maya’s primitive UI build using MEL (Panel, slider, field…..)?

That is true, but MEL is using Qt. :)

If we got the element’s name, then we can use Maya’s command to edit it using flags to do things we want.

Or, the QObject name.

object_name = my_widget.objectName()
my_widget = main_window.findChild(object_name)

I think that would only work for virtual methods of the widget, and also probably not have any effect on the underlying Qt in Maya since it wouldn’t know about the virtual method of your local python object.

Monkey-patching probably wouldn’t work, that’s true. But installing an event-filter might.

http://qt-project.org/doc/qt-4.8/qobject.html#installEventFilter

my_widget.installEventFilter()


On 20 August 2014 06:26, Tuan Nguyen <cb.il...@gmail.com> wrote:
Eh, i thought Maya's primitive UI build using MEL (Panel, slider, field.....)? I used QT before, but that's complete different story, right?
If we got the element's name, then we can use Maya's command to edit it using flags to do things we want.


--
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 python_inside_m...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Tuan Nguyen

unread,
Aug 20, 2014, 12:59:58 AM8/20/14
to python_in...@googlegroups.com
Oh Wow, never know that MEL is using QT O_O Still vague to me, but i will give it a try :D Thanks

Marcus Ottosson

unread,
Aug 20, 2014, 1:23:22 AM8/20/14
to python_in...@googlegroups.com
Well, the entire UI is Qt. I'm not sure about parts of it, such as the model viewport, which is possible coming from elsewhere, but for the buttons and sliders you're looking for, that's all Qt.

There are methods for getting the widget under the mouse cursor. If I were you, I might have a look at identifying widgets that way, for starters. You could also install an event-filter on the whole app, and have each widget under the mouse light up and possibly tell you its name.

These are brute-force approaches of course, I'm not aware of any documentation for the actual names of things in the UI.


On 20 August 2014 06:59, Tuan Nguyen <cb.il...@gmail.com> wrote:
Oh Wow, never know that MEL is using QT O_O Still vague to me, but i will give it a try :D Thanks

--
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 python_inside_m...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Reply all
Reply to author
Forward
0 new messages