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
d97c01ff
Commit
d97c01ff
authored
Dec 26, 2013
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #20067: Tkinter variables now work when wantobjects is false.
parent
e80e806b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
9 deletions
+14
-9
Lib/tkinter/__init__.py
Lib/tkinter/__init__.py
+3
-3
Lib/tkinter/test/test_tkinter/test_variables.py
Lib/tkinter/test/test_tkinter/test_variables.py
+9
-6
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/tkinter/__init__.py
View file @
d97c01ff
...
...
@@ -220,12 +220,12 @@ class Variable:
_varnum += 1
if value is not None:
self.initialize(value)
elif not self._tk.
call("
info
", "
exists
", self._name
):
elif not self._tk.
getboolean(self._tk.call("
info
", "
exists
", self._name)
):
self.initialize(self._default)
def __del__(self):
"""Unset the variable in Tcl."""
if (self._tk is not None and
self._tk.call("
info
", "
exists
",
self._name
)):
if (self._tk is not None and
self._tk.getboolean(self._tk.call("
info
", "
exists
", self._name)
)):
self._tk.globalunsetvar(self._name)
def __str__(self):
"""Return the name of the variable in Tcl."""
...
...
Lib/tkinter/test/test_tkinter/test_variables.py
View file @
d97c01ff
...
...
@@ -24,6 +24,9 @@ class TestBase(unittest.TestCase):
class
TestVariable
(
TestBase
):
def
info_exists
(
self
,
*
args
):
return
self
.
root
.
getboolean
(
self
.
root
.
call
(
"info"
,
"exists"
,
*
args
))
def
test_default
(
self
):
v
=
Variable
(
self
.
root
)
self
.
assertEqual
(
""
,
v
.
get
())
...
...
@@ -35,21 +38,21 @@ class TestVariable(TestBase):
self.assertEqual("
varname
", str(v))
def test___del__(self):
self.assertFalse(self.
root.call("
info
", "
exists
",
"
varname
"))
self.assertFalse(self.
info_exists(
"
varname
"))
v = Variable(self.root, "
sample
string
", "
varname
")
self.assertTrue(self.
root.call("
info
", "
exists
",
"
varname
"))
self.assertTrue(self.
info_exists(
"
varname
"))
del v
self.assertFalse(self.
root.call("
info
", "
exists
",
"
varname
"))
self.assertFalse(self.
info_exists(
"
varname
"))
def test_dont_unset_not_existing(self):
self.assertFalse(self.
root.call("
info
", "
exists
",
"
varname
"))
self.assertFalse(self.
info_exists(
"
varname
"))
v1 = Variable(self.root, name="
name
")
v2 = Variable(self.root, name="
name
")
del v1
self.assertFalse(self.
root.call("
info
", "
exists
",
"
name
"))
self.assertFalse(self.
info_exists(
"
name
"))
# shouldn't raise exception
del v2
self.assertFalse(self.
root.call("
info
", "
exists
",
"
name
"))
self.assertFalse(self.
info_exists(
"
name
"))
def test___eq__(self):
# values doesn't matter, only class and name are checked
...
...
Misc/NEWS
View file @
d97c01ff
...
...
@@ -29,6 +29,8 @@ Core and Builtins
Library
-------
- Issue #20067: Tkinter variables now work when wantobjects is false.
- Issue #19020: Tkinter now uses splitlist() instead of split() in configure
methods.
...
...
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