mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	Issue #19085: Fix running test_ttk_textonly on displayless host.
This commit is contained in:
		
							parent
							
								
									8d8599ce0c
								
							
						
					
					
						commit
						2028e01313
					
				
					 2 changed files with 16 additions and 9 deletions
				
			
		|  | @ -4,7 +4,8 @@ | |||
| from test.support import requires | ||||
| 
 | ||||
| from tkinter.test.support import tcl_version, requires_tcl, widget_eq | ||||
| from tkinter.test.widget_tests import (add_standard_options, noconv, | ||||
| from tkinter.test.widget_tests import ( | ||||
|     add_standard_options, noconv, pixels_round, | ||||
|     AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests) | ||||
| 
 | ||||
| requires('gui') | ||||
|  | @ -243,7 +244,7 @@ class MenubuttonTest(AbstractLabelTest, unittest.TestCase): | |||
|         'takefocus', 'text', 'textvariable', | ||||
|         'underline', 'width', 'wraplength', | ||||
|     ) | ||||
|     _conv_pixels = AbstractWidgetTest._conv_pixels | ||||
|     _conv_pixels = staticmethod(pixels_round) | ||||
| 
 | ||||
|     def _create(self, **kwargs): | ||||
|         return tkinter.Menubutton(self.root, **kwargs) | ||||
|  |  | |||
|  | @ -12,18 +12,24 @@ | |||
| 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() | ||||
| 
 | ||||
| class AbstractWidgetTest: | ||||
|     _conv_pixels = pixels_round | ||||
|     _conv_pixels = staticmethod(pixels_round) | ||||
|     _conv_pad_pixels = None | ||||
|     wantobjects = True | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Serhiy Storchaka
						Serhiy Storchaka