mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	bpo-40468: Move IDLE helplist settings to extensions page of dialog. (GH-26593)
These are the settings that extend the help menu.  Moving them shortens the dialog and will help with it being too tall for small screens.
(cherry picked from commit ab36b9f834)
			
			
This commit is contained in:
		
							parent
							
								
									87f502231c
								
							
						
					
					
						commit
						c03f0ab259
					
				
					 3 changed files with 189 additions and 138 deletions
				
			
		|  | @ -1207,24 +1207,14 @@ class GenPageTest(unittest.TestCase): | |||
|     """Test that general tab widgets enable users to make changes. | ||||
| 
 | ||||
|     Test that widget actions set vars, that var changes add | ||||
|     options to changes and that helplist works correctly. | ||||
|     options to changes. | ||||
|     """ | ||||
|     @classmethod | ||||
|     def setUpClass(cls): | ||||
|         page = cls.page = dialog.genpage | ||||
|         dialog.note.select(page) | ||||
|         page.set = page.set_add_delete_state = Func() | ||||
|         page.upc = page.update_help_changes = Func() | ||||
|         page.update() | ||||
| 
 | ||||
|     @classmethod | ||||
|     def tearDownClass(cls): | ||||
|         page = cls.page | ||||
|         del page.set, page.set_add_delete_state | ||||
|         del page.upc, page.update_help_changes | ||||
|         page.helplist.delete(0, 'end') | ||||
|         page.user_helplist.clear() | ||||
| 
 | ||||
|     def setUp(self): | ||||
|         changes.clear() | ||||
| 
 | ||||
|  | @ -1236,16 +1226,11 @@ def test_load_general_cfg(self): | |||
|         d.autosave.set(1) | ||||
|         d.win_width.set(1) | ||||
|         d.win_height.set(1) | ||||
|         d.helplist.insert('end', 'bad') | ||||
|         d.user_helplist = ['bad', 'worse'] | ||||
|         idleConf.SetOption('main', 'HelpFiles', '1', 'name;file') | ||||
|         d.load_general_cfg() | ||||
|         eq(d.startup_edit.get(), 0) | ||||
|         eq(d.autosave.get(), 0) | ||||
|         eq(d.win_width.get(), '80') | ||||
|         eq(d.win_height.get(), '40') | ||||
|         eq(d.helplist.get(0, 'end'), ('name',)) | ||||
|         eq(d.user_helplist, [('name', 'file', '1')]) | ||||
| 
 | ||||
|     def test_startup(self): | ||||
|         d = self.page | ||||
|  | @ -1306,11 +1291,43 @@ def test_context(self): | |||
|         self.page.context_int.insert(0, '1') | ||||
|         self.assertEqual(extpage, {'CodeContext': {'maxlines': '1'}}) | ||||
| 
 | ||||
| 
 | ||||
| class HelpSourceTest(unittest.TestCase): | ||||
|     """Test that the help source list works correctly.""" | ||||
|     @classmethod | ||||
|     def setUpClass(cls): | ||||
|         dialog.note.select(dialog.extpage) | ||||
|         frame = cls.frame = dialog.frame_help | ||||
|         frame.set = frame.set_add_delete_state = Func() | ||||
|         frame.upc = frame.update_help_changes = Func() | ||||
|         frame.update() | ||||
| 
 | ||||
|     @classmethod | ||||
|     def tearDownClass(cls): | ||||
|         frame = cls.frame | ||||
|         del frame.set, frame.set_add_delete_state | ||||
|         del frame.upc, frame.update_help_changes | ||||
|         frame.helplist.delete(0, 'end') | ||||
|         frame.user_helplist.clear() | ||||
| 
 | ||||
|     def setUp(self): | ||||
|         changes.clear() | ||||
| 
 | ||||
|     def test_load_helplist(self): | ||||
|         eq = self.assertEqual | ||||
|         fr = self.frame | ||||
|         fr.helplist.insert('end', 'bad') | ||||
|         fr.user_helplist = ['bad', 'worse'] | ||||
|         idleConf.SetOption('main', 'HelpFiles', '1', 'name;file') | ||||
|         fr.load_helplist() | ||||
|         eq(fr.helplist.get(0, 'end'), ('name',)) | ||||
|         eq(fr.user_helplist, [('name', 'file', '1')]) | ||||
| 
 | ||||
|     def test_source_selected(self): | ||||
|         d = self.page | ||||
|         d.set = d.set_add_delete_state | ||||
|         d.upc = d.update_help_changes | ||||
|         helplist = d.helplist | ||||
|         fr = self.frame | ||||
|         fr.set = fr.set_add_delete_state | ||||
|         fr.upc = fr.update_help_changes | ||||
|         helplist = fr.helplist | ||||
|         dex = 'end' | ||||
|         helplist.insert(dex, 'source') | ||||
|         helplist.activate(dex) | ||||
|  | @ -1321,38 +1338,38 @@ def test_source_selected(self): | |||
|         x, y, dx, dy = helplist.bbox(dex) | ||||
|         x += dx // 2 | ||||
|         y += dy // 2 | ||||
|         d.set.called = d.upc.called = 0 | ||||
|         fr.set.called = fr.upc.called = 0 | ||||
|         helplist.event_generate('<Enter>', x=0, y=0) | ||||
|         helplist.event_generate('<Motion>', x=x, y=y) | ||||
|         helplist.event_generate('<Button-1>', x=x, y=y) | ||||
|         helplist.event_generate('<ButtonRelease-1>', x=x, y=y) | ||||
|         self.assertEqual(helplist.get('anchor'), 'source') | ||||
|         self.assertTrue(d.set.called) | ||||
|         self.assertFalse(d.upc.called) | ||||
|         self.assertTrue(fr.set.called) | ||||
|         self.assertFalse(fr.upc.called) | ||||
| 
 | ||||
