from test.test_support import requires, run_unittest
from test_ttk.support import tcl_version, requires_tcl, widget_eq
-from widget_tests import (add_standard_options, noconv, noconv_meth, int_round,
+from widget_tests import (
+ add_standard_options, noconv, noconv_meth, int_round, pixels_round,
AbstractWidgetTest, StandardOptionsTests,
IntegerSizeTests, PixelSizeTests)
'takefocus', 'text', 'textvariable',
'underline', 'width', 'wraplength',
)
- _conv_pixels = staticmethod(AbstractWidgetTest._conv_pixels)
+ _conv_pixels = staticmethod(pixels_round)
def _create(self, **kwargs):
return Tkinter.Menubutton(self.root, **kwargs)
if tcl_version[:2] == (8, 5):
# Issue #19085: Workaround a bug in Tk
# http://core.tcl.tk/tk/info/3497848
- root = setup_master()
- patchlevel = root.call('info', 'patchlevel')
- patchlevel = tuple(map(int, patchlevel.split('.')))
- if patchlevel < (8, 5, 12):
- pixels_round = int
- del root
+ _pixels_round = None
+ def pixels_round(x):
+ global _pixels_round
+ if _pixels_round is None:
+ root = setup_master()
+ patchlevel = root.call('info', 'patchlevel')
+ patchlevel = tuple(map(int, patchlevel.split('.')))
+ if patchlevel < (8, 5, 12):
+ _pixels_round = int
+ else:
+ _pixels_round = int_round
+ return _pixels_round(x)
_sentinel = object()