mwxlib 1.6.10__py3-none-any.whl → 1.7.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mwxlib might be problematic. Click here for more details.

mwx/framework.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #! python3
2
2
  """mwxlib framework.
3
3
  """
4
- __version__ = "1.6.10"
4
+ __version__ = "1.7.0"
5
5
  __author__ = "Kazuya O'moto <komoto@jeol.co.jp>"
6
6
 
7
7
  from contextlib import contextmanager
@@ -210,11 +210,11 @@ class KeyCtrlInterfaceMixin:
210
210
  esc-map : 'escape'
211
211
  """
212
212
  message = print # override this in subclass
213
-
213
+
214
214
  @postcall
215
215
  def post_message(self, *args, **kwargs):
216
216
  return self.message(*args, **kwargs)
217
-
217
+
218
218
  @staticmethod
219
219
  def getKeyState(key):
220
220
  """Return state of speckey (cf. wx.GetKeyState)."""
@@ -222,7 +222,7 @@ class KeyCtrlInterfaceMixin:
222
222
  return wx.GetKeyState(_speckeys_wxkmap[key])
223
223
  except KeyError:
224
224
  pass
225
-
225
+
226
226
  @staticmethod
227
227
  def setKeyState(key, state):
228
228
  """Makes you feel like having pressed/released speckey."""
@@ -231,7 +231,7 @@ class KeyCtrlInterfaceMixin:
231
231
  vk.KeyDown(_speckeys_wxkmap[key])
232
232
  else:
233
233
  vk.KeyUp(_speckeys_wxkmap[key])
234
-
234
+
235
235
  def make_keymap(self, keymap):
236
236
  """Make a basis of extension map in the handler.
237
237
  """
@@ -259,7 +259,7 @@ class KeyCtrlInterfaceMixin:
259
259
  '*[LR]win pressed' : [ keymap, _Pass ],
260
260
  },
261
261
  })
262
-
262
+
263
263
  def pre_command_hook(self, evt):
264
264
  ## """Called when entering extension mode (internal use only)."""
265
265
  ## Check text selection for [C-c/C-x].
@@ -271,7 +271,7 @@ class KeyCtrlInterfaceMixin:
271
271
  self.message(evt.key + '-')
272
272
  evt.Skip()
273
273
  pre_command_hook.__name__ = str("enter")
274
-
274
+
275
275
  def post_command_hook(self, evt):
276
276
  ## """Called when exiting extension mode (internal use only)."""
277
277
  ## Check if the event has reached a top-level window.
@@ -284,7 +284,7 @@ class KeyCtrlInterfaceMixin:
284
284
  self.message(evt.key)
285
285
  evt.Skip()
286
286
  post_command_hook.__name__ = str("exit")
287
-
287
+
288
288
  def define_key(self, keymap, action=None, /, *args, **kwargs):
289
289
  """Define [map key (pressed)] action.
290
290
 
@@ -329,7 +329,7 @@ class KeyCtrlInterfaceMixin:
329
329
  else:
330
330
  self.handler.update({map: {key: [state, f]}})
331
331
  return action
332
-
332
+
333
333
  @ignore(UserWarning)
334
334
  def undefine_key(self, keymap):
335
335
  """Delete [map key (pressed)] context."""
@@ -340,7 +340,7 @@ class CtrlInterface(KeyCtrlInterfaceMixin):
340
340
  """Mouse/Key event interface mixin.
341
341
  """
342
342
  handler = property(lambda self: self.__handler)
343
-
343
+
344
344
  def __init__(self):
345
345
  self.__key = ''
346
346
  self.__button = ''
@@ -396,7 +396,7 @@ class CtrlInterface(KeyCtrlInterfaceMixin):
396
396
 
397
397
  self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, lambda v: _N('capture_lost', v))
398
398
  self.Bind(wx.EVT_MOUSE_CAPTURE_CHANGED, lambda v: _N('capture_changed', v))
399
-
399
+
400
400
  def on_hotkey_press(self, evt): #<wx._core.KeyEvent>
401
401
  """Called when a key is pressed."""
402
402
  ## if evt.EventObject is not self:
@@ -406,7 +406,7 @@ class CtrlInterface(KeyCtrlInterfaceMixin):
406
406
  self.__key = regulate_key(key + '-')
407
407
  if self.handler('{} pressed'.format(key), evt) is None:
408
408
  evt.Skip()
409
-
409
+
410
410
  def on_hotkey_down(self, evt): #<wx._core.KeyEvent>
411
411
  """Called when a key is pressed while dragging.
412
412
  Specifically called when the mouse is being captured.
@@ -415,14 +415,14 @@ class CtrlInterface(KeyCtrlInterfaceMixin):
415
415
  self.on_hotkey_press(evt)
416
416
  else:
417
417
  evt.Skip()
418
-
418
+
419
419
  def on_hotkey_up(self, evt): #<wx._core.KeyEvent>
420
420
  """Called when a key is released."""
421
421
  key = hotkey(evt)
422
422
  self.__key = ''
423
423
  if self.handler('{} released'.format(key), evt) is None:
424
424
  evt.Skip()
425
-
425
+
426
426
  def on_mousewheel(self, evt): #<wx._core.MouseEvent>
427
427
  """Called on mouse wheel events.
428
428
  Trigger event: 'key+wheel[up|down|right|left] pressed'
@@ -434,7 +434,7 @@ class CtrlInterface(KeyCtrlInterfaceMixin):
434
434
  evt.key = self.__key + "wheel{}".format(p)
435
435
  if self.handler('{} pressed'.format(evt.key), evt) is None:
436
436
  evt.Skip()
437
-
437
+
438
438
  def on_motion(self, evt): #<wx._core.MouseEvent>
439
439
  """Called on mouse motion events.
440
440
  Trigger event: 'key+[LMR]drag begin/motion/end'
@@ -449,7 +449,7 @@ class CtrlInterface(KeyCtrlInterfaceMixin):
449
449
  else:
450
450
  self.handler('motion', evt)
451
451
  evt.Skip()
452
-
452
+
453
453
  def _mouse_handler(self, event, evt): #<wx._core.MouseEvent>
454
454
  """Called on mouse button events.
455
455
  Trigger event: 'key+[LMRX]button pressed/released/dblclick'
@@ -473,7 +473,7 @@ class CtrlInterface(KeyCtrlInterfaceMixin):
473
473
  self.SetFocusIgnoringChildren() # let the panel accept keys
474
474
  except AttributeError:
475
475
  pass
476
-
476
+
477
477
  def _normal_handler(self, event, evt): #<wx._core.Event>
478
478
  if self.handler(event, evt) is None:
479
479
  evt.Skip()
@@ -599,7 +599,7 @@ class Menu(wx.Menu):
599
599
  self.Append(submenu_item)
600
600
  self.Enable(submenu_item.Id, len(subitems)) # Disable an empty menu.
601
601
  submenu.Id = submenu_item.Id # <- ID_ANY (dummy to check empty sbumenu)
602
-
602
+
603
603
  def _unbind(self):
604
604
  for item in self.MenuItems:
605
605
  if item.Id != wx.ID_SEPARATOR:
@@ -608,12 +608,12 @@ class Menu(wx.Menu):
608
608
  self.owner.Unbind(wx.EVT_MENU_HIGHLIGHT, item)
609
609
  if item.SubMenu:
610
610
  item.SubMenu._unbind()
611
-
611
+
612
612
  def Destroy(self):
613
613
  if self.owner and not self.owner.IsBeingDeleted():
614
614
  self._unbind()
615
615
  return wx.Menu.Destroy(self)
616
-
616
+
617
617
  @staticmethod
618
618
  def Popup(owner, menulist, *args, **kwargs):
619
619
  menu = Menu(owner, menulist)
@@ -636,7 +636,7 @@ class MenuBar(wx.MenuBar, TreeList):
636
636
  def __init__(self, *args, **kwargs):
637
637
  wx.MenuBar.__init__(self, *args, **kwargs)
638
638
  TreeList.__init__(self)
639
-
639
+
640
640
  def getmenu(self, key, root=None):
641
641
  if '/' in key:
642
642
  a, b = key.split('/', 1)
@@ -645,7 +645,7 @@ class MenuBar(wx.MenuBar, TreeList):
645
645
  if root is None:
646
646
  return next((menu for menu, label in self.Menus if menu.Title == key), None)
647
647
  return next((item.SubMenu for item in root.MenuItems if item.ItemLabel == key), None)
648
-
648
+
649
649
  def update(self, key):
650
650
  """Update items of the menu that has specified key:root/branch.
651
651
  Call when the menulist is changed.
@@ -672,7 +672,7 @@ class MenuBar(wx.MenuBar, TreeList):
672
672
 
673
673
  for j, (key, values) in enumerate(self):
674
674
  self.EnableTop(j, bool(values)) # Disable empty main menu.
675
-
675
+
676
676
  def reset(self):
677
677
  """Recreates the menubar if the Parent was attached.
678
678
  Call when the menulist is changed.
@@ -700,22 +700,22 @@ class StatusBar(wx.StatusBar):
700
700
  """
701
701
  def __init__(self, *args, **kwargs):
702
702
  wx.StatusBar.__init__(self, *args, **kwargs)
703
-
703
+
704
704
  def __call__(self, *args, **kwargs):
705
705
  text = ' '.join(str(v) for v in args)
706
706
  if self:
707
707
  return self.write(text, **kwargs)
708
-
708
+
709
709
  def resize(self, field):
710
710
  self.SetFieldsCount(len(field))
711
711
  self.SetStatusWidths(list(field)) # oldver requires list type
712
-
712
+
713
713
  def write(self, text, pane=0):
714
714
  if text and text[0] == '\b':
715
715
  text = self.read(pane) + text[1:]
716
716
  self.SetStatusText(text, pane % self.GetFieldsCount())
717
717
  return text
718
-
718
+
719
719
  def read(self, pane=0):
720
720
  return self.GetStatusText(pane % self.GetFieldsCount())
721
721
 
@@ -729,9 +729,9 @@ class Frame(wx.Frame, KeyCtrlInterfaceMixin):
729
729
  shellframe: mini-frame of the shell
730
730
  """
731
731
  handler = property(lambda self: self.__handler)
732
-
732
+
733
733
  message = property(lambda self: self.statusbar)
734
-
734
+
735
735
  def __init__(self, *args, **kwargs):
736
736
  wx.Frame.__init__(self, *args, **kwargs)
737
737
 
@@ -782,11 +782,11 @@ class Frame(wx.Frame, KeyCtrlInterfaceMixin):
782
782
  },
783
783
  )
784
784
  self.make_keymap('C-x')
785
-
785
+
786
786
  def About(self):
787
787
  wx.MessageBox(__import__("__main__").__doc__ or "no information",
788
788
  "About this software")
789
-
789
+
790
790
  def Destroy(self):
791
791
  self.timer.Stop()
792
792
  self.shellframe.Destroy() # shellframe is not my child
@@ -801,9 +801,9 @@ class MiniFrame(wx.MiniFrame, KeyCtrlInterfaceMixin):
801
801
  statusbar: StatusBar (not shown by default)
802
802
  """
803
803
  handler = property(lambda self: self.__handler)
804
-
804
+
805
805
  message = property(lambda self: self.statusbar)
806
-
806
+
807
807
  def __init__(self, *args, **kwargs):
808
808
  wx.MiniFrame.__init__(self, *args, **kwargs)
809
809
 
@@ -861,24 +861,24 @@ class AuiNotebook(aui.AuiNotebook):
861
861
  except AttributeError:
862
862
  pass
863
863
  self.Bind(aui.EVT_AUINOTEBOOK_TAB_RIGHT_DOWN, tab_menu)
864
-
864
+
865
865
  @property
866
866
  def _all_tabs(self):
867
867
  """Return all AuiTabCtrl objects (internal use only)."""
868
868
  return [x for x in self.Children if isinstance(x, aui.AuiTabCtrl)]
869
-
869
+
870
870
  @property
871
871
  def _all_panes(self):
872
872
  """Return all AuiPaneInfo excluding `dummy` one (internal use only)."""
873
873
  return list(self._mgr.AllPanes)[1:]
874
-
874
+
875
875
  def get_pages(self, type=None):
876
876
  """Yields pages of the specified window type."""
877
877
  for i in range(self.PageCount):
878
878
  win = self.GetPage(i)
879
879
  if type is None or isinstance(win, type):
880
880
  yield win
881
-
881
+
882
882
  def swap_page(self, win):
883
883
  """Replace the page with the specified page w/o focusing."""
884
884
  j = self.GetPageIndex(win)
@@ -890,12 +890,12 @@ class AuiNotebook(aui.AuiNotebook):
890
890
  self.CurrentPage.SetFocus() # reset focus
891
891
  if wnd and wnd is not org: # restore focus other window
892
892
  wnd.SetFocus()
893
-
893
+
894
894
  def get_caption(self, win):
895
895
  """Get caption of tab/page for specifiend window."""
896
896
  tab, page = self.find_tab(win)
897
897
  return page.caption
898
-
898
+
899
899
  def set_caption(self, win, caption):
900
900
  """Set caption of tab/page for specifiend window.
901
901
  Returns True if the caption has changed.
@@ -905,7 +905,7 @@ class AuiNotebook(aui.AuiNotebook):
905
905
  page.caption = caption
906
906
  tab.Refresh()
907
907
  return True
908
-
908
+
909
909
  def find_tab(self, win):
910
910
  """Return AuiTabCtrl and AuiNotebookPage for the window.
911
911
 
@@ -918,7 +918,7 @@ class AuiNotebook(aui.AuiNotebook):
918
918
  ## if page.window is win or page.caption == win:
919
919
  if page.window is win or page.window.Name == win:
920
920
  return tab, page
921
-
921
+
922
922
  def move_tab(self, win, tab):
923
923
  """Move the window page to the specified tab."""
924
924
  if isinstance(tab, int):
@@ -938,10 +938,10 @@ class AuiNotebook(aui.AuiNotebook):
938
938
  tc1.Destroy()
939
939
  self._mgr.DetachPane(pane.window)
940
940
  self._mgr.Update()
941
-
941
+
942
942
  ## Methods to save / load the perspectives.
943
943
  ## *** Inspired by wx.lib.agw.aui.AuiNotebook ***
944
-
944
+
945
945
  def savePerspective(self):
946
946
  """Saves the entire user interface layout into an encoded string,
947
947
  which can then be stored by the application.
@@ -959,7 +959,7 @@ class AuiNotebook(aui.AuiNotebook):
959
959
  names = [page.window.Name for page in tabs.Pages]
960
960
  spec += f"pane{j+1}={names};{k}|"
961
961
  return spec + '@' + self._mgr.SavePerspective()
962
-
962
+
963
963
  def loadPerspective(self, spec):
964
964
  """Loads a saved perspective.
965
965
 
@@ -1013,7 +1013,7 @@ class FileDropLoader(wx.DropTarget):
1013
1013
  self.do.Add(self.textdo)
1014
1014
  self.do.Add(self.filedo)
1015
1015
  self.SetDataObject(self.do)
1016
-
1016
+
1017
1017
  def OnDragOver(self, x, y, result):
1018
1018
  index, flags = self.target.HitTest((x, y))
1019
1019
  if index != -1:
@@ -1022,7 +1022,7 @@ class FileDropLoader(wx.DropTarget):
1022
1022
  else:
1023
1023
  result = wx.DragNone
1024
1024
  return result
1025
-
1025
+
1026
1026
  def OnData(self, x, y, result):
1027
1027
  editor = self.target.Parent.current_editor
1028
1028
  self.GetData()
@@ -1085,7 +1085,7 @@ class ShellFrame(MiniFrame):
1085
1085
  @filling : Inspection using ``wx.lib.filling.Filling``.
1086
1086
  """
1087
1087
  rootshell = property(lambda self: self.__shell) #: the root shell
1088
-
1088
+
1089
1089
  def __init__(self, parent, target=None, session=None, standalone=False, **kwargs):
1090
1090
  MiniFrame.__init__(self, parent, size=(1280,720), style=wx.DEFAULT_FRAME_STYLE)
1091
1091
 
@@ -1285,7 +1285,7 @@ class ShellFrame(MiniFrame):
1285
1285
  self.load_session(session or self.SESSION_FILE)
1286
1286
  else:
1287
1287
  self.SESSION_FILE = None
1288
-
1288
+
1289
1289
  def load_session(self, filename):
1290
1290
  """Load session from file.
1291
1291
  Buffers, pointers, and the entire layout are loaded.
@@ -1316,7 +1316,7 @@ class ShellFrame(MiniFrame):
1316
1316
  ## Reposition the window if it is not on the desktop.
1317
1317
  if wx.Display.GetFromWindow(self) == -1:
1318
1318
  self.Position = (0, 0)
1319
-
1319
+
1320
1320
  def save_session(self):
1321
1321
  """Save session to file.
1322
1322
  Buffers, pointers, and the entire layout are saved.
@@ -1355,7 +1355,7 @@ class ShellFrame(MiniFrame):
1355
1355
  "self._mgr.LoadPerspective({!r})".format(self._mgr.SavePerspective()),
1356
1356
  "self._mgr.Update()\n",
1357
1357
  )))
1358
-
1358
+
1359
1359
  def Init(self):
1360
1360
  """Initialize self-specific builtins.
1361
1361
  Note:
@@ -1383,7 +1383,7 @@ class ShellFrame(MiniFrame):
1383
1383
  builtins.profile = self.profile
1384
1384
  builtins.highlight = self.highlight
1385
1385
  builtins.filling = filling
1386
-
1386
+
1387
1387
  def Destroy(self):
1388
1388
  try:
1389
1389
  ## Remove built-in self methods
@@ -1403,13 +1403,13 @@ class ShellFrame(MiniFrame):
1403
1403
  self.save_session()
1404
1404
  self._mgr.UnInit()
1405
1405
  return MiniFrame.Destroy(self)
1406
-
1406
+
1407
1407
  def Close(self):
1408
1408
  if self.__standalone:
1409
1409
  MiniFrame.Close(self)
1410
1410
  else:
1411
1411
  self.Show(not self.Shown)
1412
-
1412
+
1413
1413
  def OnClose(self, evt):
1414
1414
  if self.debugger.busy:
1415
1415
  if wx.MessageBox( # Confirm closing the debugger.
@@ -1447,7 +1447,7 @@ class ShellFrame(MiniFrame):
1447
1447
  evt.Skip() # Close the window
1448
1448
  else:
1449
1449
  self.Show(0) # Don't destroy the window
1450
-
1450
+
1451
1451
  def OnActivate(self, evt):
1452
1452
  if not evt.Active:
1453
1453
  ## Reset autoload when active focus going outside.
@@ -1481,20 +1481,20 @@ class ShellFrame(MiniFrame):
1481
1481
  if evt.Active:
1482
1482
  self.Init()
1483
1483
  evt.Skip()
1484
-
1484
+
1485
1485
  def OnShow(self, evt):
1486
1486
  for pane in self._mgr.GetAllPanes():
1487
1487
  ## When the window is hidden, disable docking and keep child panes floating.
1488
1488
  pane.Dockable(evt.IsShown() or pane.IsDocked())
1489
1489
  evt.Skip()
1490
-
1490
+
1491
1491
  def OnGhostShow(self, evt):
1492
1492
  if evt.IsShown():
1493
1493
  self.inspector.watch()
1494
1494
  else:
1495
1495
  self.inspector.unwatch()
1496
1496
  evt.Skip()
1497
-
1497
+
1498
1498
  def OnConsolePageChanged(self, evt): #<wx._aui.AuiNotebookEvent>
1499
1499
  nb = evt.EventObject
1500
1500
  win = nb.CurrentPage
@@ -1504,7 +1504,7 @@ class ShellFrame(MiniFrame):
1504
1504
  nb.WindowStyle |= aui.AUI_NB_CLOSE_ON_ACTIVE_TAB
1505
1505
  nb.TabCtrlHeight = 0 if nb.PageCount == 1 else -1
1506
1506
  evt.Skip()
1507
-
1507
+
1508
1508
  def OnConsolePageClose(self, evt): #<wx._aui.AuiNotebookEvent>
1509
1509
  nb = evt.EventObject
1510
1510
  win = list(nb.get_pages())[evt.Selection]
@@ -1518,7 +1518,7 @@ class ShellFrame(MiniFrame):
1518
1518
  evt.Veto()
1519
1519
  else:
1520
1520
  evt.Skip()
1521
-
1521
+
1522
1522
  def About(self, evt=None):
1523
1523
  self.add_help(
1524
1524
  '\n\n'.join((
@@ -1538,7 +1538,7 @@ class ShellFrame(MiniFrame):
1538
1538
  ## f"To show the credit, press [C-M-Mbutton].", # cf. wx.InfoMessageBox(None)
1539
1539
  ))
1540
1540
  )
1541
-
1541
+
1542
1542
  def toggle_window(self, win):
1543
1543
  pane = self._mgr.GetPane(win)
1544
1544
  if pane.IsDocked():
@@ -1548,7 +1548,7 @@ class ShellFrame(MiniFrame):
1548
1548
  if pane.IsShown():
1549
1549
  pane.best_size = win.Size
1550
1550
  self.popup_window(win, not pane.IsShown())
1551
-
1551
+
1552
1552
  @save_focus_excursion()
1553
1553
  def popup_window(self, win, show=True):
1554
1554
  """Show the notebook page and keep the focus."""
@@ -1573,11 +1573,11 @@ class ShellFrame(MiniFrame):
1573
1573
  nb.Show(show)
1574
1574
  pane.Show(show)
1575
1575
  self._mgr.Update()
1576
-
1576
+
1577
1577
  ## --------------------------------
1578
1578
  ## Actions for handler
1579
1579
  ## --------------------------------
1580
-
1580
+
1581
1581
  def Quit(self, evt=None):
1582
1582
  """Stop debugger and monitor."""
1583
1583
  self.monitor.unwatch()
@@ -1588,7 +1588,7 @@ class ShellFrame(MiniFrame):
1588
1588
  del shell.globals
1589
1589
  self.indicator.Value = 1
1590
1590
  self.message("Quit")
1591
-
1591
+
1592
1592
  @save_focus_excursion()
1593
1593
  def load(self, filename, lineno=0, show=True):
1594
1594
  """Load file @where the object is defined.
@@ -1613,13 +1613,13 @@ class ShellFrame(MiniFrame):
1613
1613
  if ret and show:
1614
1614
  self.popup_window(editor, show)
1615
1615
  return ret
1616
-
1616
+
1617
1617
  def info(self, obj):
1618
1618
  self.rootshell.info(obj)
1619
-
1619
+
1620
1620
  def help(self, obj):
1621
1621
  self.rootshell.help(obj)
1622
-
1622
+
1623
1623
  def watch(self, obj):
1624
1624
  if isinstance(obj, wx.Object):
1625
1625
  self.monitor.watch(obj)
@@ -1630,10 +1630,10 @@ class ShellFrame(MiniFrame):
1630
1630
  self.popup_window(self.linfo)
1631
1631
  else:
1632
1632
  raise TypeError("primitive objects cannot be set as watch targets")
1633
-
1633
+
1634
1634
  def highlight(self, obj, *args, **kwargs):
1635
1635
  self.inspector.highlight(obj, *args, **kwargs)
1636
-
1636
+
1637
1637
  def timeit(self, obj, *args, **kwargs):
1638
1638
  """Measure the duration cpu time (per one execution)."""
1639
1639
  from timeit import timeit
@@ -1652,7 +1652,7 @@ class ShellFrame(MiniFrame):
1652
1652
  print(e)
1653
1653
  else:
1654
1654
  print("- obj must be either a string or a callable.")
1655
-
1655
+
1656
1656
  def profile(self, obj, *args, **kwargs):
1657
1657
  """Profile a single function call."""
1658
1658
  from profile import Profile
@@ -1673,7 +1673,7 @@ class ShellFrame(MiniFrame):
1673
1673
  print(e)
1674
1674
  else:
1675
1675
  print("- obj must be callable, or a string, bytes, or code object.")
1676
-
1676
+
1677
1677
  ## Note: history に余計な文字列が入らないようにする
1678
1678
  @postcall
1679
1679
  def debug(self, obj, *args, **kwargs):
@@ -1701,7 +1701,7 @@ class ShellFrame(MiniFrame):
1701
1701
  style=wx.ICON_ERROR)
1702
1702
  finally:
1703
1703
  self.debugger.interactive_shell = shell
1704
-
1704
+
1705
1705
  def on_debug_begin(self, frame):
1706
1706
  """Called before set_trace."""
1707
1707
  if not self:
@@ -1717,7 +1717,7 @@ class ShellFrame(MiniFrame):
1717
1717
  self.indicator.Value = 2
1718
1718
  if wx.IsBusy():
1719
1719
  wx.EndBusyCursor()
1720
-
1720
+
1721
1721
  def on_debug_next(self, frame):
1722
1722
  """Called from cmdloop."""
1723
1723
  if not self:
@@ -1738,7 +1738,7 @@ class ShellFrame(MiniFrame):
1738
1738
  command = re.sub(r"^(.*)", r" \1", command, flags=re.M)
1739
1739
  self.add_log(command)
1740
1740
  self.message("Debugger is busy now (Press [C-g] to quit).")
1741
-
1741
+
1742
1742
  def on_debug_end(self, frame):
1743
1743
  """Called after set_quit."""
1744
1744
  if not self:
@@ -1755,7 +1755,7 @@ class ShellFrame(MiniFrame):
1755
1755
  self.indicator.Value = 1
1756
1756
  if wx.IsBusy():
1757
1757
  wx.EndBusyCursor()
1758
-
1758
+
1759
1759
  def set_hookable(self, editor, traceable=True):
1760
1760
  """Bind pointer to set/unset trace."""
1761
1761
  if traceable:
@@ -1764,67 +1764,67 @@ class ShellFrame(MiniFrame):
1764
1764
  else:
1765
1765
  editor.handler.unbind('pointer_set')
1766
1766
  editor.handler.unbind('pointer_unset')
1767
-
1767
+
1768
1768
  def start_trace(self, line, editor):
1769
1769
  if not self.debugger.busy:
1770
1770
  self.debugger.unwatch()
1771
1771
  self.debugger.editor = editor
1772
1772
  self.debugger.watch((editor.buffer.filename, line+1))
1773
1773
  self.debugger.send_input('') # clear input
1774
-
1774
+
1775
1775
  def stop_trace(self, line, editor):
1776
1776
  if self.debugger.busy:
1777
1777
  return
1778
1778
  if self.debugger.tracing:
1779
1779
  self.debugger.editor = None
1780
1780
  self.debugger.unwatch()
1781
-
1781
+
1782
1782
  def on_trace_begin(self, frame):
1783
1783
  """Called when set-trace."""
1784
1784
  self.message("Debugger has started tracing {!r}.".format(frame))
1785
1785
  self.indicator.Value = 3
1786
-
1786
+
1787
1787
  def on_trace_hook(self, frame):
1788
1788
  """Called when a breakpoint is reached."""
1789
1789
  self.message("Debugger hooked {!r}.".format(frame))
1790
-
1790
+
1791
1791
  def on_trace_end(self, frame):
1792
1792
  """Called when unset-trace."""
1793
1793
  self.message("Debugger has stopped tracing {!r}.".format(frame))
1794
1794
  self.indicator.Value = 1
1795
-
1795
+
1796
1796
  def on_monitor_begin(self, widget):
1797
1797
  """Called when monitor watch."""
1798
1798
  self.inspector.set_colour(widget, 'blue')
1799
1799
  self.message("Started monitoring {!r}.".format(widget))
1800
-
1800
+
1801
1801
  def on_monitor_end(self, widget):
1802
1802
  """Called when monitor unwatch."""
1803
1803
  self.inspector.set_colour(widget, 'black')
1804
1804
  self.message("Stopped monitoring {!r}.".format(widget))
1805
-
1805
+
1806
1806
  def on_title_window(self, obj):
1807
1807
  """Set title to the frame."""
1808
1808
  title = obj if isinstance(obj, str) else repr(obj)
1809
1809
  self.SetTitle("Nautilus - {}".format(title))
1810
-
1810
+
1811
1811
  def add_log(self, text, noerr=None):
1812
1812
  """Add text to the logging buffer.
1813
- If noerr:bool is specified, add a line-mark.
1813
+ If noerr:bool is specified, add a line-marker.
1814
1814
  """
1815
1815
  buf = self.Log.default_buffer or self.Log.new_buffer()
1816
1816
  with buf.off_readonly():
1817
- buf.goto_char(buf.TextLength) # line to set an arrow mark
1817
+ buf.goto_char(buf.TextLength) # line to set an arrow marker
1818
1818
  buf.write(text)
1819
1819
  if noerr is not None:
1820
- ## Set a mark on the current line.
1820
+ ## Set a marker on the current line.
1821
1821
  buf.add_marker(buf.cline, 1 if noerr else 2) # 1:white 2:red-arrow
1822
1822
  return
1823
1823
 
1824
1824
  ## Logging text every step in case of crash.
1825
1825
  ## with open(self.LOGGING_FILE, 'a', encoding='utf-8', newline='') as o:
1826
1826
  ## o.write(text)
1827
-
1827
+
1828
1828
  def add_help(self, text, title=None):
1829
1829
  """Add text to the help buffer.
1830
1830
  If title:str is specified, create a new buffer with that title.
@@ -1840,7 +1840,7 @@ class ShellFrame(MiniFrame):
1840
1840
  ## Overwrite text and popup the window.
1841
1841
  self.popup_window(self.Help)
1842
1842
  self.Help.swap_page(buf)
1843
-
1843
+
1844
1844
  def clone_shell(self, target):
1845
1845
  if not hasattr(target, '__dict__'):
1846
1846
  raise TypeError("primitive objects cannot be targeted")
@@ -1856,7 +1856,7 @@ class ShellFrame(MiniFrame):
1856
1856
  self.Show()
1857
1857
  shell.SetFocus()
1858
1858
  return shell
1859
-
1859
+
1860
1860
  def delete_shell(self, shell):
1861
1861
  """Close the current shell."""
1862
1862
  if shell is self.rootshell:
@@ -1869,16 +1869,16 @@ class ShellFrame(MiniFrame):
1869
1869
  j = self.console.GetPageIndex(shell)
1870
1870
  if j != -1:
1871
1871
  self.console.DeletePage(j) # Destroy the window
1872
-
1872
+
1873
1873
  ## --------------------------------
1874
1874
  ## Attributes for notebook pages
1875
1875
  ## --------------------------------
1876
-
1876
+
1877
1877
  def get_all_pages(self, type=None):
1878
1878
  """Yields all pages of the specified type in the notebooks."""
1879
1879
  yield from self.console.get_pages(type)
1880
1880
  yield from self.ghost.get_pages(type)
1881
-
1881
+
1882
1882
  def get_all_shells(self, target=None):
1883
1883
  """Yields all shells with specified target.
1884
1884
 
@@ -1892,7 +1892,7 @@ class ShellFrame(MiniFrame):
1892
1892
  if shell.target is target:
1893
1893
  self.console.swap_page(shell)
1894
1894
  yield shell
1895
-
1895
+
1896
1896
  def get_all_editors(self, fn=None):
1897
1897
  """Yields all editors with specified fn:filename or code.
1898
1898
 
@@ -1907,12 +1907,12 @@ class ShellFrame(MiniFrame):
1907
1907
  if buf:
1908
1908
  book.swap_page(buf)
1909
1909
  yield book
1910
-
1910
+
1911
1911
  @property
1912
1912
  def current_shell(self):
1913
1913
  """Currently selected shell or rootshell."""
1914
1914
  return self.console.CurrentPage
1915
-
1915
+
1916
1916
  @property
1917
1917
  def current_editor(self):
1918
1918
  """Currently selected editor or scratch."""
@@ -1920,7 +1920,7 @@ class ShellFrame(MiniFrame):
1920
1920
  if isinstance(editor, type(self.Log)):
1921
1921
  return editor
1922
1922
  return next((book for book in self.get_all_editors() if book.IsShown()), self.Scratch)
1923
-
1923
+
1924
1924
  def create_editor(self, bookname):
1925
1925
  """Create a new editor (internal use only)..
1926
1926
  If such an editor already exists, no new editor is created.
@@ -1938,14 +1938,14 @@ class ShellFrame(MiniFrame):
1938
1938
  self.Bookshelf.build_tree(clear=0)
1939
1939
  wx.CallAfter(_attach)
1940
1940
  return editor
1941
-
1941
+
1942
1942
  ## --------------------------------
1943
1943
  ## Find / Replace text dialog
1944
1944
  ## --------------------------------
1945
1945
  ## *** The following code is a modification of <wx.py.frame.Frame> ***
1946
-
1946
+
1947
1947
  __find_target = None
1948
-
1948
+
1949
1949
  def on_search_dialog(self, evt, flags=0):
1950
1950
  if self.findDlg is not None:
1951
1951
  self.findDlg.SetFocus()
@@ -1961,16 +1961,16 @@ class ShellFrame(MiniFrame):
1961
1961
  self.findData.Flags |= wx.FR_DOWN
1962
1962
  self.findDlg = wx.FindReplaceDialog(wnd, self.findData, "Find", flags)
1963
1963
  self.findDlg.Show()
1964
-
1964
+
1965
1965
  def on_replace_dialog(self, evt):
1966
1966
  self.on_search_dialog(evt, flags=wx.FR_REPLACEDIALOG)
1967
-
1967
+
1968
1968
  def repeat_forward_search(self, evt):
1969
1969
  self.OnFindNext(evt, backward=False)
1970
-
1970
+
1971
1971
  def repeat_backward_search(self, evt):
1972
1972
  self.OnFindNext(evt, backward=True)
1973
-
1973
+
1974
1974
  def OnFindNext(self, evt, backward=None): #<wx._core.FindDialogEvent>
1975
1975
  if not self.findData.FindString:
1976
1976
  self.message("No last search.")
@@ -2001,7 +2001,7 @@ class ShellFrame(MiniFrame):
2001
2001
  self.OnFindClose(None)
2002
2002
  if loc < 0:
2003
2003
  self.message("Unable to find the search text.")
2004
-
2004
+
2005
2005
  def OnFindClose(self, evt): #<wx._core.FindDialogEvent>
2006
2006
  self.findDlg.Destroy()
2007
2007
  self.findDlg = None