mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	bpo-45160: Ttk optionmenu only set variable once (GH-28291) (GH-29132)
(cherry picked from commit add46f8476)
Co-authored-by: E-Paine <63801254+E-Paine@users.noreply.github.com>
			
			
This commit is contained in:
		
							parent
							
								
									e628700dbf
								
							
						
					
					
						commit
						04485ac988
					
				
					 3 changed files with 18 additions and 1 deletions
				
			
		|  | @ -301,6 +301,19 @@ def test_unique_radiobuttons(self): | |||
|         optmenu.destroy() | ||||
|         optmenu2.destroy() | ||||
| 
 | ||||
|     def test_trace_variable(self): | ||||
|         # prior to bpo45160, tracing a variable would cause the callback to be made twice | ||||
|         success = [] | ||||
|         items = ('a', 'b', 'c') | ||||
|         textvar = tkinter.StringVar(self.root) | ||||
|         def cb_test(*args): | ||||
|             self.assertEqual(textvar.get(), items[1]) | ||||
|             success.append(True) | ||||
|         optmenu = ttk.OptionMenu(self.root, textvar, "a", *items) | ||||
|         textvar.trace("w", cb_test) | ||||
|         optmenu['menu'].invoke(1) | ||||
|         self.assertEqual(success, [True]) | ||||
| 
 | ||||
| 
 | ||||
| class DefaultRootTest(AbstractDefaultRootTest, unittest.TestCase): | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Miss Islington (bot)
						Miss Islington (bot)