Discussion:
[Maya-Python] Trying to get into the Qt wagon
Carlos Rico
2018-09-10 18:58:39 UTC
Permalink
Hi guys, the thing is that as a starting project I would like to recreate a
MEL tool I made with Python and PySide2. It is just a window that has
buttons to open tools, that's all (you can see it in the video attached)

After googling here and there, getting some code from here and there as
well and learning some of the basics I found myself trying to get something
working but I feel like I am not on the right path.

And that is where you come into play guys. I just need some advice and
guidance to focus in the task at hand instead of trying to rush over much
documentation, if you will. I do not ask for code, just want to know where
to invest my time.

The tool I want to create with PySide2 has to be able to read a json where
the button's data is stored (title, command, tooltip, syntax(MEL/Python),
...)

I started getting info here and there and I got where you see in the
Video(by the way the buttons work and open the tools).This is already
reading the data from a json file. Collapsable "frameLayouts" from a
snippet I came across, the famous I guess flowlayout PySide2 example, using
a QCompleter in the filter field (does not filter anything for now), well,
what you see in the video. So my question is, and sorry for the long post,
what do I need to achive my goal?

Do I need a QListView, QListWidget, QItemDelegate, QCompleter? maybe there
is something already created that may serve me as a starting point, I do
not know, or maybe I need something else I do not know yet. Do I need to
sub-class my own widgets? Do I need to use the model/view thingy? As always
I am sure this can be done in many ways. I just need the easier one :)

I'll keep digging, It is just that sometimes you have to realize that the
wheel was already invented.

Thanks in advance. And sorry if this is very vague and you need more
information.


*Carlos Rico Adega*-------------------------------------
<http://www.vimeo.com/16765581> LinkedIn
<https://www.linkedin.com/in/carlos-rico-adega-3250586/>
***@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_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFzJ14VDu0V--%3DGcP9FYbmEh%2Br8zhsau9xce9_KCCYt8kEebbA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Justin Israel
2018-09-10 22:00:55 UTC
Permalink
Post by Carlos Rico
Hi guys, the thing is that as a starting project I would like to recreate
a MEL tool I made with Python and PySide2. It is just a window that has
buttons to open tools, that's all (you can see it in the video attached)
After googling here and there, getting some code from here and there as
well and learning some of the basics I found myself trying to get
something working but I feel like I am not on the right path.
And that is where you come into play guys. I just need some advice and
guidance to focus in the task at hand instead of trying to rush over much
documentation, if you will. I do not ask for code, just want to know
where to invest my time.
The tool I want to create with PySide2 has to be able to read a json where
the button's data is stored (title, command, tooltip, syntax(MEL/Python),
...)
I started getting info here and there and I got where you see in the
Video(by the way the buttons work and open the tools).This is already
reading the data from a json file. Collapsable "frameLayouts" from a
snippet I came across, the famous I guess flowlayout PySide2 example, using
a QCompleter in the filter field (does not filter anything for now), well,
what you see in the video. So my question is, and sorry for the long post,
what do I need to achive my goal?
Do I need a QListView, QListWidget, QItemDelegate, QCompleter? maybe there
is something already created that may serve me as a starting point, I do
not know, or maybe I need something else I do not know yet. Do I need to
sub-class my own widgets? Do I need to use the model/view thingy? As
always I am sure this can be done in many ways. I just need the easier one
:)
This is pretty vague and requires studying your video to understand the
nature of your question. It would be great if you could directly outline a
single specific goal, what you have so far, and what you want it to do.

You have listed some of the building blocks needed for creating a list that
can be filtered by text. You would also need a QSortFilterProxyModel
between your model and view, to be driven by the state of your filter box.
Post by Carlos Rico
I'll keep digging, It is just that sometimes you have to realize that the
wheel was already invented.
Thanks in advance. And sorry if this is very vague and you need more
information.
*Carlos Rico Adega*-------------------------------------
<http://www.vimeo.com/16765581> LinkedIn
<https://www.linkedin.com/in/carlos-rico-adega-3250586/>
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAFzJ14VDu0V--%3DGcP9FYbmEh%2Br8zhsau9xce9_KCCYt8kEebbA%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAFzJ14VDu0V--%3DGcP9FYbmEh%2Br8zhsau9xce9_KCCYt8kEebbA%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
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_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA30uwqKw1eNecRMuUgudmXpe_63AwB64AitNcBG0ijUDA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Carlos Rico
2018-09-11 19:33:44 UTC
Permalink
Hi, thanks your insight on the task Justin and for the quick response. I
will summarize what I would like the tool to be able to do.

