MCPcopy Index your code
hub / github.com/python/cpython / test_traversal

Method test_traversal

Lib/test/test_ttk/test_widgets.py:1184–1225  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1182 self.assertEqual(self.nb.tabs(), ())
1183
1184 def test_traversal(self):
1185 self.nb.pack()
1186 self.nb.update()
1187
1188 self.nb.select(0)
1189
1190 if sys.platform == 'darwin':
1191 focus_identify_as = ''
1192 elif sys.platform == 'win32':
1193 focus_identify_as = 'focus'
1194 else:
1195 focus_identify_as = 'focus' if tk_version < (8, 7) else 'padding'
1196 self.assertEqual(self.nb.identify(5, 5), focus_identify_as)
1197 simulate_mouse_click(self.nb, 5, 5)
1198 self.nb.focus_force()
1199 self.nb.event_generate('<Control-Tab>')
1200 self.assertEqual(self.nb.select(), str(self.child2))
1201 self.nb.focus_force()
1202 self.nb.event_generate('<Shift-Control-Tab>')
1203 self.assertEqual(self.nb.select(), str(self.child1))
1204 self.nb.focus_force()
1205 self.nb.event_generate('<Shift-Control-Tab>')
1206 self.assertEqual(self.nb.select(), str(self.child2))
1207
1208 self.nb.tab(self.child1, text='a', underline=0)
1209 self.nb.tab(self.child2, text='e', underline=0)
1210 self.nb.enable_traversal()
1211 self.nb.focus_force()
1212 self.assertEqual(self.nb.identify(5, 5), focus_identify_as)
1213 simulate_mouse_click(self.nb, 5, 5)
1214 # on macOS Emacs-style keyboard shortcuts are region-dependent;
1215 # let's use the regular arrow keys instead
1216 if sys.platform == 'darwin':
1217 begin = '<Left>'
1218 end = '<Right>'
1219 else:
1220 begin = '<Alt-a>'
1221 end = '<Alt-e>'
1222 self.nb.event_generate(begin)
1223 self.assertEqual(self.nb.select(), str(self.child1))
1224 self.nb.event_generate(end)
1225 self.assertEqual(self.nb.select(), str(self.child2))
1226
1227
1228@add_configure_tests(IntegerSizeTests, StandardTtkOptionsTests)

Callers

nothing calls this directly

Calls 11

simulate_mouse_clickFunction · 0.90
strFunction · 0.85
event_generateMethod · 0.80
tabMethod · 0.80
enable_traversalMethod · 0.80
packMethod · 0.45
updateMethod · 0.45
selectMethod · 0.45
assertEqualMethod · 0.45
identifyMethod · 0.45
focus_forceMethod · 0.45

Tested by

no test coverage detected