(self)
| 52 | self.assertNotEqual(sys.last_type, tkinter.TclError) |
| 53 | |
| 54 | def test_initialization(self): |
| 55 | # master passing |
| 56 | master = tkinter.Frame(self.root) |
| 57 | x = ttk.LabeledScale(master) |
| 58 | self.assertEqual(x.master, master) |
| 59 | x.destroy() |
| 60 | |
| 61 | # variable initialization/passing |
| 62 | passed_expected = (('0', 0), (0, 0), (10, 10), |
| 63 | (-1, -1), (sys.maxsize + 1, sys.maxsize + 1), |
| 64 | (2.5, 2), ('2.5', 2)) |
| 65 | for pair in passed_expected: |
| 66 | x = ttk.LabeledScale(self.root, from_=pair[0]) |
| 67 | self.assertEqual(x.value, pair[1]) |
| 68 | x.destroy() |
| 69 | x = ttk.LabeledScale(self.root, from_=None) |
| 70 | self.assertRaises((ValueError, tkinter.TclError), x._variable.get) |
| 71 | x.destroy() |
| 72 | # variable should have its default value set to the from_ value |
| 73 | myvar = tkinter.DoubleVar(self.root, value=20) |
| 74 | x = ttk.LabeledScale(self.root, variable=myvar) |
| 75 | self.assertEqual(x.value, 0) |
| 76 | x.destroy() |
| 77 | # check that it is really using a DoubleVar |
| 78 | x = ttk.LabeledScale(self.root, variable=myvar, from_=0.5) |
| 79 | self.assertEqual(x.value, 0.5) |
| 80 | self.assertEqual(x._variable._name, myvar._name) |
| 81 | x.destroy() |
| 82 | |
| 83 | # widget positionment |
| 84 | def check_positions(scale, scale_pos, label, label_pos): |
| 85 | self.assertEqual(scale.pack_info()['side'], scale_pos) |
| 86 | self.assertEqual(label.place_info()['anchor'], label_pos) |
| 87 | x = ttk.LabeledScale(self.root, compound='top') |
| 88 | check_positions(x.scale, 'bottom', x.label, 'n') |
| 89 | x.destroy() |
| 90 | x = ttk.LabeledScale(self.root, compound='bottom') |
| 91 | check_positions(x.scale, 'top', x.label, 's') |
| 92 | x.destroy() |
| 93 | # invert default positions |
| 94 | x = ttk.LabeledScale(self.root, compound='unknown') |
| 95 | check_positions(x.scale, 'top', x.label, 's') |
| 96 | x.destroy() |
| 97 | x = ttk.LabeledScale(self.root) # take default positions |
| 98 | check_positions(x.scale, 'bottom', x.label, 'n') |
| 99 | x.destroy() |
| 100 | |
| 101 | # extra, and invalid, kwargs |
| 102 | self.assertRaises(tkinter.TclError, ttk.LabeledScale, master, a='b') |
| 103 | |
| 104 | |
| 105 | def test_horizontal_range(self): |
nothing calls this directly
no test coverage detected