1. Read the data for the buttons from an external file (json, yaml, ...)
This data would contain the category of the tool, the label, the command to
run, whether this command is MEL or python code to know how to run it,
tooltip, context menus where needed. I guess a simple JSON might do the job.

2. Sort categories alphabetically and sort the buttons within each category
(animation, rigging, ...)

3. Filter the buttons shown via a the QLineEdit. This QLineEdit has to
provide autocompletion based on the data. Right click context menu with the
recent filters used. I am using a QCompleter and getting the word list from
the json file (tool labels) .

4. Adding, editing and removing tools. This is another UI to manage the
data.

5. Collapsable categories as shown in the video. (snippet I found)

I am a bit worried about performance, that is one of the reasons I want to
convert the MEL code to Python and PySide2. The thing is that there are
already 1127 buttons and I really do not know how the python version would
perform. Would it be fast?

I guess I need the ModelView approach. I'll keep reading the docs. I'll
come back again to the forum when I have concrete questions.

Thank you.
Cheers!



*Carlos Rico Adega*-------------------------------------
<http://www.vimeo.com/16765581> LinkedIn
<https://www.linkedin.com/in/carlos-rico-adega-3250586/>
Post by Justin Israel
Post by Carlos Rico
Hi guys, the thing is that as a starting project I would like to
recreate a MEL tool I made with Python and PySide2. It is just a window
that has buttons to open tools, that's all (you can see it in the video
attached)
After googling here and there, getting some code from here and there as
well and learning some of the basics I found myself trying to get
something working but I feel like I am not on the right path.
And that is where you come into play guys. I just need some advice and
guidance to focus in the task at hand instead of trying to rush over
much documentation, if you will. I do not ask for code, just want to
know where to invest my time.
The tool I want to create with PySide2 has to be able to read a json
where the button's data is stored (title, command, tooltip,
syntax(MEL/Python), ...)
I started getting info here and there and I got where you see in the
Video(by the way the buttons work and open the tools).This is already
reading the data from a json file. Collapsable "frameLayouts" from a
snippet I came across, the famous I guess flowlayout PySide2 example, using
a QCompleter in the filter field (does not filter anything for now), well,
what you see in the video. So my question is, and sorry for the long post,
what do I need to achive my goal?
Do I need a QListView, QListWidget, QItemDelegate, QCompleter? maybe
there is something already created that may serve me as a starting point, I
do not know, or maybe I need something else I do not know yet. Do I need to
sub-class my own widgets? Do I need to use the model/view thingy? As
always I am sure this can be done in many ways. I just need the easier one
:)
This is pretty vague and requires studying your video to understand the
nature of your question. It would be great if you could directly outline a
single specific goal, what you have so far, and what you want it to do.
You have listed some of the building blocks needed for creating a list
that can be filtered by text. You would also need a QSortFilterProxyModel
between your model and view, to be driven by the state of your filter box.
Post by Carlos Rico
I'll keep digging, It is just that sometimes you have to realize that the
wheel was already invented.
Thanks in advance. And sorry if this is very vague and you need more
information.
*Carlos Rico Adega*-------------------------------------
<http://www.vimeo.com/16765581> LinkedIn
<https://www.linkedin.com/in/carlos-rico-adega-3250586/>
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAFzJ14VDu0V--%3DGcP9FYbmEh%2Br8zhsau9xce9_KCCYt8kEebbA%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAFzJ14VDu0V--%3DGcP9FYbmEh%2Br8zhsau9xce9_KCCYt8kEebbA%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA30uwqKw1eNecRMuUgudmXpe_63AwB64AitNcBG0ijUDA%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA30uwqKw1eNecRMuUgudmXpe_63AwB64AitNcBG0ijUDA%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
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_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFzJ14VPsEM2EJiEuidMi7nq4K%3DBCHtJ4CP96ybF-CYKf0xEiw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Justin Israel
2018-09-11 19:51:36 UTC
Permalink
Post by Carlos Rico
Hi, thanks your insight on the task Justin and for the quick response. I
will summarize what I would like the tool to be able to do.
1. Read the data for the buttons from an external file (json, yaml, ...)
This data would contain the category of the tool, the label, the command to
run, whether this command is MEL or python code to know how to run it,
tooltip, context menus where needed. I guess a simple JSON might do the job.
2. Sort categories alphabetically and sort the buttons within each
category (animation, rigging, ...)
Your options are to either add the items to the model pre-sorted and keep
adding new ones in a sorted order, and use Qsortfilterproxymodel only for
the filtering. Or to also use Qsortfilterproxymodel also for its custom
sort function.
Post by Carlos Rico
3. Filter the buttons shown via a the QLineEdit. This QLineEdit has to
provide autocompletion based on the data. Right click context menu with the
recent filters used. I am using a QCompleter and getting the word list from
the json file (tool labels) .
4. Adding, editing and removing tools. This is another UI to manage the
data.
5. Collapsable categories as shown in the video. (snippet I found)
I am a bit worried about performance, that is one of the reasons I want to
convert the MEL code to Python and PySide2. The thing is that there are
already 1127 buttons and I really do not know how the python version would
perform. Would it be fast?
If you use a model/view approach, it should work fine since those 1127
buttons aren't all going to be triggering paint events at the same time.
Only the visible widgets in the view will trigger any activity. Even though
the bindings are in Python, effectively you are still creating C++ objects.
The slowness comes from python code that gets executed frequently such as
custom events or data logic. Or constantly constructing, destroying, or
accessing python objects.
Post by Carlos Rico
I guess I need the ModelView approach. I'll keep reading the docs. I'll
come back again to the forum when I have concrete questions.
Thank you.
Cheers!
*Carlos Rico Adega*-------------------------------------
<http://www.vimeo.com/16765581> LinkedIn
<https://www.linkedin.com/in/carlos-rico-adega-3250586/>
Post by Justin Israel
Post by Carlos Rico
Hi guys, the thing is that as a starting project I would like to
recreate a MEL tool I made with Python and PySide2. It is just a window
that has buttons to open tools, that's all (you can see it in the video
attached)
After googling here and there, getting some code from here and there as
well and learning some of the basics I found myself trying to get
something working but I feel like I am not on the right path.
And that is where you come into play guys. I just need some advice and
guidance to focus in the task at hand instead of trying to rush over
much documentation, if you will. I do not ask for code, just want to
know where to invest my time.
The tool I want to create with PySide2 has to be able to read a json
where the button's data is stored (title, command, tooltip,
syntax(MEL/Python), ...)
I started getting info here and there and I got where you see in the
Video(by the way the buttons work and open the tools).This is already
reading the data from a json file. Collapsable "frameLayouts" from a
snippet I came across, the famous I guess flowlayout PySide2 example, using
a QCompleter in the filter field (does not filter anything for now), well,
what you see in the video. So my question is, and sorry for the long post,
what do I need to achive my goal?
Do I need a QListView, QListWidget, QItemDelegate, QCompleter? maybe
there is something already created that may serve me as a starting point, I
do not know, or maybe I need something else I do not know yet. Do I need to
sub-class my own widgets? Do I need to use the model/view thingy? As
always I am sure this can be done in many ways. I just need the easier one
:)
This is pretty vague and requires studying your video to understand the
nature of your question. It would be great if you could directly outline a
single specific goal, what you have so far, and what you want it to do.
You have listed some of the building blocks needed for creating a list
that can be filtered by text. You would also need a QSortFilterProxyModel
between your model and view, to be driven by the state of your filter box.
Post by Carlos Rico
I'll keep digging, It is just that sometimes you have to realize that
the wheel was already invented.
Thanks in advance. And sorry if this is very vague and you need more
information.
*Carlos Rico Adega*-------------------------------------
<http://www.vimeo.com/16765581> LinkedIn
<https://www.linkedin.com/in/carlos-rico-adega-3250586/>
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAFzJ14VDu0V--%3DGcP9FYbmEh%2Br8zhsau9xce9_KCCYt8kEebbA%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAFzJ14VDu0V--%3DGcP9FYbmEh%2Br8zhsau9xce9_KCCYt8kEebbA%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
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
To view this discussion on the web visit
Post by Justin Israel
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA30uwqKw1eNecRMuUgudmXpe_63AwB64AitNcBG0ijUDA%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA30uwqKw1eNecRMuUgudmXpe_63AwB64AitNcBG0ijUDA%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAFzJ14VPsEM2EJiEuidMi7nq4K%3DBCHtJ4CP96ybF-CYKf0xEiw%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAFzJ14VPsEM2EJiEuidMi7nq4K%3DBCHtJ4CP96ybF-CYKf0xEiw%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
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_maya+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0w3b%2BRuBajT9TTgG19XayC0LdVw5SBRm3uizk3DdZyoA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...