mwxlib 0.90.0__py3-none-any.whl → 0.90.3__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
@@ -4,7 +4,7 @@
4
4
 
5
5
  Author: Kazuya O'moto <komoto@jeol.co.jp>
6
6
  """
7
- __version__ = "0.90.0"
7
+ __version__ = "0.90.3"
8
8
  __author__ = "Kazuya O'moto <komoto@jeol.co.jp>"
9
9
 
10
10
  from functools import wraps, partial
@@ -47,17 +47,6 @@ def postcall(f):
47
47
  return _f
48
48
 
49
49
 
50
- def deprecated(item=None, msg='', useName=False):
51
- """A decorator of wx.deprecated."""
52
- if item is None:
53
- return lambda f: deprecated(f, msg, useName)
54
- return wx.deprecated(item, msg, useName)
55
-
56
-
57
- def skip(v):
58
- v.Skip()
59
-
60
-
61
50
  _speckeys = {
62
51
  wx.WXK_ALT : 'alt',
63
52
  wx.WXK_BACK : 'backspace',
@@ -1153,7 +1142,9 @@ class ShellFrame(MiniFrame):
1153
1142
  evt.Skip()
1154
1143
  self.Bind(wx.EVT_SIZE, on_size)
1155
1144
 
1156
- def skip(v):
1145
+ def dispatch(v):
1146
+ """Fork key events to the debugger."""
1147
+ self.debugger.handler(self.handler.current_event, v)
1157
1148
  if self.debugger.handler.current_state:
1158
1149
  if self.debugger.tracing:
1159
1150
  self.message("Current status is tracing. Press [C-g] to quit.")
@@ -1162,10 +1153,6 @@ class ShellFrame(MiniFrame):
1162
1153
  self.indicator.Value = 7
1163
1154
  v.Skip()
1164
1155
 
1165
- def dispatch(v):
1166
- """Fork key events to the debugger."""
1167
- self.debugger.handler(self.handler.current_event, v)
1168
-
1169
1156
  self.handler.update({ # DNA<ShellFrame>
1170
1157
  None : {
1171
1158
  'debug_begin' : [ None, self.on_debug_begin ],
@@ -1183,9 +1170,9 @@ class ShellFrame(MiniFrame):
1183
1170
  'buffer_caption_reset' : [ None, self.on_buffer_caption ],
1184
1171
  },
1185
1172
  0 : {
1186
- '* pressed' : (0, skip, dispatch), # => debugger
1187
- '* released' : (0, skip, dispatch), # => debugger
1188
- 'C-g pressed' : (0, self.Quit, skip, dispatch), # => debugger
1173
+ '* pressed' : (0, dispatch), # => debugger
1174
+ '* released' : (0, dispatch), # => debugger
1175
+ 'C-g pressed' : (0, self.Quit, dispatch), # => debugger
1189
1176
  'f1 pressed' : (0, self.About),
1190
1177
  'C-f pressed' : (0, self.OnFindText),
1191
1178
  'f3 pressed' : (0, self.OnFindNext),
@@ -1194,8 +1181,6 @@ class ShellFrame(MiniFrame):
1194
1181
  'S-f11 pressed' : (0, _F(self.toggle_window, self.watcher, doc="Toggle watcher")),
1195
1182
  'f12 pressed' : (0, _F(self.Close, alias="close", doc="Close the window")),
1196
1183
  '*f[0-9]* pressed' : (0, ),
1197
- 'M-left pressed' : (0, _F(self.other_window, p=-1)),
1198
- 'M-right pressed' : (0, _F(self.other_window, p=+1)),
1199
1184
  },
1200
1185
  })
1201
1186
 
@@ -1205,11 +1190,13 @@ class ShellFrame(MiniFrame):
1205
1190
  self.set_hookable(self.Scratch)
1206
1191
 
1207
1192
  @self.Scratch.define_key('C-j')
1193
+ @postcall
1208
1194
  def eval_line():
1209
1195
  shell = self.current_shell
1210
1196
  self.Scratch.buffer.py_eval_line(shell.globals, shell.locals)
1211
1197
 
1212
1198
  @self.Scratch.define_key('M-j')
1199
+ @postcall
1213
1200
  def exec_buffer():
1214
1201
  shell = self.current_shell
1215
1202
  self.Scratch.buffer.py_exec_region(shell.globals, shell.locals)
@@ -1746,7 +1733,6 @@ class ShellFrame(MiniFrame):
1746
1733
  self.debugger.editor = book
1747
1734
  self.debugger.watch((book.buffer.filename, line+1))
1748
1735
  self.debugger.send_input('') # clear input
1749
- book.buffer.del_marker(4)
1750
1736
 
1751
1737
  def stop_trace(self, line, book):
1752
1738
  if self.debugger.busy:
@@ -1754,7 +1740,6 @@ class ShellFrame(MiniFrame):
1754
1740
  if self.debugger.tracing:
1755
1741
  self.debugger.editor = None
1756
1742
  self.debugger.unwatch()
1757
- book.buffer.set_marker(line, 4)
1758
1743
 
1759
1744
  def on_trace_begin(self, frame):
1760
1745
  """Called when set-trace."""
@@ -1817,20 +1802,6 @@ class ShellFrame(MiniFrame):
1817
1802
  self.popup_window(self.Help, focus=0)
1818
1803
  self.Help.swap_page(buf)
1819
1804
 
1820
- def other_window(self, p=1):
1821
- "Move focus to other window"
1822
- pages = [x for x in self.get_all_pages() if x.IsShownOnScreen()]
1823
- wnd = wx.Window.FindFocus()
1824
- while wnd:
1825
- if wnd in pages:
1826
- j = (pages.index(wnd) + p) % len(pages)
1827
- obj = pages[j]
1828
- if isinstance(obj, aui.AuiNotebook):
1829
- obj = obj.CurrentPage
1830
- obj.SetFocus()
1831
- break
1832
- wnd = wnd.Parent
1833
-
1834
1805
  def clone_shell(self, target):
1835
1806
  if not hasattr(target, '__dict__'):
1836
1807
  raise TypeError("primitive objects cannot be targeted")
@@ -1917,79 +1888,6 @@ class ShellFrame(MiniFrame):
1917
1888
  self.findDlg = None
1918
1889
 
1919
1890
 
1920
- ## Monkey-patch for wx.core
1921
- try:
1922
- from wx import core # PY3
1923
-
1924
- def _EvtHandler_Bind(self, event, handler=None, source=None, id=wx.ID_ANY, id2=wx.ID_ANY):
1925
- """
1926
- Bind an event to an event handler.
1927
- (override) Record the handler in the list and return the handler.
1928
- """
1929
- if handler is None:
1930
- return lambda f: _EvtHandler_Bind(self, event, f, source, id, id2)
1931
-
1932
- assert isinstance(event, wx.PyEventBinder)
1933
- assert callable(handler) or handler is None
1934
- assert source is None or hasattr(source, 'GetId')
1935
- if source is not None:
1936
- id = source.GetId()
1937
- event.Bind(self, id, id2, handler)
1938
-
1939
- ## Record all handlers.
1940
- try:
1941
- vmap = self.__event_handler__
1942
- except AttributeError:
1943
- vmap = self.__event_handler__ = {}
1944
- try:
1945
- vmap[event.typeId].insert(0, (id, handler))
1946
- except KeyError:
1947
- vmap[event.typeId] = [(id, handler)]
1948
- return handler
1949
-
1950
- core.EvtHandler.Bind = _EvtHandler_Bind
1951
- ## del _EvtHandler_Bind
1952
-
1953
- def _EvtHandler_Unbind(self, event, source=None, id=wx.ID_ANY, id2=wx.ID_ANY, handler=None):
1954
- """
1955
- Disconnects the event handler binding for event from `self`.
1956
- Returns ``True`` if successful.
1957
- (override) Delete the handler from the list.
1958
- """
1959
- if source is not None:
1960
- id = source.GetId()
1961
- retval = event.Unbind(self, id, id2, handler)
1962
-
1963
- ## Remove the specified handler or all handlers.
1964
- if retval:
1965
- try:
1966
- vmap = self.__event_handler__
1967
- except AttributeError:
1968
- return retval
1969
- try:
1970
- handlers = vmap[event.typeId]
1971
- if handler or id != wx.ID_ANY:
1972
- for v in handlers.copy():
1973
- if v[0] == id or v[1] == handler:
1974
- handlers.remove(v)
1975
- else:
1976
- handlers.pop(0) # No optional arguments are specified.
1977
- if not handlers:
1978
- del vmap[event.typeId]
1979
- except KeyError:
1980
- pass # Note: vmap is actually inconsistent, but ignored.
1981
- return retval
1982
-
1983
- core.EvtHandler.Unbind = _EvtHandler_Unbind
1984
- ## del _EvtHandler_Unbind
1985
-
1986
- del core
1987
-
1988
- except ImportError as e:
1989
- print(e)
1990
- pass
1991
-
1992
-
1993
1891
  def filling(obj=None, **kwargs):
1994
1892
  """Wx.py tool for watching widget ingredients."""
1995
1893
  from .py.filling import FillingFrame
mwx/nutshell.py CHANGED
@@ -7,6 +7,7 @@ Author: Kazuya O'moto <komoto@jeol.co.jp>
7
7
  from functools import wraps
8
8
  from importlib import import_module
9
9
  from pprint import pformat
10
+ from bdb import BdbQuit
10
11
  import traceback
11
12
  import warnings
12
13
  import inspect
@@ -35,14 +36,19 @@ from .framework import CtrlInterface, AuiNotebook, Menu
35
36
  ## URL pattern (flag = re.M | re.A)
36
37
  url_re = r"https?://[\w/:%#$&?()~.=+-]+"
37
38
 
39
+ ## no-file pattern
40
+ nofile_re = r'[\/:*?"<>|]'
41
+
38
42
  ## Python syntax pattern
39
43
  py_indent_re = r"if|else|elif|for|while|with|def|class|try|except|finally"
40
44
  py_outdent_re = r"else:|elif\s+.*:|except(\s+.*)?:|finally:"
41
45
  py_closing_re = r"break|pass|return|raise|continue"
42
46
 
43
47
  ## Python interp traceback pattern
44
- py_error_re = r'^ +File "(.*?)", line ([0-9]+)'
45
- py_frame_re = r"^ +file '(.*?)', line ([0-9]+)"
48
+ py_error_re = r' +File "(.*?)", line ([0-9]+)'
49
+ py_frame_re = r" +file '(.*?)', line ([0-9]+)"
50
+ py_where_re = r'> +([^*?"<>|\r\n]+?):([0-9]+)'
51
+ py_break_re = r'at ([^*?"<>|\r\n]+?):([0-9]+)'
46
52
 
47
53
 
48
54
  def skip(v):
@@ -111,7 +117,7 @@ class EditorInterface(CtrlInterface):
111
117
  'C-t pressed' : (0, ), # overrides transpose-line
112
118
  'C-S-f pressed' : (0, _F(self.set_mark)), # overrides mark
113
119
  'C-space pressed' : (0, _F(self.set_mark)),
114
- 'C-S-space pressed' : (0, _F(self.set_pointer)),
120
+ 'S-space pressed' : (0, _F(self.set_pointer)),
115
121
  'C-backspace pressed' : (0, skip),
116
122
  'S-backspace pressed' : (0, _F(self.backward_kill_line)),
117
123
  'C-tab pressed' : (0, _F(self.insert_space_like_tab)),
@@ -376,6 +382,11 @@ class EditorInterface(CtrlInterface):
376
382
  lambda self,v: self.set_marker(v, 3), # [pointer_set]
377
383
  lambda self: self.del_marker(3)) # [pointer_unset]
378
384
 
385
+ red_pointer = property(
386
+ lambda self: self.get_marker(4),
387
+ lambda self,v: self.set_marker(v, 4), # [red-pointer_set]
388
+ lambda self: self.del_marker(4)) # [red-pointer_unset]
389
+
379
390
  @property
380
391
  def markline(self):
381
392
  return self.MarkerNext(0, 1<<0)
@@ -416,9 +427,10 @@ class EditorInterface(CtrlInterface):
416
427
 
417
428
  def set_pointer(self):
418
429
  if self.pointer == self.cline:
419
- self.pointer = -1 # toggle marker
430
+ self.pointer = -1
420
431
  else:
421
432
  self.pointer = self.cline
433
+ self.red_pointer = -1
422
434
 
423
435
  def exchange_point_and_mark(self):
424
436
  p = self.cpos
@@ -607,9 +619,7 @@ class EditorInterface(CtrlInterface):
607
619
 
608
620
  def py_electric_indent(self):
609
621
  """Calculate indent spaces for the following line."""
610
- ## Note:
611
- ## The last char is replaced with b'\x00'.
612
- ## It looks like a bug in wx.stc.
622
+ ## [BUG 4.2.0] The last char is replaced with b'\x00'.
613
623
  ## text, lp = self.CurLineRaw
614
624
  ## return self.py_calc_indentation(text[:lp].decode())
615
625
  text, lp = self.CurLine
@@ -1609,7 +1619,7 @@ class Buffer(EditWindow, EditorInterface):
1609
1619
  ## Python eval / exec
1610
1620
  ## --------------------------------
1611
1621
 
1612
- def py_eval_line(self, globals, locals):
1622
+ def py_eval_line(self, globals=None, locals=None):
1613
1623
  if self.CallTipActive():
1614
1624
  self.CallTipCancel()
1615
1625
 
@@ -1633,7 +1643,7 @@ class Buffer(EditWindow, EditorInterface):
1633
1643
  return
1634
1644
  self.message(status)
1635
1645
 
1636
- def py_exec_region(self, globals, locals, filename=None):
1646
+ def py_exec_region(self, globals=None, locals=None, filename=None):
1637
1647
  if not filename:
1638
1648
  filename = self.filename
1639
1649
  try:
@@ -1641,6 +1651,9 @@ class Buffer(EditWindow, EditorInterface):
1641
1651
  exec(code, globals, locals)
1642
1652
  dispatcher.send(signal='Interpreter.push',
1643
1653
  sender=self, command=None, more=False)
1654
+ except BdbQuit:
1655
+ self.red_pointer = self.cline
1656
+ pass
1644
1657
  except Exception as e:
1645
1658
  msg = traceback.format_exc()
1646
1659
  err = re.findall(py_error_re, msg, re.M)
@@ -1653,7 +1666,7 @@ class Buffer(EditWindow, EditorInterface):
1653
1666
  self.EnsureCaretVisible()
1654
1667
  self.AnnotationSetStyle(lx, stc.STC_STYLE_ANNOTATION)
1655
1668
  self.AnnotationSetText(lx, msg)
1656
- self.message("- {!r}".format(e))
1669
+ self.message("- {}".format(e))
1657
1670
  ## print(msg, file=sys.__stderr__)
1658
1671
  else:
1659
1672
  self.code = code
@@ -2263,7 +2276,7 @@ class Nautilus(Shell, EditorInterface):
2263
2276
  obj.this = inspect.getmodule(obj)
2264
2277
  obj.shell = self # overwrite the facade <wx.py.shell.ShellFacade>
2265
2278
  except AttributeError:
2266
- ## print("- cannot overwrite target vars: {!r}".format(e))
2279
+ ## print("- cannot overwrite target vars: {}".format(e))
2267
2280
  pass
2268
2281
  self.parent.handler('title_window', obj)
2269
2282
 
@@ -2716,6 +2729,7 @@ class Nautilus(Shell, EditorInterface):
2716
2729
  self.goto_char(self.eolc)
2717
2730
  self.promptPosEnd = 0
2718
2731
  self.prompt()
2732
+ self.AnnotationClearAll()
2719
2733
 
2720
2734
  def on_enter_notemode(self, evt):
2721
2735
  self.noteMode = True
@@ -2935,12 +2949,6 @@ class Nautilus(Shell, EditorInterface):
2935
2949
  """Full command-(multi-)line (excluding ps1:prompt)."""
2936
2950
  return self.GetTextRange(self.bolc, self.eolc)
2937
2951
 
2938
- def cmdline_atoms(self):
2939
- q = self.bolc
2940
- while q < self.eolc:
2941
- p, q, st = self.get_following_atom(q)
2942
- yield self.GetTextRange(p, q)
2943
-
2944
2952
  @property
2945
2953
  def cmdline_region(self):
2946
2954
  lc = self.LineFromPosition(self.bolc)
@@ -2997,17 +3005,14 @@ class Nautilus(Shell, EditorInterface):
2997
3005
 
2998
3006
  (override) Mark points before push.
2999
3007
  """
