(self)
| 886 | self.assertRaises(tkinter.TclError, self.scale.get, 0, '') |
| 887 | |
| 888 | def test_set(self): |
| 889 | if self.wantobjects: |
| 890 | conv = lambda x: x |
| 891 | else: |
| 892 | conv = float |
| 893 | |
| 894 | # set restricts the max/min values according to the current range |
| 895 | max = conv(self.scale['to']) |
| 896 | new_max = max + 10 |
| 897 | self.scale.set(new_max) |
| 898 | self.assertEqual(conv(self.scale.get()), max) |
| 899 | min = conv(self.scale['from']) |
| 900 | self.scale.set(min - 1) |
| 901 | self.assertEqual(conv(self.scale.get()), min) |
| 902 | |
| 903 | # changing directly the variable doesn't impose this limitation tho |
| 904 | var = tkinter.DoubleVar(self.root) |
| 905 | self.scale['variable'] = var |
| 906 | var.set(max + 5) |
| 907 | self.assertEqual(conv(self.scale.get()), var.get()) |
| 908 | self.assertEqual(conv(self.scale.get()), max + 5) |
| 909 | del var |
| 910 | gc_collect() # For PyPy or other GCs. |
| 911 | |
| 912 | # the same happens with the value option |
| 913 | self.scale['value'] = max + 10 |
| 914 | self.assertEqual(conv(self.scale.get()), max + 10) |
| 915 | self.assertEqual(conv(self.scale.get()), conv(self.scale['value'])) |
| 916 | |
| 917 | # nevertheless, note that the max/min values we can get specifying |
| 918 | # x, y coords are the ones according to the current range |
| 919 | self.assertEqual(conv(self.scale.get(0, 0)), min) |
| 920 | self.assertEqual(conv(self.scale.get(self.scale.winfo_width(), 0)), max) |
| 921 | |
| 922 | self.assertRaises(tkinter.TclError, self.scale.set, None) |
| 923 | |
| 924 | |
| 925 | @add_configure_tests(StandardTtkOptionsTests) |
nothing calls this directly
no test coverage detected