Discussion:
[Maya-Python] Dynamically add checkBoxes in PySide while being able to refer to them later
Jakob Kousholt
2018-11-19 05:54:32 UTC
Permalink
Hi,

I am trying to add a bunch of buttons and UI elements based of a python
list. My issue is that I would need to refer to them later to see if they
are checked or unchecked. Usually I would assign the button to a variable
and check that specific variable for the state of the checkbox like:

potatoCheckBox = QtWidgets.QCheckBox()
potatoCheckBox.checkState()

But I am not sure how to get about it over a list. of course the code is
not making any sense as you can't add two strings like that together to
assign a variable - big mess, However I think it kinda shows how I would
like to go about it. Using my list as a prefix for a lot of new attributes
on my UI class.

list = ['potato', 'tomato', 'poop']

for obj in list:
obj + CheckBox = QtWidgets.QCheckBox()

potatoCheckBox.checkState()
tomatoCheckBox.checkState()
poopCheckBox.checkState()

Any pointers in the right direction would be much appreciated. Thank you.

Jake
--
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/CAEKd6bbuUefk%2Bt8rmVT4wt8CVhu6ZBmx6N6pTKQOE%3DOeg1LH1w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Marcus Ottosson
2018-11-19 06:24:49 UTC
Permalink
How about something like this?

list = ['potato', 'tomato', 'poop']
boxes = {}
for obj in list:
boxes[obj] = QtWidgets.QCheckBox()

boxes["potato"].checkState()
boxes["tomato"].checkState()
boxes["poop"].checkState()
Post by Jakob Kousholt
Hi,
I am trying to add a bunch of buttons and UI elements based of a python
list. My issue is that I would need to refer to them later to see if they
are checked or unchecked. Usually I would assign the button to a variable
potatoCheckBox = QtWidgets.QCheckBox()
potatoCheckBox.checkState()
But I am not sure how to get about it over a list. of course the code is
not making any sense as you can't add two strings like that together to
assign a variable - big mess, However I think it kinda shows how I would
like to go about it. Using my list as a prefix for a lot of new attributes
on my UI class.
list = ['potato', 'tomato', 'poop']
obj + CheckBox = QtWidgets.QCheckBox()
potatoCheckBox.checkState()
tomatoCheckBox.checkState()
poopCheckBox.checkState()
Any pointers in the right direction would be much appreciated. Thank you.
Jake
--
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/CAEKd6bbuUefk%2Bt8rmVT4wt8CVhu6ZBmx6N6pTKQOE%3DOeg1LH1w%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAEKd6bbuUefk%2Bt8rmVT4wt8CVhu6ZBmx6N6pTKQOE%3DOeg1LH1w%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/CAFRtmODgaZ3gajU7BzQ-Q%3DhVKqS8m_LV7e%2BESCJDD5HB%2B1_Uew%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Justin Israel
2018-11-19 08:01:18 UTC
Permalink
From what part of the world does this cuisine originate?
Post by Marcus Ottosson
How about something like this?
list = ['potato', 'tomato', 'poop']
boxes = {}
boxes[obj] = QtWidgets.QCheckBox()
boxes["potato"].checkState()
boxes["tomato"].checkState()
boxes["poop"].checkState()
Post by Jakob Kousholt
Hi,
I am trying to add a bunch of buttons and UI elements based of a python
list. My issue is that I would need to refer to them later to see if they
are checked or unchecked. Usually I would assign the button to a variable
potatoCheckBox = QtWidgets.QCheckBox()
potatoCheckBox.checkState()
But I am not sure how to get about it over a list. of course the code is
not making any sense as you can't add two strings like that together to
assign a variable - big mess, However I think it kinda shows how I would
like to go about it. Using my list as a prefix for a lot of new attributes
on my UI class.
list = ['potato', 'tomato', 'poop']
obj + CheckBox = QtWidgets.QCheckBox()
potatoCheckBox.checkState()
tomatoCheckBox.checkState()
poopCheckBox.checkState()
Any pointers in the right direction would be much appreciated. Thank you.
Jake
--
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/CAEKd6bbuUefk%2Bt8rmVT4wt8CVhu6ZBmx6N6pTKQOE%3DOeg1LH1w%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAEKd6bbuUefk%2Bt8rmVT4wt8CVhu6ZBmx6N6pTKQOE%3DOeg1LH1w%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/CAFRtmODgaZ3gajU7BzQ-Q%3DhVKqS8m_LV7e%2BESCJDD5HB%2B1_Uew%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODgaZ3gajU7BzQ-Q%3DhVKqS8m_LV7e%2BESCJDD5HB%2B1_Uew%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/CAPGFgA0hr_MTj6tsGphBSpSY5WjMgM3fy3LLX3LnoJTDn-4FOA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Marcus Ottosson
2018-11-19 08:49:08 UTC
Permalink
I think it's referred to as a "Wellington Stew"
Post by Justin Israel
From what part of the world does this cuisine originate?
Post by Marcus Ottosson
How about something like this?
list = ['potato', 'tomato', 'poop']
boxes = {}
boxes[obj] = QtWidgets.QCheckBox()
boxes["potato"].checkState()
boxes["tomato"].checkState()
boxes["poop"].checkState()
Post by Jakob Kousholt
Hi,
I am trying to add a bunch of buttons and UI elements based of a python
list. My issue is that I would need to refer to them later to see if they
are checked or unchecked. Usually I would assign the button to a variable
potatoCheckBox = QtWidgets.QCheckBox()
potatoCheckBox.checkState()
But I am not sure how to get about it over a list. of course the code is
not making any sense as you can't add two strings like that together to
assign a variable - big mess, However I think it kinda shows how I would
like to go about it. Using my list as a prefix for a lot of new attributes
on my UI class.
list = ['potato', 'tomato', 'poop']
obj + CheckBox = QtWidgets.QCheckBox()
potatoCheckBox.checkState()
tomatoCheckBox.checkState()
poopCheckBox.checkState()
Any pointers in the right direction would be much appreciated. Thank you.
Jake
--
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/CAEKd6bbuUefk%2Bt8rmVT4wt8CVhu6ZBmx6N6pTKQOE%3DOeg1LH1w%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAEKd6bbuUefk%2Bt8rmVT4wt8CVhu6ZBmx6N6pTKQOE%3DOeg1LH1w%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/CAFRtmODgaZ3gajU7BzQ-Q%3DhVKqS8m_LV7e%2BESCJDD5HB%2B1_Uew%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODgaZ3gajU7BzQ-Q%3DhVKqS8m_LV7e%2BESCJDD5HB%2B1_Uew%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/CAPGFgA0hr_MTj6tsGphBSpSY5WjMgM3fy3LLX3LnoJTDn-4FOA%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0hr_MTj6tsGphBSpSY5WjMgM3fy3LLX3LnoJTDn-4FOA%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/CAFRtmOAX51e3T4grnT2Q_thyf8_eJzra9j2Kv4yndBTf%3DZHX3g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Jakob Kousholt
2018-11-21 00:02:36 UTC
Permalink
Thanks, Marcus. Totally did the trick!

Yeah, I wouldn't encourage you to cook that... haha!


*Jakob Kousholt - Freelance Creature Modeler and Concept Sculptor*
+1 (347) 327-1370
***@gmail.com
www.jakejk.com
Post by Marcus Ottosson
I think it's referred to as a "Wellington Stew"
Post by Justin Israel
From what part of the world does this cuisine originate?
Post by Marcus Ottosson
How about something like this?
list = ['potato', 'tomato', 'poop']
boxes = {}
boxes[obj] = QtWidgets.QCheckBox()
boxes["potato"].checkState()
boxes["tomato"].checkState()
boxes["poop"].checkState()
Post by Jakob Kousholt
Hi,
I am trying to add a bunch of buttons and UI elements based of a python
list. My issue is that I would need to refer to them later to see if they
are checked or unchecked. Usually I would assign the button to a variable
potatoCheckBox = QtWidgets.QCheckBox()
potatoCheckBox.checkState()
But I am not sure how to get about it over a list. of course the code
is not making any sense as you can't add two strings like that together to
assign a variable - big mess, However I think it kinda shows how I would
like to go about it. Using my list as a prefix for a lot of new attributes
on my UI class.
list = ['potato', 'tomato', 'poop']
obj + CheckBox = QtWidgets.QCheckBox()
potatoCheckBox.checkState()
tomatoCheckBox.checkState()
poopCheckBox.checkState()
Any pointers in the right direction would be much appreciated. Thank you.
Jake
--
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/CAEKd6bbuUefk%2Bt8rmVT4wt8CVhu6ZBmx6N6pTKQOE%3DOeg1LH1w%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAEKd6bbuUefk%2Bt8rmVT4wt8CVhu6ZBmx6N6pTKQOE%3DOeg1LH1w%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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODgaZ3gajU7BzQ-Q%3DhVKqS8m_LV7e%2BESCJDD5HB%2B1_Uew%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODgaZ3gajU7BzQ-Q%3DhVKqS8m_LV7e%2BESCJDD5HB%2B1_Uew%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/CAPGFgA0hr_MTj6tsGphBSpSY5WjMgM3fy3LLX3LnoJTDn-4FOA%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0hr_MTj6tsGphBSpSY5WjMgM3fy3LLX3LnoJTDn-4FOA%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/CAFRtmOAX51e3T4grnT2Q_thyf8_eJzra9j2Kv4yndBTf%3DZHX3g%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAX51e3T4grnT2Q_thyf8_eJzra9j2Kv4yndBTf%3DZHX3g%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/CAEKd6bb6cjyF%3DQh0RDLbUVTHSq_sSBTg1dOnONpNt_MRwPpR%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...