3000
- try:
3001
- self.on_text_input(command)
3002
- except AttributeError:
3003
- pass
3008
+ self.on_text_input(command)
3004
3009
  Shell.push(self, command, **kwargs)
3005
3010
 
3006
3011
  def addHistory(self, command):
3007
3012
  """Add command to the command history.
3008
3013
 
3009
- (override) If the command is new (i.e., not found in the head of the list).
3010
- Then, write the command to the logging buffer.
3014
+ (override) If the command is not found at the head of the list,
3015
+ write the command to the logging buffer.
3011
3016
  """
3012
3017
  if not command:
3013
3018
  return
@@ -3026,6 +3031,7 @@ class Nautilus(Shell, EditorInterface):
3026
3031
  if noerr:
3027
3032
  words = re.findall(r"\b[a-zA-Z_][\w.]+", input + output)
3028
3033
  self.fragmwords |= set(words)
3034
+ command = self.fixLineEndings(command)
3029
3035
  self.parent.handler('add_log', command + os.linesep, noerr)
3030
3036
  except AttributeError:
3031
3037
  ## execStartupScript 実行時は出力先 (owner) が存在しない
@@ -3035,8 +3041,8 @@ class Nautilus(Shell, EditorInterface):
3035
3041
  def execStartupScript(self, su):
3036
3042
  """Execute the user's PYTHONSTARTUP script if they have one.
3037
3043
 
3038
- (override) Add globals when executing su:startupScript
3039
- Fix history point
3044
+ (override) Add globals when executing su:startupScript.
3045
+ Fix history point.
3040
3046
  """
3041
3047
  ## self.globals = self.locals
3042
3048
  self.promptPosEnd = self.TextLength # fix history point
@@ -3059,25 +3065,28 @@ class Nautilus(Shell, EditorInterface):
3059
3065
  if self.CanPaste() and wx.TheClipboard.Open():
3060
3066
  data = wx.TextDataObject()
3061
3067
  if wx.TheClipboard.GetData(data):
3062
- text = data.GetText()
3063
- command = text.rstrip()
3064
- endl = text[len(command):] # the rest whitespace
3068
+ command = data.GetText()
3069
+ ## command = command.rstrip()
3065
3070
  command = self.fixLineEndings(command)
3066
3071
  command = self.regulate_cmd(command)
3067
3072
  ps = sys.ps2
3068
- if self.cpos == self.eolc: # caret at the end of the buffer
3069
- endl = endl.replace('\n', os.linesep + ps)
3070
3073
  _text, lp = self.CurLine
3071
3074
  if rectangle:
3072
3075
  ps += ' ' * (lp - len(ps)) # add offset
3073
3076
  if lp == 0:
3074
3077
  command = ps + command # paste-line
3075
3078
  command = command.replace('\n', os.linesep + ps)
3076
- self.ReplaceSelection(command + endl)
3079
+ self.ReplaceSelection(command)
3077
3080
  wx.TheClipboard.Close()
3078
3081
 
3079
3082
  def regulate_cmd(self, text):
3080
- """Regulate text to executable command."""
3083
+ """Regulate text to executable command.
3084
+
3085
+ cf. Execute
3086
+ Note:
3087
+ The eol-code (cr/lf) is not fixed.
3088
+ Call self.fixLineEndings in advance as necessary.
3089
+ """
3081
3090
  text = self.lstripPrompt(text) # strip a leading prompt
3082
3091
  lf = '\n'
3083
3092
  return (text.replace(os.linesep + sys.ps1, lf)
@@ -3130,11 +3139,20 @@ class Nautilus(Shell, EditorInterface):
3130
3139
  sender=self, command=None, more=False)
3131
3140
 
3132
3141
  def exec_cmdline(self):
3133
- """Execute command-line directly."""
3142
+ """Execute command-line directly.
3143
+
3144
+ cf. Execute
3145
+ """
3146
+ def _cmdline_atoms():
3147
+ q = self.bolc
3148
+ while q < self.eolc:
3149
+ p, q, st = self.get_following_atom(q)
3150
+ yield self.GetTextRange(p, q)
3151
+
3134
3152
  commands = []
3135
3153
  cmd = ''
3136
3154
  lines = ''
3137
- for atom in self.cmdline_atoms():
3155
+ for atom in _cmdline_atoms():
3138
3156
  lines += atom
3139
3157
  if atom[0] not in '\r\n':
3140
3158
  continue
@@ -3172,41 +3190,6 @@ class Nautilus(Shell, EditorInterface):
3172
3190
  self.write(cmd)
3173
3191
  self.processLine()
3174
3192
 
3175
- def Execute(self, text):
3176
- """Replace selection with text and run commands.
3177
-
3178
- (override) Patch `finally` miss-indentation
3179
- """
3180
- command = self.regulate_cmd(text)
3181
- commands = []
3182
- cmd = ''
3183
- for line in command.splitlines():
3184
- lstr = line.lstrip()
3185
- if (lstr and lstr == line # no indent
3186
- and not lstr.startswith('#') # no comment
3187
- and not re.match(py_outdent_re, lstr)): # no outdent pattern
3188
- if cmd:
3189
- commands.append(cmd) # Add the previous command to the list
3190
- cmd = line
3191
- else:
3192
- cmd += '\n' + line # Multiline command; Add to the command
3193
- commands.append(cmd)
3194
-
3195
- self.Replace(self.bolc, self.eolc, '')
3196
- for cmd in commands:
3197
- self.write(cmd.replace('\n', os.linesep + sys.ps2))
3198
- self.processLine()
3199
-
3200
- def run(self, command, prompt=True, verbose=True):
3201
- """Execute command as if it was typed in directly.
3202
-
3203
- (override) Set interp.more False to clear `commandBuffer`.
3204
- Deselect and move to the end of the command line.
3205
- """
3206
- self.interp.more = False
3207
- self.goto_char(self.eolc)
3208
- return Shell.run(self, command, prompt, verbose)
3209
-
3210
3193
  ## --------------------------------
3211
3194
  ## Autocomp actions of the shell
3212
3195
  ## --------------------------------
@@ -3295,7 +3278,7 @@ class Nautilus(Shell, EditorInterface):
3295
3278
  if lines:
3296
3279
  region = self.get_region(self.cline)
3297
3280
  self.pointer = region[0] + lines[-1] - 1
3298
- self.message("- {!r}".format(e))
3281
+ self.message("- {}".format(e))
3299
3282
  ## print(msg, file=sys.__stderr__)
3300
3283
  else:
3301
3284
  del self.pointer
mwx/wxmon.py CHANGED
@@ -53,10 +53,10 @@ class EventMonitor(CheckList, ListCtrlAutoWidthMixin, CtrlInterface):
53
53
 
54
54
  self.parent = parent
55
55
  self.target = None
56
+ self._target = None # previous target
56
57
 
57
58
  self.Font = wx.Font(9, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
58
59
 
59
- self.__prev = None
60
60
  self.__dir = True # sort direction
61
61
  self.__items = []
62
62
 
@@ -128,13 +128,14 @@ class EventMonitor(CheckList, ListCtrlAutoWidthMixin, CtrlInterface):
128
128
  self.clear()
129
129
  self.unwatch()
130
130
  if widget is None:
131
- widget = self.__prev # Restart
131
+ widget = self._target # Resume watching the previous target.
132
132
  if not widget:
133
133
  return
134
134
  if not isinstance(widget, wx.Object):
135
135
  wx.MessageBox("Cannot watch the widget.\n\n"
136
136
  "- {!r} is not a wx.Object.".format(widget))
137
137
  return
138
+ self._target = widget
138
139
  self.target = widget
139
140
  ssmap = self.dump(widget, verbose=0)
140
141
  for binder in self.get_watchlist():
@@ -158,7 +159,6 @@ class EventMonitor(CheckList, ListCtrlAutoWidthMixin, CtrlInterface):
158
159
  if not widget.Unbind(binder, handler=self.onWatchedEvent):
159
160
  print("- Failed to unbind {}: {}".format(binder.typeId, widget))
160
161
  self.parent.handler('monitor_end', widget)
161
- self.__prev = widget
162
162
  self.target = None
163
163
 
164
164
  def onWatchedEvent(self, evt):
@@ -297,7 +297,7 @@ class EventMonitor(CheckList, ListCtrlAutoWidthMixin, CtrlInterface):
297
297
 
298
298
  def OnContextMenu(self, evt):
299
299
  obj = self.target
300
- wnd = self.__prev
300
+ wnd = self._target
301
301
  menu = [
302
302
  (1, "Copy data", Icon('copy'),
303
303
  lambda v: self.copy(),
@@ -322,3 +322,76 @@ def monit(widget=None, **kwargs):
322
322
  ew.watch(widget)
323
323
  ew.Show()
324
324
  return ew
325
+
326
+
327
+ ## Monkey-patch for wx.core (to be deprecated)
328
+ try:
329
+ from wx import core # PY3
330
+
331
+ def _EvtHandler_Bind(self, event, handler=None, source=None, id=wx.ID_ANY, id2=wx.ID_ANY):
332
+ """
333
+ Bind an event to an event handler.
334
+ (override) Record the handler in the list and return the handler.
335
+ """
336
+ if handler is None:
337
+ return lambda f: _EvtHandler_Bind(self, event, f, source, id, id2)
338
+
339
+ assert isinstance(event, wx.PyEventBinder)
340
+ assert callable(handler) or handler is None
341
+ assert source is None or hasattr(source, 'GetId')
342
+ if source is not None:
343
+ id = source.GetId()
344
+ event.Bind(self, id, id2, handler)
345
+
346
+ ## Record all handlers.
347
+ try:
348
+ vmap = self.__event_handler__
349
+ except AttributeError:
350
+ vmap = self.__event_handler__ = {}
351
+ try:
352
+ vmap[event.typeId].insert(0, (id, handler))
353
+ except KeyError:
354
+ vmap[event.typeId] = [(id, handler)]
355
+ return handler
356
+
357
+ core.EvtHandler.Bind = _EvtHandler_Bind
358
+ ## del _EvtHandler_Bind
359
+
360
+ def _EvtHandler_Unbind(self, event, source=None, id=wx.ID_ANY, id2=wx.ID_ANY, handler=None):
361
+ """
362
+ Disconnects the event handler binding for event from `self`.
363
+ Returns ``True`` if successful.
364
+ (override) Delete the handler from the list.
365
+ """
366
+ if source is not None:
367
+ id = source.GetId()
368
+ retval = event.Unbind(self, id, id2, handler)
369
+
370
+ ## Remove the specified handler or all handlers.
371
+ if retval:
372
+ try:
373
+ vmap = self.__event_handler__
374
+ except AttributeError:
375
+ return retval
376
+ try:
377
+ handlers = vmap[event.typeId]
378
+ if handler or id != wx.ID_ANY:
379
+ for v in handlers.copy():
380
+ if v[0] == id or v[1] == handler:
381
+ handlers.remove(v)
382
+ else:
383
+ handlers.pop(0) # No optional arguments are specified.
384
+ if not handlers:
385
+ del vmap[event.typeId]
386
+ except KeyError:
387
+ pass # Note: vmap is actually inconsistent, but ignored.
388
+ return retval
389
+
390
+ core.EvtHandler.Unbind = _EvtHandler_Unbind
391
+ ## del _EvtHandler_Unbind
392
+
393
+ del core
394
+
395
+ except ImportError as e:
396
+ print(e)
397
+ pass
mwx/wxpdb.py CHANGED
@@ -370,7 +370,7 @@ class Debugger(Pdb):
370
370
  """
371
371
  if self.editor:
372
372
  del self.editor.buffer.pointer
373
- self.editor = None
373
+ self.editor = None
374
374
  self.code = None
375
375
 
376
376
  ## Note: Required to terminate the reader of threading pdb.
mwx/wxwit.py CHANGED
@@ -134,14 +134,6 @@ class Inspector(it.InspectionTree, CtrlInterface):
134
134
  self.target = None
135
135
  self.timer.Stop()
136
136
 
137
- def addref(self, obj, ref='obj'):
138
- shell = self.parent.current_shell
139
- if shell is not obj:
140
- shell.locals[ref] = obj
141
- self.parent.message("self.{} -> {!r}".format(ref, obj))
142
- shell.SetFocus()
143
- return shell
144
-
145
137
  ## --------------------------------
146
138
  ## Actions on tree items
147
139
  ## --------------------------------
@@ -177,16 +169,13 @@ class Inspector(it.InspectionTree, CtrlInterface):
177
169
  valid = (obj is not None)
178
170
  menu = [
179
171
  (1, "&Dive into the shell", Icon('core'),
180
- lambda v: self.parent.clone_shell(obj),
172
+ lambda v: dive(obj),
181
173
  lambda v: v.Enable(valid)),
182
174
 
183
175
  (2, "&Watch the event", Icon('ghost'),
184
- lambda v: self.parent.debug(obj),
176
+ lambda v: debug(obj),
185
177
  lambda v: v.Enable(valid)),
186
178
 
187
- (3, "&Add reference", Icon('tag'),
188
- lambda v: self.addref(obj),
189
- lambda v: v.Enable(valid)),
190
179
  (),
191
180
  (8, "&Filling View", miniIcon('ShowFilling'),
192
181
  lambda v: filling(obj),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mwxlib
3
- Version: 0.90.0
3
+ Version: 0.90.3
4
4
  Summary: A wrapper of matplotlib and wxPython (phoenix)
5
5
  Home-page: https://github.com/komoto48g/mwxlib
6
6
  Author: Kazuya O'moto <komoto@jeol.co.jp>
@@ -1,22 +1,22 @@
1
1
  mwx/__init__.py,sha256=6pnXWrbO-_yuceMClYg0GKpZB5W1DPUPerhjUm4bIXM,2423
2
2
  mwx/controls.py,sha256=6Zin21RWN_yQ7v8FQQjksvJux7Bbi8opMFq1HsbZCVo,46530
3
- mwx/framework.py,sha256=c9M8SqmW_RlmFLmFRfNXRFJdI1zpno7rGFW0h4pgXLQ,76134
3
+ mwx/framework.py,sha256=qbF1XwgBkNWT5z8Hbu3IKdvUnDpMZYzxwshZ9r6vctU,72662
4
4
  mwx/graphman.py,sha256=agvuPofnfQoDtTC0Hk_n8OqySb0SqeHoJVMcLi_YVQA,68507
5
5
  mwx/images.py,sha256=mrnUYH12I3XLVSZcEXlpVltX0XMxufbl2yRvDIQJZqc,49957
6
6
  mwx/matplot2.py,sha256=Knecx055Cm25qobhXuNTE1sjDVLABl6IGVAYFAwfyEI,32882
7
7
  mwx/matplot2g.py,sha256=mLy73uchAFkD5SBeeGo_ZI9O5vuhyQei4vqZteEclG4,64959
8
8
  mwx/matplot2lg.py,sha256=Djt0lFtQs_yLK4wOYXLhLsSahgVhCGtYlIIQ8IJkCOA,26311
9
9
  mwx/mgplt.py,sha256=EG5yP2vibFkksiuGrQy_nqRepwtFKk2xg35HbbNz0E0,5742
10
- mwx/nutshell.py,sha256=gtJOkDbrBr0UwXmbQ0_S4kxlhN5q2WHF-GykJHAKLE8,136642
10
+ mwx/nutshell.py,sha256=seOjkLmsfsGRCOrWzOH-fEST8F_SJeC6tp4xNpcaJkM,135740
11
11
  mwx/utilus.py,sha256=YA19NZjCrTHHafqd2sQoA-TV947awCxPPmDLiHSz978,37001
12
- mwx/wxmon.py,sha256=EOxQdFkMkwEoV4jojMCukQRk5C8CXBUJSwT7Cq2HyXs,11246
13
- mwx/wxpdb.py,sha256=KQkmFdF-WB4NwQuK5bWY9wzuSffNwDSxtdzqlEq2054,19490
12
+ mwx/wxmon.py,sha256=6ejFMuI7gffewrR7eLbI7BQfqBRYX-ujp2Ru7ofeork,13802
13
+ mwx/wxpdb.py,sha256=8f55jAO856iB61wRidCR3aFjnrHuaC3RZF6kwj1Ok1E,19486
14
14
  mwx/wxwil.py,sha256=uAmpkOQtDGjqywJ8bV-yT5IUANPi9rsMa1CcWVIILeM,5680
15
- mwx/wxwit.py,sha256=BJTnqdoLpWYHQAiUfhzxhF6Nip6Eo-8QoVr3DwtAC3k,8097
15
+ mwx/wxwit.py,sha256=0sskPOE9LTIYI0iokXTmtgPMDxeLAZk3zoFMDH9Xn5g,7656
16
16
  mwx/py/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  mwx/py/filling.py,sha256=f6KMBcBv7gwrl6qmJYLTL-O0Z47bWNAdTCZtUZIo8vM,16794
18
- mwxlib-0.90.0.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
19
- mwxlib-0.90.0.dist-info/METADATA,sha256=lYDOX2wksNfz6sC3yvwH1hRTr1uiYDCNnNYJ1CG2zi8,1945
20
- mwxlib-0.90.0.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
21
- mwxlib-0.90.0.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
22
- mwxlib-0.90.0.dist-info/RECORD,,
18
+ mwxlib-0.90.3.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
19
+ mwxlib-0.90.3.dist-info/METADATA,sha256=CEHM1YIueh8YkeDoP2Ype1-QD9DDtgqUGxQFHKMzSj8,1945
20
+ mwxlib-0.90.3.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
21
+ mwxlib-0.90.3.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
22
+ mwxlib-0.90.3.dist-info/RECORD,,