Compare commits
3 Commits
cf22aa3bc6
...
ff51e5ec26
Author | SHA1 | Date |
---|---|---|
Miss Islington (bot) | ff51e5ec26 | |
Miss Islington (bot) | b2652f2d7e | |
Miss Islington (bot) | aab9390334 |
|
@ -1133,20 +1133,9 @@ container should match the type_ specified::
|
|||
|
||||
Any container can be passed as the *choices* value, so :class:`list` objects,
|
||||
:class:`set` objects, and custom containers are all supported.
|
||||
This includes :class:`enum.Enum`, which could be used to restrain
|
||||
argument's choices; if we reuse previous rock/paper/scissors game example,
|
||||
this could be as follows::
|
||||
|
||||
>>> from enum import Enum
|
||||
>>> class GameMove(Enum):
|
||||
... ROCK = 'rock'
|
||||
... PAPER = 'paper'
|
||||
... SCISSORS = 'scissors'
|
||||
...
|
||||
>>> parser = argparse.ArgumentParser(prog='game.py')
|
||||
>>> parser.add_argument('move', type=GameMove, choices=GameMove)
|
||||
>>> parser.parse_args(['rock'])
|
||||
Namespace(move=<GameMove.ROCK: 'rock'>)
|
||||
Use of :class:`enum.Enum` is not recommended because it is difficult to
|
||||
control its appearance in usage, help, and error messages.
|
||||
|
||||
|
||||
required
|
||||
|
|
|
@ -757,7 +757,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
|
|||
def runcode(self, code):
|
||||
"Override base class method"
|
||||
if self.tkconsole.executing:
|
||||
self.interp.restart_subprocess()
|
||||
self.restart_subprocess()
|
||||
self.checklinecache()
|
||||
debugger = self.debugger
|
||||
try:
|
||||
|
|
|
@ -435,11 +435,12 @@ class ComboboxTest(EntryTest, unittest.TestCase):
|
|||
|
||||
def _show_drop_down_listbox(self):
|
||||
width = self.combo.winfo_width()
|
||||
self.combo.event_generate('<ButtonPress-1>', x=width - 5, y=5)
|
||||
self.combo.event_generate('<ButtonRelease-1>', x=width - 5, y=5)
|
||||
x, y = width - 5, 5
|
||||
self.assertRegex(self.combo.identify(x, y), r'.*downarrow\Z')
|
||||
self.combo.event_generate('<ButtonPress-1>', x=x, y=y)
|
||||
self.combo.event_generate('<ButtonRelease-1>', x=x, y=y)
|
||||
self.combo.update_idletasks()
|
||||
|
||||
|
||||
def test_virtual_event(self):
|
||||
success = []
|
||||
|
||||
|
@ -1085,6 +1086,7 @@ class NotebookTest(AbstractWidgetTest, unittest.TestCase):
|
|||
|
||||
self.nb.select(0)
|
||||
|
||||
self.assertEqual(self.nb.identify(5, 5), 'focus')
|
||||
simulate_mouse_click(self.nb, 5, 5)
|
||||
self.nb.focus_force()
|
||||
self.nb.event_generate('<Control-Tab>')
|
||||
|
@ -1099,6 +1101,7 @@ class NotebookTest(AbstractWidgetTest, unittest.TestCase):
|
|||
self.nb.tab(self.child1, text='a', underline=0)
|
||||
self.nb.enable_traversal()
|
||||
self.nb.focus_force()
|
||||
self.assertEqual(self.nb.identify(5, 5), 'focus')
|
||||
simulate_mouse_click(self.nb, 5, 5)
|
||||
if sys.platform == 'darwin':
|
||||
self.nb.event_generate('<Option-a>')
|
||||
|
@ -1129,6 +1132,7 @@ class SpinboxTest(EntryTest, unittest.TestCase):
|
|||
height = self.spin.winfo_height()
|
||||
x = width - 5
|
||||
y = height//2 - 5
|
||||
self.assertRegex(self.spin.identify(x, y), r'.*uparrow\Z')
|
||||
self.spin.event_generate('<ButtonPress-1>', x=x, y=y)
|
||||
self.spin.event_generate('<ButtonRelease-1>', x=x, y=y)
|
||||
self.spin.update_idletasks()
|
||||
|
@ -1138,6 +1142,7 @@ class SpinboxTest(EntryTest, unittest.TestCase):
|
|||
height = self.spin.winfo_height()
|
||||
x = width - 5
|
||||
y = height//2 + 4
|
||||
self.assertRegex(self.spin.identify(x, y), r'.*downarrow\Z')
|
||||
self.spin.event_generate('<ButtonPress-1>', x=x, y=y)
|
||||
self.spin.event_generate('<ButtonRelease-1>', x=x, y=y)
|
||||
self.spin.update_idletasks()
|
||||
|
@ -1526,6 +1531,9 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
|
|||
|
||||
def test_heading_callback(self):
|
||||
def simulate_heading_click(x, y):
|
||||
if tcl_version >= (8, 6):
|
||||
self.assertEqual(self.tv.identify_column(x), '#0')
|
||||
self.assertEqual(self.tv.identify_region(x, y), 'heading')
|
||||
simulate_mouse_click(self.tv, x, y)
|
||||
self.tv.update()
|
||||
|
||||
|
|
Loading…
Reference in New Issue