Discussion:
[Maya-Python] PyQt - Radio button selection
yann19
2018-07-17 17:07:51 UTC
Permalink
Hi all,

I apologize in advance that my code isn't directly related to maya.
I have created 4 radio buttons, where 2 of each buttons are created and
sorted into 2 different layouts.
Only 1 radio button will be checked in each layout.

My code is as follows:

time_first_hbox = QtGui.QHBoxLayout()
start_rbtn = QtGui.QRadioButton("Start")
min_rbtn = QtGui.QRadioButton("Min")
min_rbtn.setChecked(True)
time_first_hbox.addWidget(start_rbtn)
time_first_hbox.addWidget(min_rbtn)

time_last_hbox = QtGui.QHBoxLayout()
end_rbtn = QtGui.QRadioButton("End")
max_rbtn = QtGui.QRadioButton("Max")
max_rbtn.setChecked(True)
time_last_hbox.addWidget(end_rbtn)
time_last_hbox.addWidget(max_rbtn)

options_time_hbox = QtGui.QHBoxLayout()
options_time_hbox.addLayout(time_first_hbox)
options_time_hbox.addLayout(time_last_hbox)


While both the `Min` and `Max` buttons are set to checked as default, when
I tried to select `End` button, instead of the default `Max` selection
moved to `End`, it was `Min` that was moved.
As a result, the (user) selection is only limited to `Start/ Min/ End`
while `Max` will always be checked..

I had thought that if I had created 2 different layouts, the radio buttons
selection will be limited to those within the layout (Start/Min) and
(End/Max).
Am I missing something here?
--
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/3ae4a510-45c3-4da6-8e40-06cc35ce930b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
yann19
2018-07-17 17:13:14 UTC
Permalink
I would also like to add on that (unable to edit the post), if I clicked on
the option - "Max", it will gets unchecked, and only 1 radio button
selection can only be made thereafter..
--
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/ed1782d9-0dc5-4dbb-9d31-45d6ad48872f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Marcus Ottosson
2018-07-17 17:20:58 UTC
Permalink
See http://doc.qt.io/qt-5/qradiobutton.html#details

Radio buttons are autoExclusive by default. If auto-exclusive is enabled,
radio buttons that belong to the same parent widget behave as if they were
part of the same exclusive button group. If you need multiple exclusive
button groups for radio buttons that belong to the same parent widget, put
them into a QButtonGroup.

Looks like you’ll need two “groups”.
​
Post by yann19
I would also like to add on that (unable to edit the post), if I clicked
on the option - "Max", it will gets unchecked, and only 1 radio button
selection can only be made thereafter..
--
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/ed1782d9-0dc5-4dbb-9d31-
45d6ad48872f%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/ed1782d9-0dc5-4dbb-9d31-45d6ad48872f%40googlegroups.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/CAFRtmOAko-BNoeuKBoNPcDKedhb93A1C6XOoy9H2tYv3SZ8C8w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Marcus Ottosson
2018-07-17 17:21:38 UTC
Permalink
Alternatively, instead of two layouts, parent them to two widgets, each
with their own layout, and put the two widgets in a third layout.
Post by Marcus Ottosson
See http://doc.qt.io/qt-5/qradiobutton.html#details
Radio buttons are autoExclusive by default. If auto-exclusive is enabled,
radio buttons that belong to the same parent widget behave as if they were
part of the same exclusive button group. If you need multiple exclusive
button groups for radio buttons that belong to the same parent widget, put
them into a QButtonGroup.
Looks like you’ll need two “groups”.
​
Post by yann19
I would also like to add on that (unable to edit the post), if I clicked
on the option - "Max", it will gets unchecked, and only 1 radio button
selection can only be made thereafter..
--
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/ms
gid/python_inside_maya/ed1782d9-0dc5-4dbb-9d31-45d6ad48872f%
40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/ed1782d9-0dc5-4dbb-9d31-45d6ad48872f%40googlegroups.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/CAFRtmODzwGdymXZVfKeOdu0o0cLvmRTGGS7NvSvrQF%2BYF3rfTg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Justin Israel
2018-07-17 19:50:01 UTC
Permalink
Post by Marcus Ottosson
Alternatively, instead of two layouts, parent them to two widgets, each
with their own layout, and put the two widgets in a third layout.
I like your suggestion of using QButtonGroup as opposed to managing it by
layout and parent. A group is more explicit about the logic and is the way
I always go.
Post by Marcus Ottosson
Post by Marcus Ottosson
See http://doc.qt.io/qt-5/qradiobutton.html#details
Radio buttons are autoExclusive by default. If auto-exclusive is enabled,
radio buttons that belong to the same parent widget behave as if they were
part of the same exclusive button group. If you need multiple exclusive
button groups for radio buttons that belong to the same parent widget, put
them into a QButtonGroup.
Looks like you’ll need two “groups”.
​
Post by yann19
I would also like to add on that (unable to edit the post), if I clicked
on the option - "Max", it will gets unchecked, and only 1 radio button
selection can only be made thereafter..
--
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/ed1782d9-0dc5-4dbb-9d31-45d6ad48872f%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/ed1782d9-0dc5-4dbb-9d31-45d6ad48872f%40googlegroups.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/CAFRtmODzwGdymXZVfKeOdu0o0cLvmRTGGS7NvSvrQF%2BYF3rfTg%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODzwGdymXZVfKeOdu0o0cLvmRTGGS7NvSvrQF%2BYF3rfTg%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/CAPGFgA2VGOE9WcQUoS26ypv8EzqgF6yVqVcbpsypFiqTk3A80w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
yann19
2018-07-19 21:50:40 UTC
Permalink
Got it, thanks guys!
Post by Justin Israel
Post by Marcus Ottosson
Alternatively, instead of two layouts, parent them to two widgets, each
with their own layout, and put the two widgets in a third layout.
I like your suggestion of using QButtonGroup as opposed to managing it by
layout and parent. A group is more explicit about the logic and is the way
I always go.
Post by Marcus Ottosson
Post by Marcus Ottosson
See http://doc.qt.io/qt-5/qradiobutton.html#details
Radio buttons are autoExclusive by default. If auto-exclusive is
enabled, radio buttons that belong to the same parent widget behave as if
they were part of the same exclusive button group. If you need multiple
exclusive button groups for radio buttons that belong to the same parent
widget, put them into a QButtonGroup.
Looks like you’ll need two “groups”.
​
Post by yann19
I would also like to add on that (unable to edit the post), if I
clicked on the option - "Max", it will gets unchecked, and only 1 radio
button selection can only be made thereafter..
--
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
<javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/ed1782d9-0dc5-4dbb-9d31-45d6ad48872f%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/ed1782d9-0dc5-4dbb-9d31-45d6ad48872f%40googlegroups.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/CAFRtmODzwGdymXZVfKeOdu0o0cLvmRTGGS7NvSvrQF%2BYF3rfTg%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODzwGdymXZVfKeOdu0o0cLvmRTGGS7NvSvrQF%2BYF3rfTg%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/fd2c0287-bdb5-4663-b554-c66dde2820a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...