Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a568e527
Commit
a568e527
authored
Jul 31, 2017
by
csabella
Committed by
Serhiy Storchaka
Jul 31, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-25684: ttk.OptionMenu radiobuttons weren't unique (#2276)
between instances of OptionMenu.
parent
e8eb17b2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
1 deletion
+29
-1
Lib/tkinter/test/test_ttk/test_extensions.py
Lib/tkinter/test/test_ttk/test_extensions.py
+25
-0
Lib/tkinter/ttk.py
Lib/tkinter/ttk.py
+2
-1
Misc/NEWS.d/next/Library/2017-07-17-11-35-00.bpo-25684.usELVx.rst
...S.d/next/Library/2017-07-17-11-35-00.bpo-25684.usELVx.rst
+2
-0
No files found.
Lib/tkinter/test/test_ttk/test_extensions.py
View file @
a568e527
...
...
@@ -291,6 +291,31 @@ class OptionMenuTest(AbstractTkTest, unittest.TestCase):
optmenu
.
destroy
()
def
test_unique_radiobuttons
(
self
):
# check that radiobuttons are unique across instances (bpo25684)
items
=
(
'a'
,
'b'
,
'c'
)
default
=
'a'
optmenu
=
ttk
.
OptionMenu
(
self
.
root
,
self
.
textvar
,
default
,
*
items
)
textvar2
=
tkinter
.
StringVar
(
self
.
root
)
optmenu2
=
ttk
.
OptionMenu
(
self
.
root
,
textvar2
,
default
,
*
items
)
optmenu
.
pack
()
optmenu
.
wait_visibility
()
optmenu2
.
pack
()
optmenu2
.
wait_visibility
()
optmenu
[
'menu'
].
invoke
(
1
)
optmenu2
[
'menu'
].
invoke
(
2
)
optmenu_stringvar_name
=
optmenu
[
'menu'
].
entrycget
(
0
,
'variable'
)
optmenu2_stringvar_name
=
optmenu2
[
'menu'
].
entrycget
(
0
,
'variable'
)
self
.
assertNotEqual
(
optmenu_stringvar_name
,
optmenu2_stringvar_name
)
self
.
assertEqual
(
self
.
root
.
tk
.
globalgetvar
(
optmenu_stringvar_name
),
items
[
1
])
self
.
assertEqual
(
self
.
root
.
tk
.
globalgetvar
(
optmenu2_stringvar_name
),
items
[
2
])
optmenu
.
destroy
()
optmenu2
.
destroy
()
tests_gui
=
(
LabeledScaleTest
,
OptionMenuTest
)
...
...
Lib/tkinter/ttk.py
View file @
a568e527
...
...
@@ -1635,7 +1635,8 @@ class OptionMenu(Menubutton):
menu
.
delete
(
0
,
'end'
)
for
val
in
values
:
menu
.
add_radiobutton
(
label
=
val
,
command
=
tkinter
.
_setit
(
self
.
_variable
,
val
,
self
.
_callback
))
command
=
tkinter
.
_setit
(
self
.
_variable
,
val
,
self
.
_callback
),
variable
=
self
.
_variable
)
if
default
:
self
.
_variable
.
set
(
default
)
...
...
Misc/NEWS.d/next/Library/2017-07-17-11-35-00.bpo-25684.usELVx.rst
0 → 100644
View file @
a568e527
Change ``ttk.OptionMenu`` radiobuttons to be unique across instances of
``OptionMenu``.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment