mwxlib 1.6.8__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/bookshelf.py +26 -22
- mwx/controls.py +142 -143
- mwx/framework.py +109 -114
- mwx/graphman.py +90 -89
- mwx/matplot2.py +82 -81
- mwx/matplot2g.py +165 -165
- mwx/matplot2lg.py +57 -57
- mwx/mgplt.py +12 -12
- mwx/nutshell.py +306 -288
- mwx/plugins/ffmpeg_view.py +15 -15
- mwx/plugins/fft_view.py +4 -4
- mwx/plugins/frame_listview.py +26 -26
- mwx/plugins/line_profile.py +1 -1
- mwx/utilus.py +40 -40
- mwx/wxmon.py +20 -20
- mwx/wxpdb.py +46 -46
- mwx/wxwil.py +11 -11
- mwx/wxwit.py +15 -15
- {mwxlib-1.6.8.dist-info → mwxlib-1.7.0.dist-info}/METADATA +1 -1
- mwxlib-1.7.0.dist-info/RECORD +28 -0
- mwxlib-1.6.8.dist-info/RECORD +0 -28
- {mwxlib-1.6.8.dist-info → mwxlib-1.7.0.dist-info}/WHEEL +0 -0
- {mwxlib-1.6.8.dist-info → mwxlib-1.7.0.dist-info}/top_level.txt +0 -0
mwx/framework.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#! python3
|
|
2
2
|
"""mwxlib framework.
|
|
3
3
|
"""
|
|
4
|
-
__version__ = "1.
|
|
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,18 +608,16 @@ 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
|
-
except Exception:
|
|
616
|
-
pass
|
|
617
615
|
return wx.Menu.Destroy(self)
|
|
618
|
-
|
|
616
|
+
|
|
619
617
|
@staticmethod
|
|
620
|
-
def Popup(
|
|
621
|
-
menu = Menu(
|
|
622
|
-
|
|
618
|
+
def Popup(owner, menulist, *args, **kwargs):
|
|
619
|
+
menu = Menu(owner, menulist)
|
|
620
|
+
owner.PopupMenu(menu, *args, **kwargs)
|
|
623
621
|
menu.Destroy()
|
|
624
622
|
|
|
625
623
|
|
|
@@ -638,7 +636,7 @@ class MenuBar(wx.MenuBar, TreeList):
|
|
|
638
636
|
def __init__(self, *args, **kwargs):
|
|
639
637
|
wx.MenuBar.__init__(self, *args, **kwargs)
|
|
640
638
|
TreeList.__init__(self)
|
|
641
|
-
|
|
639
|
+
|
|
642
640
|
def getmenu(self, key, root=None):
|
|
643
641
|
if '/' in key:
|
|
644
642
|
a, b = key.split('/', 1)
|
|
@@ -647,7 +645,7 @@ class MenuBar(wx.MenuBar, TreeList):
|
|
|
647
645
|
if root is None:
|
|
648
646
|
return next((menu for menu, label in self.Menus if menu.Title == key), None)
|
|
649
647
|
return next((item.SubMenu for item in root.MenuItems if item.ItemLabel == key), None)
|
|
650
|
-
|
|
648
|
+
|
|
651
649
|
def update(self, key):
|
|
652
650
|
"""Update items of the menu that has specified key:root/branch.
|
|
653
651
|
Call when the menulist is changed.
|
|
@@ -674,7 +672,7 @@ class MenuBar(wx.MenuBar, TreeList):
|
|
|
674
672
|
|
|
675
673
|
for j, (key, values) in enumerate(self):
|
|
676
674
|
self.EnableTop(j, bool(values)) # Disable empty main menu.
|
|
677
|
-
|
|
675
|
+
|
|
678
676
|
def reset(self):
|
|
679
677
|
"""Recreates the menubar if the Parent was attached.
|
|
680
678
|
Call when the menulist is changed.
|
|
@@ -702,22 +700,22 @@ class StatusBar(wx.StatusBar):
|
|
|
702
700
|
"""
|
|
703
701
|
def __init__(self, *args, **kwargs):
|
|
704
702
|
wx.StatusBar.__init__(self, *args, **kwargs)
|
|
705
|
-
|
|
703
|
+
|
|
706
704
|
def __call__(self, *args, **kwargs):
|
|
707
705
|
text = ' '.join(str(v) for v in args)
|
|
708
706
|
if self:
|
|
709
707
|
return self.write(text, **kwargs)
|
|
710
|
-
|
|
708
|
+
|
|
711
709
|
def resize(self, field):
|
|
712
710
|
self.SetFieldsCount(len(field))
|
|
713
711
|
self.SetStatusWidths(list(field)) # oldver requires list type
|
|
714
|
-
|
|
712
|
+
|
|
715
713
|
def write(self, text, pane=0):
|
|
716
714
|
if text and text[0] == '\b':
|
|
717
715
|
text = self.read(pane) + text[1:]
|
|
718
716
|
self.SetStatusText(text, pane % self.GetFieldsCount())
|
|
719
717
|
return text
|
|
720
|
-
|
|
718
|
+
|
|
721
719
|
def read(self, pane=0):
|
|
722
720
|
return self.GetStatusText(pane % self.GetFieldsCount())
|
|
723
721
|
|
|
@@ -731,9 +729,9 @@ class Frame(wx.Frame, KeyCtrlInterfaceMixin):
|
|
|
731
729
|
shellframe: mini-frame of the shell
|
|
732
730
|
"""
|
|
733
731
|
handler = property(lambda self: self.__handler)
|
|
734
|
-
|
|
732
|
+
|
|
735
733
|
message = property(lambda self: self.statusbar)
|
|
736
|
-
|
|
734
|
+
|
|
737
735
|
def __init__(self, *args, **kwargs):
|
|
738
736
|
wx.Frame.__init__(self, *args, **kwargs)
|
|
739
737
|
|
|
@@ -784,11 +782,11 @@ class Frame(wx.Frame, KeyCtrlInterfaceMixin):
|
|
|
784
782
|
},
|
|
785
783
|
)
|
|
786
784
|
self.make_keymap('C-x')
|
|
787
|
-
|
|
785
|
+
|
|
788
786
|
def About(self):
|
|
789
787
|
wx.MessageBox(__import__("__main__").__doc__ or "no information",
|
|
790
788
|
"About this software")
|
|
791
|
-
|
|
789
|
+
|
|
792
790
|
def Destroy(self):
|
|
793
791
|
self.timer.Stop()
|
|
794
792
|
self.shellframe.Destroy() # shellframe is not my child
|
|
@@ -803,9 +801,9 @@ class MiniFrame(wx.MiniFrame, KeyCtrlInterfaceMixin):
|
|
|
803
801
|
statusbar: StatusBar (not shown by default)
|
|
804
802
|
"""
|
|
805
803
|
handler = property(lambda self: self.__handler)
|
|
806
|
-
|
|
804
|
+
|
|
807
805
|
message = property(lambda self: self.statusbar)
|
|
808
|
-
|
|
806
|
+
|
|
809
807
|
def __init__(self, *args, **kwargs):
|
|
810
808
|
wx.MiniFrame.__init__(self, *args, **kwargs)
|
|
811
809
|
|
|
@@ -838,9 +836,6 @@ class MiniFrame(wx.MiniFrame, KeyCtrlInterfaceMixin):
|
|
|
838
836
|
},
|
|
839
837
|
)
|
|
840
838
|
self.make_keymap('C-x')
|
|
841
|
-
|
|
842
|
-
def Destroy(self):
|
|
843
|
-
return wx.MiniFrame.Destroy(self)
|
|
844
839
|
|
|
845
840
|
|
|
846
841
|
class AuiNotebook(aui.AuiNotebook):
|
|
@@ -866,24 +861,24 @@ class AuiNotebook(aui.AuiNotebook):
|
|
|
866
861
|
except AttributeError:
|
|
867
862
|
pass
|
|
868
863
|
self.Bind(aui.EVT_AUINOTEBOOK_TAB_RIGHT_DOWN, tab_menu)
|
|
869
|
-
|
|
864
|
+
|
|
870
865
|
@property
|
|
871
866
|
def _all_tabs(self):
|
|
872
867
|
"""Return all AuiTabCtrl objects (internal use only)."""
|
|
873
868
|
return [x for x in self.Children if isinstance(x, aui.AuiTabCtrl)]
|
|
874
|
-
|
|
869
|
+
|
|
875
870
|
@property
|
|
876
871
|
def _all_panes(self):
|
|
877
872
|
"""Return all AuiPaneInfo excluding `dummy` one (internal use only)."""
|
|
878
873
|
return list(self._mgr.AllPanes)[1:]
|
|
879
|
-
|
|
874
|
+
|
|
880
875
|
def get_pages(self, type=None):
|
|
881
876
|
"""Yields pages of the specified window type."""
|
|
882
877
|
for i in range(self.PageCount):
|
|
883
878
|
win = self.GetPage(i)
|
|
884
879
|
if type is None or isinstance(win, type):
|
|
885
880
|
yield win
|
|
886
|
-
|
|
881
|
+
|
|
887
882
|
def swap_page(self, win):
|
|
888
883
|
"""Replace the page with the specified page w/o focusing."""
|
|
889
884
|
j = self.GetPageIndex(win)
|
|
@@ -895,12 +890,12 @@ class AuiNotebook(aui.AuiNotebook):
|
|
|
895
890
|
self.CurrentPage.SetFocus() # reset focus
|
|
896
891
|
if wnd and wnd is not org: # restore focus other window
|
|
897
892
|
wnd.SetFocus()
|
|
898
|
-
|
|
893
|
+
|
|
899
894
|
def get_caption(self, win):
|
|
900
895
|
"""Get caption of tab/page for specifiend window."""
|
|
901
896
|
tab, page = self.find_tab(win)
|
|
902
897
|
return page.caption
|
|
903
|
-
|
|
898
|
+
|
|
904
899
|
def set_caption(self, win, caption):
|
|
905
900
|
"""Set caption of tab/page for specifiend window.
|
|
906
901
|
Returns True if the caption has changed.
|
|
@@ -910,7 +905,7 @@ class AuiNotebook(aui.AuiNotebook):
|
|
|
910
905
|
page.caption = caption
|
|
911
906
|
tab.Refresh()
|
|
912
907
|
return True
|
|
913
|
-
|
|
908
|
+
|
|
914
909
|
def find_tab(self, win):
|
|
915
910
|
"""Return AuiTabCtrl and AuiNotebookPage for the window.
|
|
916
911
|
|
|
@@ -923,7 +918,7 @@ class AuiNotebook(aui.AuiNotebook):
|
|
|
923
918
|
## if page.window is win or page.caption == win:
|
|
924
919
|
if page.window is win or page.window.Name == win:
|
|
925
920
|
return tab, page
|
|
926
|
-
|
|
921
|
+
|
|
927
922
|
def move_tab(self, win, tab):
|
|
928
923
|
"""Move the window page to the specified tab."""
|
|
929
924
|
if isinstance(tab, int):
|
|
@@ -943,10 +938,10 @@ class AuiNotebook(aui.AuiNotebook):
|
|
|
943
938
|
tc1.Destroy()
|
|
944
939
|
self._mgr.DetachPane(pane.window)
|
|
945
940
|
self._mgr.Update()
|
|
946
|
-
|
|
941
|
+
|
|
947
942
|
## Methods to save / load the perspectives.
|
|
948
943
|
## *** Inspired by wx.lib.agw.aui.AuiNotebook ***
|
|
949
|
-
|
|
944
|
+
|
|
950
945
|
def savePerspective(self):
|
|
951
946
|
"""Saves the entire user interface layout into an encoded string,
|
|
952
947
|
which can then be stored by the application.
|
|
@@ -964,7 +959,7 @@ class AuiNotebook(aui.AuiNotebook):
|
|
|
964
959
|
names = [page.window.Name for page in tabs.Pages]
|
|
965
960
|
spec += f"pane{j+1}={names};{k}|"
|
|
966
961
|
return spec + '@' + self._mgr.SavePerspective()
|
|
967
|
-
|
|
962
|
+
|
|
968
963
|
def loadPerspective(self, spec):
|
|
969
964
|
"""Loads a saved perspective.
|
|
970
965
|
|
|
@@ -1018,7 +1013,7 @@ class FileDropLoader(wx.DropTarget):
|
|
|
1018
1013
|
self.do.Add(self.textdo)
|
|
1019
1014
|
self.do.Add(self.filedo)
|
|
1020
1015
|
self.SetDataObject(self.do)
|
|
1021
|
-
|
|
1016
|
+
|
|
1022
1017
|
def OnDragOver(self, x, y, result):
|
|
1023
1018
|
index, flags = self.target.HitTest((x, y))
|
|
1024
1019
|
if index != -1:
|
|
@@ -1027,7 +1022,7 @@ class FileDropLoader(wx.DropTarget):
|
|
|
1027
1022
|
else:
|
|
1028
1023
|
result = wx.DragNone
|
|
1029
1024
|
return result
|
|
1030
|
-
|
|
1025
|
+
|
|
1031
1026
|
def OnData(self, x, y, result):
|
|
1032
1027
|
editor = self.target.Parent.current_editor
|
|
1033
1028
|
self.GetData()
|
|
@@ -1090,7 +1085,7 @@ class ShellFrame(MiniFrame):
|
|
|
1090
1085
|
@filling : Inspection using ``wx.lib.filling.Filling``.
|
|
1091
1086
|
"""
|
|
1092
1087
|
rootshell = property(lambda self: self.__shell) #: the root shell
|
|
1093
|
-
|
|
1088
|
+
|
|
1094
1089
|
def __init__(self, parent, target=None, session=None, standalone=False, **kwargs):
|
|
1095
1090
|
MiniFrame.__init__(self, parent, size=(1280,720), style=wx.DEFAULT_FRAME_STYLE)
|
|
1096
1091
|
|
|
@@ -1290,7 +1285,7 @@ class ShellFrame(MiniFrame):
|
|
|
1290
1285
|
self.load_session(session or self.SESSION_FILE)
|
|
1291
1286
|
else:
|
|
1292
1287
|
self.SESSION_FILE = None
|
|
1293
|
-
|
|
1288
|
+
|
|
1294
1289
|
def load_session(self, filename):
|
|
1295
1290
|
"""Load session from file.
|
|
1296
1291
|
Buffers, pointers, and the entire layout are loaded.
|
|
@@ -1321,7 +1316,7 @@ class ShellFrame(MiniFrame):
|
|
|
1321
1316
|
## Reposition the window if it is not on the desktop.
|
|
1322
1317
|
if wx.Display.GetFromWindow(self) == -1:
|
|
1323
1318
|
self.Position = (0, 0)
|
|
1324
|
-
|
|
1319
|
+
|
|
1325
1320
|
def save_session(self):
|
|
1326
1321
|
"""Save session to file.
|
|
1327
1322
|
Buffers, pointers, and the entire layout are saved.
|
|
@@ -1360,7 +1355,7 @@ class ShellFrame(MiniFrame):
|
|
|
1360
1355
|
"self._mgr.LoadPerspective({!r})".format(self._mgr.SavePerspective()),
|
|
1361
1356
|
"self._mgr.Update()\n",
|
|
1362
1357
|
)))
|
|
1363
|
-
|
|
1358
|
+
|
|
1364
1359
|
def Init(self):
|
|
1365
1360
|
"""Initialize self-specific builtins.
|
|
1366
1361
|
Note:
|
|
@@ -1388,7 +1383,7 @@ class ShellFrame(MiniFrame):
|
|
|
1388
1383
|
builtins.profile = self.profile
|
|
1389
1384
|
builtins.highlight = self.highlight
|
|
1390
1385
|
builtins.filling = filling
|
|
1391
|
-
|
|
1386
|
+
|
|
1392
1387
|
def Destroy(self):
|
|
1393
1388
|
try:
|
|
1394
1389
|
## Remove built-in self methods
|
|
@@ -1408,13 +1403,13 @@ class ShellFrame(MiniFrame):
|
|
|
1408
1403
|
self.save_session()
|
|
1409
1404
|
self._mgr.UnInit()
|
|
1410
1405
|
return MiniFrame.Destroy(self)
|
|
1411
|
-
|
|
1406
|
+
|
|
1412
1407
|
def Close(self):
|
|
1413
1408
|
if self.__standalone:
|
|
1414
1409
|
MiniFrame.Close(self)
|
|
1415
1410
|
else:
|
|
1416
1411
|
self.Show(not self.Shown)
|
|
1417
|
-
|
|
1412
|
+
|
|
1418
1413
|
def OnClose(self, evt):
|
|
1419
1414
|
if self.debugger.busy:
|
|
1420
1415
|
if wx.MessageBox( # Confirm closing the debugger.
|
|
@@ -1452,7 +1447,7 @@ class ShellFrame(MiniFrame):
|
|
|
1452
1447
|
evt.Skip() # Close the window
|
|
1453
1448
|
else:
|
|
1454
1449
|
self.Show(0) # Don't destroy the window
|
|
1455
|
-
|
|
1450
|
+
|
|
1456
1451
|
def OnActivate(self, evt):
|
|
1457
1452
|
if not evt.Active:
|
|
1458
1453
|
## Reset autoload when active focus going outside.
|
|
@@ -1486,20 +1481,20 @@ class ShellFrame(MiniFrame):
|
|
|
1486
1481
|
if evt.Active:
|
|
1487
1482
|
self.Init()
|
|
1488
1483
|
evt.Skip()
|
|
1489
|
-
|
|
1484
|
+
|
|
1490
1485
|
def OnShow(self, evt):
|
|
1491
1486
|
for pane in self._mgr.GetAllPanes():
|
|
1492
1487
|
## When the window is hidden, disable docking and keep child panes floating.
|
|
1493
1488
|
pane.Dockable(evt.IsShown() or pane.IsDocked())
|
|
1494
1489
|
evt.Skip()
|
|
1495
|
-
|
|
1490
|
+
|
|
1496
1491
|
def OnGhostShow(self, evt):
|
|
1497
1492
|
if evt.IsShown():
|
|
1498
1493
|
self.inspector.watch()
|
|
1499
1494
|
else:
|
|
1500
1495
|
self.inspector.unwatch()
|
|
1501
1496
|
evt.Skip()
|
|
1502
|
-
|
|
1497
|
+
|
|
1503
1498
|
def OnConsolePageChanged(self, evt): #<wx._aui.AuiNotebookEvent>
|
|
1504
1499
|
nb = evt.EventObject
|
|
1505
1500
|
win = nb.CurrentPage
|
|
@@ -1509,7 +1504,7 @@ class ShellFrame(MiniFrame):
|
|
|
1509
1504
|
nb.WindowStyle |= aui.AUI_NB_CLOSE_ON_ACTIVE_TAB
|
|
1510
1505
|
nb.TabCtrlHeight = 0 if nb.PageCount == 1 else -1
|
|
1511
1506
|
evt.Skip()
|
|
1512
|
-
|
|
1507
|
+
|
|
1513
1508
|
def OnConsolePageClose(self, evt): #<wx._aui.AuiNotebookEvent>
|
|
1514
1509
|
nb = evt.EventObject
|
|
1515
1510
|
win = list(nb.get_pages())[evt.Selection]
|
|
@@ -1523,7 +1518,7 @@ class ShellFrame(MiniFrame):
|
|
|
1523
1518
|
evt.Veto()
|
|
1524
1519
|
else:
|
|
1525
1520
|
evt.Skip()
|
|
1526
|
-
|
|
1521
|
+
|
|
1527
1522
|
def About(self, evt=None):
|
|
1528
1523
|
self.add_help(
|
|
1529
1524
|
'\n\n'.join((
|
|
@@ -1543,7 +1538,7 @@ class ShellFrame(MiniFrame):
|
|
|
1543
1538
|
## f"To show the credit, press [C-M-Mbutton].", # cf. wx.InfoMessageBox(None)
|
|
1544
1539
|
))
|
|
1545
1540
|
)
|
|
1546
|
-
|
|
1541
|
+
|
|
1547
1542
|
def toggle_window(self, win):
|
|
1548
1543
|
pane = self._mgr.GetPane(win)
|
|
1549
1544
|
if pane.IsDocked():
|
|
@@ -1553,7 +1548,7 @@ class ShellFrame(MiniFrame):
|
|
|
1553
1548
|
if pane.IsShown():
|
|
1554
1549
|
pane.best_size = win.Size
|
|
1555
1550
|
self.popup_window(win, not pane.IsShown())
|
|
1556
|
-
|
|
1551
|
+
|
|
1557
1552
|
@save_focus_excursion()
|
|
1558
1553
|
def popup_window(self, win, show=True):
|
|
1559
1554
|
"""Show the notebook page and keep the focus."""
|
|
@@ -1578,11 +1573,11 @@ class ShellFrame(MiniFrame):
|
|
|
1578
1573
|
nb.Show(show)
|
|
1579
1574
|
pane.Show(show)
|
|
1580
1575
|
self._mgr.Update()
|
|
1581
|
-
|
|
1576
|
+
|
|
1582
1577
|
## --------------------------------
|
|
1583
1578
|
## Actions for handler
|
|
1584
1579
|
## --------------------------------
|
|
1585
|
-
|
|
1580
|
+
|
|
1586
1581
|
def Quit(self, evt=None):
|
|
1587
1582
|
"""Stop debugger and monitor."""
|
|
1588
1583
|
self.monitor.unwatch()
|
|
@@ -1593,7 +1588,7 @@ class ShellFrame(MiniFrame):
|
|
|
1593
1588
|
del shell.globals
|
|
1594
1589
|
self.indicator.Value = 1
|
|
1595
1590
|
self.message("Quit")
|
|
1596
|
-
|
|
1591
|
+
|
|
1597
1592
|
@save_focus_excursion()
|
|
1598
1593
|
def load(self, filename, lineno=0, show=True):
|
|
1599
1594
|
"""Load file @where the object is defined.
|
|
@@ -1618,13 +1613,13 @@ class ShellFrame(MiniFrame):
|
|
|
1618
1613
|
if ret and show:
|
|
1619
1614
|
self.popup_window(editor, show)
|
|
1620
1615
|
return ret
|
|
1621
|
-
|
|
1616
|
+
|
|
1622
1617
|
def info(self, obj):
|
|
1623
1618
|
self.rootshell.info(obj)
|
|
1624
|
-
|
|
1619
|
+
|
|
1625
1620
|
def help(self, obj):
|
|
1626
1621
|
self.rootshell.help(obj)
|
|
1627
|
-
|
|
1622
|
+
|
|
1628
1623
|
def watch(self, obj):
|
|
1629
1624
|
if isinstance(obj, wx.Object):
|
|
1630
1625
|
self.monitor.watch(obj)
|
|
@@ -1635,10 +1630,10 @@ class ShellFrame(MiniFrame):
|
|
|
1635
1630
|
self.popup_window(self.linfo)
|
|
1636
1631
|
else:
|
|
1637
1632
|
raise TypeError("primitive objects cannot be set as watch targets")
|
|
1638
|
-
|
|
1633
|
+
|
|
1639
1634
|
def highlight(self, obj, *args, **kwargs):
|
|
1640
1635
|
self.inspector.highlight(obj, *args, **kwargs)
|
|
1641
|
-
|
|
1636
|
+
|
|
1642
1637
|
def timeit(self, obj, *args, **kwargs):
|
|
1643
1638
|
"""Measure the duration cpu time (per one execution)."""
|
|
1644
1639
|
from timeit import timeit
|
|
@@ -1657,7 +1652,7 @@ class ShellFrame(MiniFrame):
|
|
|
1657
1652
|
print(e)
|
|
1658
1653
|
else:
|
|
1659
1654
|
print("- obj must be either a string or a callable.")
|
|
1660
|
-
|
|
1655
|
+
|
|
1661
1656
|
def profile(self, obj, *args, **kwargs):
|
|
1662
1657
|
"""Profile a single function call."""
|
|
1663
1658
|
from profile import Profile
|
|
@@ -1678,7 +1673,7 @@ class ShellFrame(MiniFrame):
|
|
|
1678
1673
|
print(e)
|
|
1679
1674
|
else:
|
|
1680
1675
|
print("- obj must be callable, or a string, bytes, or code object.")
|
|
1681
|
-
|
|
1676
|
+
|
|
1682
1677
|
## Note: history に余計な文字列が入らないようにする
|
|
1683
1678
|
@postcall
|
|
1684
1679
|
def debug(self, obj, *args, **kwargs):
|
|
@@ -1706,7 +1701,7 @@ class ShellFrame(MiniFrame):
|
|
|
1706
1701
|
style=wx.ICON_ERROR)
|
|
1707
1702
|
finally:
|
|
1708
1703
|
self.debugger.interactive_shell = shell
|
|
1709
|
-
|
|
1704
|
+
|
|
1710
1705
|
def on_debug_begin(self, frame):
|
|
1711
1706
|
"""Called before set_trace."""
|
|
1712
1707
|
if not self:
|
|
@@ -1722,7 +1717,7 @@ class ShellFrame(MiniFrame):
|
|
|
1722
1717
|
self.indicator.Value = 2
|
|
1723
1718
|
if wx.IsBusy():
|
|
1724
1719
|
wx.EndBusyCursor()
|
|
1725
|
-
|
|
1720
|
+
|
|
1726
1721
|
def on_debug_next(self, frame):
|
|
1727
1722
|
"""Called from cmdloop."""
|
|
1728
1723
|
if not self:
|
|
@@ -1743,7 +1738,7 @@ class ShellFrame(MiniFrame):
|
|
|
1743
1738
|
command = re.sub(r"^(.*)", r" \1", command, flags=re.M)
|
|
1744
1739
|
self.add_log(command)
|
|
1745
1740
|
self.message("Debugger is busy now (Press [C-g] to quit).")
|
|
1746
|
-
|
|
1741
|
+
|
|
1747
1742
|
def on_debug_end(self, frame):
|
|
1748
1743
|
"""Called after set_quit."""
|
|
1749
1744
|
if not self:
|
|
@@ -1760,7 +1755,7 @@ class ShellFrame(MiniFrame):
|
|
|
1760
1755
|
self.indicator.Value = 1
|
|
1761
1756
|
if wx.IsBusy():
|
|
1762
1757
|
wx.EndBusyCursor()
|
|
1763
|
-
|
|
1758
|
+
|
|
1764
1759
|
def set_hookable(self, editor, traceable=True):
|
|
1765
1760
|
"""Bind pointer to set/unset trace."""
|
|
1766
1761
|
if traceable:
|
|
@@ -1769,67 +1764,67 @@ class ShellFrame(MiniFrame):
|
|
|
1769
1764
|
else:
|
|
1770
1765
|
editor.handler.unbind('pointer_set')
|
|
1771
1766
|
editor.handler.unbind('pointer_unset')
|
|
1772
|
-
|
|
1767
|
+
|
|
1773
1768
|
def start_trace(self, line, editor):
|
|
1774
1769
|
if not self.debugger.busy:
|
|
1775
1770
|
self.debugger.unwatch()
|
|
1776
1771
|
self.debugger.editor = editor
|
|
1777
1772
|
self.debugger.watch((editor.buffer.filename, line+1))
|
|
1778
1773
|
self.debugger.send_input('') # clear input
|
|
1779
|
-
|
|
1774
|
+
|
|
1780
1775
|
def stop_trace(self, line, editor):
|
|
1781
1776
|
if self.debugger.busy:
|
|
1782
1777
|
return
|
|
1783
1778
|
if self.debugger.tracing:
|
|
1784
1779
|
self.debugger.editor = None
|
|
1785
1780
|
self.debugger.unwatch()
|
|
1786
|
-
|
|
1781
|
+
|
|
1787
1782
|
def on_trace_begin(self, frame):
|
|
1788
1783
|
"""Called when set-trace."""
|
|
1789
1784
|
self.message("Debugger has started tracing {!r}.".format(frame))
|
|
1790
1785
|
self.indicator.Value = 3
|
|
1791
|
-
|
|
1786
|
+
|
|
1792
1787
|
def on_trace_hook(self, frame):
|
|
1793
1788
|
"""Called when a breakpoint is reached."""
|
|
1794
1789
|
self.message("Debugger hooked {!r}.".format(frame))
|
|
1795
|
-
|
|
1790
|
+
|
|
1796
1791
|
def on_trace_end(self, frame):
|
|
1797
1792
|
"""Called when unset-trace."""
|
|
1798
1793
|
self.message("Debugger has stopped tracing {!r}.".format(frame))
|
|
1799
1794
|
self.indicator.Value = 1
|
|
1800
|
-
|
|
1795
|
+
|
|
1801
1796
|
def on_monitor_begin(self, widget):
|
|
1802
1797
|
"""Called when monitor watch."""
|
|
1803
1798
|
self.inspector.set_colour(widget, 'blue')
|
|
1804
1799
|
self.message("Started monitoring {!r}.".format(widget))
|
|
1805
|
-
|
|
1800
|
+
|
|
1806
1801
|
def on_monitor_end(self, widget):
|
|
1807
1802
|
"""Called when monitor unwatch."""
|
|
1808
1803
|
self.inspector.set_colour(widget, 'black')
|
|
1809
1804
|
self.message("Stopped monitoring {!r}.".format(widget))
|
|
1810
|
-
|
|
1805
|
+
|
|
1811
1806
|
def on_title_window(self, obj):
|
|
1812
1807
|
"""Set title to the frame."""
|
|
1813
1808
|
title = obj if isinstance(obj, str) else repr(obj)
|
|
1814
1809
|
self.SetTitle("Nautilus - {}".format(title))
|
|
1815
|
-
|
|
1810
|
+
|
|
1816
1811
|
def add_log(self, text, noerr=None):
|
|
1817
1812
|
"""Add text to the logging buffer.
|
|
1818
|
-
If noerr:bool is specified, add a line-
|
|
1813
|
+
If noerr:bool is specified, add a line-marker.
|
|
1819
1814
|
"""
|
|
1820
1815
|
buf = self.Log.default_buffer or self.Log.new_buffer()
|
|
1821
1816
|
with buf.off_readonly():
|
|
1822
|
-
buf.goto_char(buf.TextLength) # line to set an arrow
|
|
1817
|
+
buf.goto_char(buf.TextLength) # line to set an arrow marker
|
|
1823
1818
|
buf.write(text)
|
|
1824
1819
|
if noerr is not None:
|
|
1825
|
-
## Set a
|
|
1820
|
+
## Set a marker on the current line.
|
|
1826
1821
|
buf.add_marker(buf.cline, 1 if noerr else 2) # 1:white 2:red-arrow
|
|
1827
1822
|
return
|
|
1828
1823
|
|
|
1829
1824
|
## Logging text every step in case of crash.
|
|
1830
1825
|
## with open(self.LOGGING_FILE, 'a', encoding='utf-8', newline='') as o:
|
|
1831
1826
|
## o.write(text)
|
|
1832
|
-
|
|
1827
|
+
|
|
1833
1828
|
def add_help(self, text, title=None):
|
|
1834
1829
|
"""Add text to the help buffer.
|
|
1835
1830
|
If title:str is specified, create a new buffer with that title.
|
|
@@ -1845,7 +1840,7 @@ class ShellFrame(MiniFrame):
|
|
|
1845
1840
|
## Overwrite text and popup the window.
|
|
1846
1841
|
self.popup_window(self.Help)
|
|
1847
1842
|
self.Help.swap_page(buf)
|
|
1848
|
-
|
|
1843
|
+
|
|
1849
1844
|
def clone_shell(self, target):
|
|
1850
1845
|
if not hasattr(target, '__dict__'):
|
|
1851
1846
|
raise TypeError("primitive objects cannot be targeted")
|
|
@@ -1861,7 +1856,7 @@ class ShellFrame(MiniFrame):
|
|
|
1861
1856
|
self.Show()
|
|
1862
1857
|
shell.SetFocus()
|
|
1863
1858
|
return shell
|
|
1864
|
-
|
|
1859
|
+
|
|
1865
1860
|
def delete_shell(self, shell):
|
|
1866
1861
|
"""Close the current shell."""
|
|
1867
1862
|
if shell is self.rootshell:
|
|
@@ -1874,16 +1869,16 @@ class ShellFrame(MiniFrame):
|
|
|
1874
1869
|
j = self.console.GetPageIndex(shell)
|
|
1875
1870
|
if j != -1:
|
|
1876
1871
|
self.console.DeletePage(j) # Destroy the window
|
|
1877
|
-
|
|
1872
|
+
|
|
1878
1873
|
## --------------------------------
|
|
1879
1874
|
## Attributes for notebook pages
|
|
1880
1875
|
## --------------------------------
|
|
1881
|
-
|
|
1876
|
+
|
|
1882
1877
|
def get_all_pages(self, type=None):
|
|
1883
1878
|
"""Yields all pages of the specified type in the notebooks."""
|
|
1884
1879
|
yield from self.console.get_pages(type)
|
|
1885
1880
|
yield from self.ghost.get_pages(type)
|
|
1886
|
-
|
|
1881
|
+
|
|
1887
1882
|
def get_all_shells(self, target=None):
|
|
1888
1883
|
"""Yields all shells with specified target.
|
|
1889
1884
|
|
|
@@ -1897,7 +1892,7 @@ class ShellFrame(MiniFrame):
|
|
|
1897
1892
|
if shell.target is target:
|
|
1898
1893
|
self.console.swap_page(shell)
|
|
1899
1894
|
yield shell
|
|
1900
|
-
|
|
1895
|
+
|
|
1901
1896
|
def get_all_editors(self, fn=None):
|
|
1902
1897
|
"""Yields all editors with specified fn:filename or code.
|
|
1903
1898
|
|
|
@@ -1912,12 +1907,12 @@ class ShellFrame(MiniFrame):
|
|
|
1912
1907
|
if buf:
|
|
1913
1908
|
book.swap_page(buf)
|
|
1914
1909
|
yield book
|
|
1915
|
-
|
|
1910
|
+
|
|
1916
1911
|
@property
|
|
1917
1912
|
def current_shell(self):
|
|
1918
1913
|
"""Currently selected shell or rootshell."""
|
|
1919
1914
|
return self.console.CurrentPage
|
|
1920
|
-
|
|
1915
|
+
|
|
1921
1916
|
@property
|
|
1922
1917
|
def current_editor(self):
|
|
1923
1918
|
"""Currently selected editor or scratch."""
|
|
@@ -1925,7 +1920,7 @@ class ShellFrame(MiniFrame):
|
|
|
1925
1920
|
if isinstance(editor, type(self.Log)):
|
|
1926
1921
|
return editor
|
|
1927
1922
|
return next((book for book in self.get_all_editors() if book.IsShown()), self.Scratch)
|
|
1928
|
-
|
|
1923
|
+
|
|
1929
1924
|
def create_editor(self, bookname):
|
|
1930
1925
|
"""Create a new editor (internal use only)..
|
|
1931
1926
|
If such an editor already exists, no new editor is created.
|
|
@@ -1943,14 +1938,14 @@ class ShellFrame(MiniFrame):
|
|
|
1943
1938
|
self.Bookshelf.build_tree(clear=0)
|
|
1944
1939
|
wx.CallAfter(_attach)
|
|
1945
1940
|
return editor
|
|
1946
|
-
|
|
1941
|
+
|
|
1947
1942
|
## --------------------------------
|
|
1948
1943
|
## Find / Replace text dialog
|
|
1949
1944
|
## --------------------------------
|
|
1950
1945
|
## *** The following code is a modification of <wx.py.frame.Frame> ***
|
|
1951
|
-
|
|
1946
|
+
|
|
1952
1947
|
__find_target = None
|
|
1953
|
-
|
|
1948
|
+
|
|
1954
1949
|
def on_search_dialog(self, evt, flags=0):
|
|
1955
1950
|
if self.findDlg is not None:
|
|
1956
1951
|
self.findDlg.SetFocus()
|
|
@@ -1966,16 +1961,16 @@ class ShellFrame(MiniFrame):
|
|
|
1966
1961
|
self.findData.Flags |= wx.FR_DOWN
|
|
1967
1962
|
self.findDlg = wx.FindReplaceDialog(wnd, self.findData, "Find", flags)
|
|
1968
1963
|
self.findDlg.Show()
|
|
1969
|
-
|
|
1964
|
+
|
|
1970
1965
|
def on_replace_dialog(self, evt):
|
|
1971
1966
|
self.on_search_dialog(evt, flags=wx.FR_REPLACEDIALOG)
|
|
1972
|
-
|
|
1967
|
+
|
|
1973
1968
|
def repeat_forward_search(self, evt):
|
|
1974
1969
|
self.OnFindNext(evt, backward=False)
|
|
1975
|
-
|
|
1970
|
+
|
|
1976
1971
|
def repeat_backward_search(self, evt):
|
|
1977
1972
|
self.OnFindNext(evt, backward=True)
|
|
1978
|
-
|
|
1973
|
+
|
|
1979
1974
|
def OnFindNext(self, evt, backward=None): #<wx._core.FindDialogEvent>
|
|
1980
1975
|
if not self.findData.FindString:
|
|
1981
1976
|
self.message("No last search.")
|
|
@@ -2006,7 +2001,7 @@ class ShellFrame(MiniFrame):
|
|
|
2006
2001
|
self.OnFindClose(None)
|
|
2007
2002
|
if loc < 0:
|
|
2008
2003
|
self.message("Unable to find the search text.")
|
|
2009
|
-
|
|
2004
|
+
|
|
2010
2005
|
def OnFindClose(self, evt): #<wx._core.FindDialogEvent>
|
|
2011
2006
|
self.findDlg.Destroy()
|
|
2012
2007
|
self.findDlg = None
|