|     def test_set_add_delete_state(self): | ||||
|         # Call with 0 items, 1 unselected item, 1 selected item. | ||||
|         eq = self.assertEqual | ||||
|         d = self.page | ||||
|         del d.set_add_delete_state  # Unmask method. | ||||
|         sad = d.set_add_delete_state | ||||
|         h = d.helplist | ||||
|         fr = self.frame | ||||
|         del fr.set_add_delete_state  # Unmask method. | ||||
|         sad = fr.set_add_delete_state | ||||
|         h = fr.helplist | ||||
| 
 | ||||
|         h.delete(0, 'end') | ||||
|         sad() | ||||
|         eq(d.button_helplist_edit.state(), ('disabled',)) | ||||
|         eq(d.button_helplist_remove.state(), ('disabled',)) | ||||
|         eq(fr.button_helplist_edit.state(), ('disabled',)) | ||||
|         eq(fr.button_helplist_remove.state(), ('disabled',)) | ||||
| 
 | ||||
|         h.insert(0, 'source') | ||||
|         sad() | ||||
|         eq(d.button_helplist_edit.state(), ('disabled',)) | ||||
|         eq(d.button_helplist_remove.state(), ('disabled',)) | ||||
|         eq(fr.button_helplist_edit.state(), ('disabled',)) | ||||
|         eq(fr.button_helplist_remove.state(), ('disabled',)) | ||||
| 
 | ||||
|         h.selection_set(0) | ||||
|         sad() | ||||
|         eq(d.button_helplist_edit.state(), ()) | ||||
|         eq(d.button_helplist_remove.state(), ()) | ||||
|         d.set_add_delete_state = Func()  # Mask method. | ||||
|         eq(fr.button_helplist_edit.state(), ()) | ||||
|         eq(fr.button_helplist_remove.state(), ()) | ||||
|         fr.set_add_delete_state = Func()  # Mask method. | ||||
| 
 | ||||
|     def test_helplist_item_add(self): | ||||
|         # Call without and twice with HelpSource result. | ||||
|  | @ -1360,25 +1377,25 @@ def test_helplist_item_add(self): | |||
|         eq = self.assertEqual | ||||
|         orig_helpsource = configdialog.HelpSource | ||||
|         hs = configdialog.HelpSource = Func(return_self=True) | ||||
|         d = self.page | ||||
|         d.helplist.delete(0, 'end') | ||||
|         d.user_helplist.clear() | ||||
|         d.set.called = d.upc.called = 0 | ||||
|         fr = self.frame | ||||
|         fr.helplist.delete(0, 'end') | ||||
|         fr.user_helplist.clear() | ||||
|         fr.set.called = fr.upc.called = 0 | ||||
| 
 | ||||
|         hs.result = '' | ||||
|         d.helplist_item_add() | ||||
|         self.assertTrue(list(d.helplist.get(0, 'end')) == | ||||
|                         d.user_helplist == []) | ||||
|         self.assertFalse(d.upc.called) | ||||
|         fr.helplist_item_add() | ||||
|         self.assertTrue(list(fr.helplist.get(0, 'end')) == | ||||
|                         fr.user_helplist == []) | ||||
|         self.assertFalse(fr.upc.called) | ||||
| 
 | ||||
|         hs.result = ('name1', 'file1') | ||||
|         d.helplist_item_add() | ||||
|         fr.helplist_item_add() | ||||
|         hs.result = ('name2', 'file2') | ||||
|         d.helplist_item_add() | ||||
|         eq(d.helplist.get(0, 'end'), ('name1', 'name2')) | ||||
|         eq(d.user_helplist, [('name1', 'file1'), ('name2', 'file2')]) | ||||
|         eq(d.upc.called, 2) | ||||
|         self.assertFalse(d.set.called) | ||||
|         fr.helplist_item_add() | ||||
|         eq(fr.helplist.get(0, 'end'), ('name1', 'name2')) | ||||
|         eq(fr.user_helplist, [('name1', 'file1'), ('name2', 'file2')]) | ||||
|         eq(fr.upc.called, 2) | ||||
|         self.assertFalse(fr.set.called) | ||||
| 
 | ||||
|         configdialog.HelpSource = orig_helpsource | ||||
| 
 | ||||
|  | @ -1387,58 +1404,58 @@ def test_helplist_item_edit(self): | |||
|         eq = self.assertEqual | ||||
|         orig_helpsource = configdialog.HelpSource | ||||
|         hs = configdialog.HelpSource = Func(return_self=True) | ||||
|         d = self.page | ||||
|         d.helplist.delete(0, 'end') | ||||
|         d.helplist.insert(0, 'name1') | ||||
|         d.helplist.selection_set(0) | ||||
|         d.helplist.selection_anchor(0) | ||||
|         d.user_helplist.clear() | ||||
|         d.user_helplist.append(('name1', 'file1')) | ||||
|         d.set.called = d.upc.called = 0 | ||||
|         fr = self.frame | ||||
|         fr.helplist.delete(0, 'end') | ||||
|         fr.helplist.insert(0, 'name1') | ||||
|         fr.helplist.selection_set(0) | ||||
|         fr.helplist.selection_anchor(0) | ||||
|         fr.user_helplist.clear() | ||||
|         fr.user_helplist.append(('name1', 'file1')) | ||||
|         fr.set.called = fr.upc.called = 0 | ||||
| 
 | ||||
|         hs.result = '' | ||||
|         d.helplist_item_edit() | ||||
|         fr.helplist_item_edit() | ||||
|         hs.result = ('name1', 'file1') | ||||
|         d.helplist_item_edit() | ||||
|         eq(d.helplist.get(0, 'end'), ('name1',)) | ||||
|         eq(d.user_helplist, [('name1', 'file1')]) | ||||
|         self.assertFalse(d.upc.called) | ||||
|         fr.helplist_item_edit() | ||||
|         eq(fr.helplist.get(0, 'end'), ('name1',)) | ||||
|         eq(fr.user_helplist, [('name1', 'file1')]) | ||||
|         self.assertFalse(fr.upc.called) | ||||
| 
 | ||||
|         hs.result = ('name2', 'file2') | ||||
|         d.helplist_item_edit() | ||||
|         eq(d.helplist.get(0, 'end'), ('name2',)) | ||||
|         eq(d.user_helplist, [('name2', 'file2')]) | ||||
|         self.assertTrue(d.upc.called == d.set.called == 1) | ||||
|         fr.helplist_item_edit() | ||||
|         eq(fr.helplist.get(0, 'end'), ('name2',)) | ||||
|         eq(fr.user_helplist, [('name2', 'file2')]) | ||||
|         self.assertTrue(fr.upc.called == fr.set.called == 1) | ||||
| 
 | ||||
|         configdialog.HelpSource = orig_helpsource | ||||
| 
 | ||||
|     def test_helplist_item_remove(self): | ||||
|         eq = self.assertEqual | ||||
|         d = self.page | ||||
|         d.helplist.delete(0, 'end') | ||||
|         d.helplist.insert(0, 'name1') | ||||
|         d.helplist.selection_set(0) | ||||
|         d.helplist.selection_anchor(0) | ||||
|         d.user_helplist.clear() | ||||
|         d.user_helplist.append(('name1', 'file1')) | ||||
|         d.set.called = d.upc.called = 0 | ||||
|         fr = self.frame | ||||
|         fr.helplist.delete(0, 'end') | ||||
|         fr.helplist.insert(0, 'name1') | ||||
|         fr.helplist.selection_set(0) | ||||
|         fr.helplist.selection_anchor(0) | ||||
|         fr.user_helplist.clear() | ||||
|         fr.user_helplist.append(('name1', 'file1')) | ||||
|         fr.set.called = fr.upc.called = 0 | ||||
| 
 | ||||
|         d.helplist_item_remove() | ||||
|         eq(d.helplist.get(0, 'end'), ()) | ||||
|         eq(d.user_helplist, []) | ||||
|         self.assertTrue(d.upc.called == d.set.called == 1) | ||||
|         fr.helplist_item_remove() | ||||
|         eq(fr.helplist.get(0, 'end'), ()) | ||||
|         eq(fr.user_helplist, []) | ||||
|         self.assertTrue(fr.upc.called == fr.set.called == 1) | ||||
| 
 | ||||
|     def test_update_help_changes(self): | ||||
|         d = self.page | ||||
|         del d.update_help_changes | ||||
|         d.user_helplist.clear() | ||||
|         d.user_helplist.append(('name1', 'file1')) | ||||
|         d.user_helplist.append(('name2', 'file2')) | ||||
|         fr = self.frame | ||||
|         del fr.update_help_changes | ||||
|         fr.user_helplist.clear() | ||||
|         fr.user_helplist.append(('name1', 'file1')) | ||||
|         fr.user_helplist.append(('name2', 'file2')) | ||||
| 
 | ||||
|         d.update_help_changes() | ||||
|         fr.update_help_changes() | ||||
|         self.assertEqual(mainpage['HelpFiles'], | ||||
|                          {'1': 'name1;file1', '2': 'name2;file2'}) | ||||
|         d.update_help_changes = Func() | ||||
|         fr.update_help_changes = Func() | ||||
| 
 | ||||
| 
 | ||||
| class VarTraceTest(unittest.TestCase): | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Miss Islington (bot)
						Miss Islington (bot)