mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Issue #23880: Tkinter's getint() and getdouble() now support Tcl_Obj.
Tkinter's getdouble() now supports any numbers (in particular int).
This commit is contained in:
parent
008d88b462
commit
645058d11a
9 changed files with 115 additions and 84 deletions
|
@ -122,10 +122,10 @@ class TestIntVar(TestBase):
|
|||
def test_invalid_value(self):
|
||||
v = IntVar(self.root, name="name")
|
||||
self.root.globalsetvar("name", "value")
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises((ValueError, TclError)):
|
||||
v.get()
|
||||
self.root.globalsetvar("name", "345.0")
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises((ValueError, TclError)):
|
||||
v.get()
|
||||
|
||||
|
||||
|
@ -152,7 +152,7 @@ class TestDoubleVar(TestBase):
|
|||
def test_invalid_value(self):
|
||||
v = DoubleVar(self.root, name="name")
|
||||
self.root.globalsetvar("name", "value")
|
||||
with self.assertRaises(ValueError):
|
||||
with self.assertRaises((ValueError, TclError)):
|
||||
v.get()
|
||||
|
||||
|
||||
|
|
|
@ -70,17 +70,15 @@ class LabeledScaleTest(AbstractTkTest, unittest.TestCase):
|
|||
# variable initialization/passing
|
||||
passed_expected = (('0', 0), (0, 0), (10, 10),
|
||||
(-1, -1), (sys.maxsize + 1, sys.maxsize + 1))
|
||||
if self.wantobjects:
|
||||
passed_expected += ((2.5, 2),)
|
||||
for pair in passed_expected:
|
||||
x = ttk.LabeledScale(self.root, from_=pair[0])
|
||||
self.assertEqual(x.value, pair[1])
|
||||
x.destroy()
|
||||
x = ttk.LabeledScale(self.root, from_='2.5')
|
||||
self.assertRaises(ValueError, x._variable.get)
|
||||
self.assertRaises((ValueError, tkinter.TclError), x._variable.get)
|
||||
x.destroy()
|
||||
x = ttk.LabeledScale(self.root, from_=None)
|
||||
self.assertRaises(ValueError, x._variable.get)
|
||||
self.assertRaises((ValueError, tkinter.TclError), x._variable.get)
|
||||
x.destroy()
|
||||
# variable should have its default value set to the from_ value
|
||||
myvar = tkinter.DoubleVar(self.root, value=20)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue