mwxlib 0.81.0__py3-none-any.whl → 0.81.2__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/__init__.py CHANGED
@@ -26,18 +26,6 @@ from .framework import Frame, MiniFrame, ShellFrame
26
26
  ## from .mgplt import Gnuplot
27
27
  ## from .mgplt import GnuplotFrame
28
28
 
29
- from importlib import reload
30
- import contextlib
31
- import wx
32
-
33
-
34
- @contextlib.contextmanager
35
- def app(loop=True):
36
- app = wx.GetApp() or wx.App()
37
- yield app
38
- if loop and not app.GetMainLoop():
39
- app.MainLoop()
40
-
41
29
 
42
30
  def deb(target=None, loop=True, locals=None, **kwargs):
43
31
  """Dive into the process.
@@ -60,6 +48,8 @@ def deb(target=None, loop=True, locals=None, **kwargs):
60
48
  Note:
61
49
  This will execute the startup script $(PYTHONSTARTUP).
62
50
  """
51
+ import wx
52
+
63
53
  quote_unqoute = """
64
54
  Anything one man can imagine, other man can make real.
65
55
  --- Jules Verne (1828--1905)
@@ -68,11 +58,17 @@ def deb(target=None, loop=True, locals=None, **kwargs):
68
58
  "mwx {}".format(__version__) + quote_unqoute)
69
59
  kwargs.setdefault("execStartupScript", True)
70
60
  kwargs.setdefault("ensureClose", True)
71
- with app(loop):
72
- frame = ShellFrame(None, target, **kwargs)
73
- frame.Show()
74
- shell = frame.rootshell
75
- shell.SetFocus()
76
- if locals:
77
- shell.locals.update(locals)
78
- return frame
61
+
62
+ app = wx.GetApp() or wx.App()
63
+ frame = ShellFrame(None, target, **kwargs)
64
+ frame.Show()
65
+ shell = frame.rootshell
66
+ shell.SetFocus()
67
+ if locals:
68
+ shell.locals.update(locals)
69
+ if loop:
70
+ if not app.GetMainLoop():
71
+ app.MainLoop()
72
+ else:
73
+ pass # The mainloop is already running.
74
+ return frame
mwx/controls.py CHANGED
@@ -1133,11 +1133,12 @@ class Indicator(wx.Control):
1133
1133
  spacing = 7
1134
1134
  radius = 5
1135
1135
 
1136
- def __init__(self, parent, value=0, tip='', size=(-1,-1), **kwargs):
1137
- s = self.spacing
1138
- size = np.maximum((s*6, s*2+1), size) # minimum size:(6s,2s)
1139
- wx.Control.__init__(self, parent, size=size,
1140
- style=wx.BORDER_NONE, **kwargs)
1136
+ def __init__(self, parent, value=0, tip='',
1137
+ size=(-1,-1), style=wx.BORDER_NONE, **kwargs):
1138
+ s = self.spacing # minimum size:(6s,2s)
1139
+ w = max(size[0], s*6)
1140
+ h = max(size[1], s*2+1)
1141
+ wx.Control.__init__(self, parent, size=(w,h), style=style, **kwargs)
1141
1142
 
1142
1143
  self.__value = value
1143
1144
  self.ToolTip = tip.strip()
@@ -1201,8 +1202,9 @@ class Gauge(wx.Control):
1201
1202
  self.__range = int(v)
1202
1203
  self.Draw()
1203
1204
 
1204
- def __init__(self, parent, range=24, value=0, tip='', **kwargs):
1205
- wx.Control.__init__(self, parent, style=wx.BORDER_NONE, **kwargs)
1205
+ def __init__(self, parent, range=24, value=0, tip='',
1206
+ style=wx.BORDER_NONE, **kwargs):
1207
+ wx.Control.__init__(self, parent, style=style, **kwargs)
1206
1208
 
1207
1209
  self.__range = range
1208
1210
  self.__value = value
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.81.0"
7
+ __version__ = "0.81.2"
8
8
  __author__ = "Kazuya O'moto <komoto@jeol.co.jp>"
9
9
 
10
10
  from functools import wraps, partial
@@ -388,9 +388,8 @@ def pack(self, items, orient=wx.HORIZONTAL, style=None, label=None):
388
388
  Args:
389
389
  items : wx objects (with some packing parameters)
390
390
 
391
- - (obj, 1) -> sized with ratio 1 (orient と同方向)
392
- 他に 0 以外を指定しているオブジェクトとエリアを分け合う
393
- - (obj, 1, wx.EXPAND) -> expanded with ratio 1 (orient と垂直方向)
391
+ - (obj, 1) -> sized with ratio 1 (parallel to `orient`)
392
+ - (obj, 1, wx.EXPAND) -> expanded with ratio 1 (perpendicular to `orient`)
394
393
  - (obj, 0, wx.ALIGN_CENTER | wx.LEFT, 4) -> center with 4 pixel at wx.LEFT
395
394
  - ((-1,-1), 1, wx.EXPAND) -> stretched space
396
395
  - (-1,-1) -> padding space
@@ -466,9 +465,9 @@ class Menu(wx.Menu):
466
465
  menu_item.SetBitmaps(*icons)
467
466
  self.Append(menu_item)
468
467
  try:
469
- self.owner.Bind(wx.EVT_MENU, handlers[0], id=id)
470
- self.owner.Bind(wx.EVT_UPDATE_UI, handlers[1], id=id)
471
- self.owner.Bind(wx.EVT_MENU_HIGHLIGHT, handlers[2], id=id)
468
+ owner.Bind(wx.EVT_MENU, handlers[0], menu_item)
469
+ owner.Bind(wx.EVT_UPDATE_UI, handlers[1], menu_item)
470
+ owner.Bind(wx.EVT_MENU_HIGHLIGHT, handlers[2], menu_item)
472
471
  except IndexError:
473
472
  pass
474
473
  else:
@@ -479,8 +478,8 @@ class Menu(wx.Menu):
479
478
  if icons:
480
479
  submenu_item.SetBitmaps(*icons)
481
480
  self.Append(submenu_item)
482
- self.Enable(submenu_item.Id, len(subitems)) # Disable an empty menu
483
- submenu.Id = submenu_item.Id # <- ID_ANY
481
+ self.Enable(submenu_item.Id, len(subitems)) # Disable an empty menu.
482
+ submenu.Id = submenu_item.Id # <- ID_ANY (dummy to check empty sbumenu)
484
483
 
485
484
  @staticmethod
486
485
  def Popup(parent, menu, *args, **kwargs):
@@ -521,14 +520,14 @@ class MenuBar(wx.MenuBar, TreeList):
521
520
  """
522
521
  if self.Parent:
523
522
  menu = self.getmenu(key)
524
- if not menu: # 新規のメニューアイテムを挿入する
525
- self.reset() # リセットして終了
523
+ if not menu:
524
+ self.reset()
526
525
  return
527
526
 
528
527
  for item in menu.MenuItems: # delete all items
529
- self.Parent.Unbind(wx.EVT_MENU, id=item.Id)
530
- self.Parent.Unbind(wx.EVT_UPDATE_UI, id=item.Id)
531
- self.Parent.Unbind(wx.EVT_MENU_HIGHLIGHT, id=item.Id)
528
+ self.Parent.Unbind(wx.EVT_MENU, item)
529
+ self.Parent.Unbind(wx.EVT_UPDATE_UI, item)
530
+ self.Parent.Unbind(wx.EVT_MENU_HIGHLIGHT, item)
532
531
  menu.Delete(item)
533
532
 
534
533
  menu2 = Menu(self.Parent, self[key]) # new menu2 to swap menu
@@ -536,7 +535,7 @@ class MenuBar(wx.MenuBar, TreeList):
536
535
  menu.Append(menu2.Remove(item)) # 重複しないようにいったん切り離して追加する
537
536
 
538
537
  if hasattr(menu, 'Id'):
539
- self.Enable(menu.Id, menu.MenuItemCount > 0) # 空のサブメニューは無効にする
538
+ self.Enable(menu.Id, menu.MenuItemCount > 0) # Disable empty submenu.
540
539
 
541
540
  def reset(self):
542
541
  """Recreates menubar if the Parent were attached by SetMenuBar.
@@ -546,16 +545,16 @@ class MenuBar(wx.MenuBar, TreeList):
546
545
  for j in range(self.GetMenuCount()): # remove and del all top-level menu
547
546
  menu = self.Remove(0)
548
547
  for item in menu.MenuItems: # delete all items
549
- self.Parent.Unbind(wx.EVT_MENU, id=item.Id)
550
- self.Parent.Unbind(wx.EVT_UPDATE_UI, id=item.Id)
551
- self.Parent.Unbind(wx.EVT_MENU_HIGHLIGHT, id=item.Id)
548
+ self.Parent.Unbind(wx.EVT_MENU, item)
549
+ self.Parent.Unbind(wx.EVT_UPDATE_UI, item)
550
+ self.Parent.Unbind(wx.EVT_MENU_HIGHLIGHT, item)
552
551
  menu.Destroy()
553
552
 
554
553
  for j, (key, values) in enumerate(self):
555
- menu = Menu(self.Parent, values) # 空のメインメニューでも表示に追加する
554
+ menu = Menu(self.Parent, values)
556
555
  self.Append(menu, key)
557
556
  if not values:
558
- self.EnableTop(j, False) # 空のメインメニューは無効にする
557
+ self.EnableTop(j, False) # Disable empty main menu.
559
558
 
560
559
 
561
560
  class StatusBar(wx.StatusBar):
@@ -1213,8 +1212,7 @@ class ShellFrame(MiniFrame):
1213
1212
  self.Log.default_buffer.SaveFile(self.LOGGING_FILE)
1214
1213
  self.History.default_buffer.SaveFile(self.HISTORY_FILE)
1215
1214
  self.save_session()
1216
- except Exception:
1217
- traceback.print_exc()
1215
+ self.timer.Stop()
1218
1216
  finally:
1219
1217
  self._mgr.UnInit()
1220
1218
  return MiniFrame.Destroy(self)
@@ -1451,8 +1449,8 @@ class ShellFrame(MiniFrame):
1451
1449
  def help(self, obj):
1452
1450
  self.rootshell.help(obj)
1453
1451
 
1454
- def highlight(self, obj):
1455
- self.inspector.highlight(obj)
1452
+ def highlight(self, obj, *args, **kwargs):
1453
+ self.inspector.highlight(obj, *args, **kwargs)
1456
1454
 
1457
1455
  ## Note: history 変数に余計な文字列が入らないようにする
1458
1456
  @postcall
mwx/graphman.py CHANGED
@@ -408,12 +408,17 @@ class LayerInterface(CtrlInterface):
408
408
  del self.Arts
409
409
 
410
410
 
411
- class Layer(LayerInterface, ControlPanel):
411
+ class Layer(ControlPanel, LayerInterface):
412
412
  """Graphman.Layer
413
413
  """
414
414
  def __init__(self, parent, session=None, **kwargs):
415
415
  ControlPanel.__init__(self, parent, **kwargs)
416
416
  LayerInterface.__init__(self, parent, session)
417
+
418
+ ## Explicit (override) precedence
419
+ message = LayerInterface.message
420
+ IsShown = LayerInterface.IsShown
421
+ Show = LayerInterface.Show
417
422
 
418
423
 
419
424
  class Graph(GraphPlot):
@@ -992,16 +997,24 @@ class Frame(mwx.Frame):
992
997
  module = inspect.getmodule(cls) # rebase module or __main__
993
998
 
994
999
  if issubclass(cls, LayerInterface):
995
- warnings.warn("Use class name 'Plugin' instead of {!r}."
1000
+ warnings.warn("Duplicate iniheritance of LayerInterface by {!r}."
996
1001
  .format(cls.__name__), stacklevel=2)
997
1002
  cls.__module__ = module.__name__ # __main__ to module
998
1003
  module.Plugin = cls
999
1004
  return cls
1000
1005
 
1001
- class _Plugin(LayerInterface, cls):
1006
+ class _Plugin(cls, LayerInterface):
1002
1007
  def __init__(self, parent, session=None, **kwargs):
1003
1008
  cls.__init__(self, parent, **kwargs)
1004
1009
  LayerInterface.__init__(self, parent, session)
1010
+
1011
+ ## Explicit (override) precedence
1012
+ message = LayerInterface.message
1013
+ IsShown = LayerInterface.IsShown
1014
+ Show = LayerInterface.Show
1015
+
1016
+ ## Implicit (override) precedence
1017
+ ## cls.Init / cls.save_session / cls.load_session
1005
1018
 
1006
1019
  _Plugin.__module__ = cls.__module__ = module.__name__
1007
1020
  _Plugin.__name__ = cls.__name__ + str("~")
@@ -1023,6 +1036,8 @@ class Frame(mwx.Frame):
1023
1036
  else:
1024
1037
  rootpath = root
1025
1038
 
1039
+ assert isinstance(rootpath, str)
1040
+
1026
1041
  name = os.path.basename(rootpath)
1027
1042
  if name.endswith(".py"):
1028
1043
  name,_ = os.path.splitext(name)
mwx/nutshell.py CHANGED
@@ -115,10 +115,10 @@ class EditorInterface(CtrlInterface):
115
115
  'C-S-; pressed' : (0, _F(self.comment_out_line)),
116
116
  'C-: pressed' : (0, _F(self.uncomment_line)),
117
117
  'C-S-: pressed' : (0, _F(self.uncomment_line)),
118
- 'Lbutton pressed' : (0, lambda v: margin_fork(v, 'Lclick'), skip),
119
- 'Rbutton pressed' : (0, lambda v: margin_fork(v, 'Rclick'), skip),
120
- 'Mbutton pressed' : (0, lambda v: margin_fork(v, 'Mclick'), skip),
121
- 'Lbutton dblclick' : (0, lambda v: margin_fork(v, 'dblclick'), skip),
118
+ 'Lbutton pressed' : (0, lambda v: click_fork(v, 'Lclick')),
119
+ 'Rbutton pressed' : (0, lambda v: click_fork(v, 'Rclick')),
120
+ 'Mbutton pressed' : (0, lambda v: click_fork(v, 'Mclick')),
121
+ 'Lbutton dblclick' : (0, lambda v: click_fork(v, 'dblclick')),
122
122
  'margin_dblclick' : (0, self.on_margin_dblclick),
123
123
  'select_itext' : (10, self.filter_text, self.on_filter_text_enter),
124
124
  'select_line' : (100, self.on_linesel_begin, skip),
@@ -137,10 +137,12 @@ class EditorInterface(CtrlInterface):
137
137
  },
138
138
  })
139
139
 
140
- def margin_fork(v, click):
140
+ def click_fork(v, click):
141
141
  if self._margin is not None:
142
142
  v.Margin = self._margin # Add info to event object. OK ??
143
143
  self.handler(f"margin_{click}", v)
144
+ v.Skip()
145
+ self._margin = None
144
146
 
145
147
  def on_motion(v):
146
148
  self._window_handler('motion', v)
@@ -152,6 +154,7 @@ class EditorInterface(CtrlInterface):
152
154
  self._margin = m # current margin under mouse
153
155
  return
154
156
  self._margin = None
157
+ v.Skip()
155
158
  self.Bind(wx.EVT_MOTION, on_motion)
156
159
 
157
160
  self.Bind(wx.EVT_MOUSE_CAPTURE_LOST,
mwx/wxwit.py CHANGED
@@ -102,7 +102,8 @@ class Inspector(it.InspectionTree, CtrlInterface):
102
102
  return "{} ({!r} {})".format(clsname, obj.Name, obj.Id)
103
103
  return clsname
104
104
 
105
- def highlight(self, obj):
105
+ def highlight(self, obj, msec=2000):
106
+ self.highlighter.highlightTime = msec
106
107
  if isinstance(obj, wx.Window):
107
108
  self.highlighter.HighlightWindow(obj)
108
109
  elif isinstance(obj, wx.Sizer):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mwxlib
3
- Version: 0.81.0
3
+ Version: 0.81.2
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
- mwx/__init__.py,sha256=CxhKHOhig62F8p6GvP5gii-VvQtSjp9yWJpHvC_Kans,2592
2
- mwx/controls.py,sha256=J0zbs7l-2HHpA9MAlg2Dfp12EslnhK_0XM_PuNxvk70,42983
3
- mwx/framework.py,sha256=k5J9Axv26uMHYFYvZOAVOan2mcOIdWPt8Jdfu-1TRP4,71691
4
- mwx/graphman.py,sha256=ubJq0LuF2II1D2XrTUc62tad1yO9HnYk77hfj5DC_e4,69191
1
+ mwx/__init__.py,sha256=132PKNl-qpvV8godY4iAnHcupnmPTWfFx-j7tantnmA,2521
2
+ mwx/controls.py,sha256=nK98yYgWczs1xKUbCXyM7A2XXl84iOm65c8DRjMrTPI,43034
3
+ mwx/framework.py,sha256=rq5mUn4FYYwPhLT405HODh25rpgfhwytan0MnfIo_dk,71410
4
+ mwx/graphman.py,sha256=zXGOxVVWQJxlMl2TNigfCBIhiPAjlgMb8Qn-D1AxN88,69722
5
5
  mwx/images.py,sha256=9e8X7OpJ6Z3fF3ez17P_qk2D1NMO10-lN8TCtulAqT0,46248
6
6
  mwx/matplot2.py,sha256=mzctMUk00m-tvs268PTwdLln7G3NCl6J-5zFzJkfsVI,36004
7
7
  mwx/matplot2g.py,sha256=yfF4r6juclU1I1k41lGb_VwxRmp0ktuD8az-wQ26MsE,67727
8
8
  mwx/matplot2lg.py,sha256=h_aFij_7ksG2DXuYCaGmjtlcl122vZnwbMTv21Mprcg,27606
9
9
  mwx/mgplt.py,sha256=49_wpFZUEKErQmtobqrlNKDjWlAsdLft-izlqSyGPD0,6878
10
- mwx/nutshell.py,sha256=b1Py22yFLq8AM5EfR9Njoq_v4TlryHWFomiCRhekjVg,135191
10
+ mwx/nutshell.py,sha256=5BxB3TeyY1I5W0uDCSTZc6lh5nGW6ckBOQwHZa_RKD8,135235
11
11
  mwx/utilus.py,sha256=NBU4PG3AQ8bE1Iadpe4QaZOGZYPh7NQ85ff6jxeKVG4,36281
12
12
  mwx/wxmon.py,sha256=g55Ds_dRpDS8dNmaVQwgnd1inuj45tqLMIgJA23cOIw,11291
13
13
  mwx/wxpdb.py,sha256=-_rDNxk3S3z1PgDZ6AAhKksFp8wJL3NBKDxfOZ74E3c,19790
14
14
  mwx/wxwil.py,sha256=BUfEF0Nc1E-mVC3Vdz6k1E-2s5J0PO6qEzRQ6lfyePI,5246
15
- mwx/wxwit.py,sha256=2JLf94XoVKLt8IIwVdYS7Zoa9SII60XQ69y2JrptBuE,7166
15
+ mwx/wxwit.py,sha256=lJX2A26IcSA_MpdTnlV5QYg1PruE47ckk1yL8E_dYiE,7224
16
16
  mwx/py/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  mwx/py/filling.py,sha256=NnQnfUVol-Nz4QYZUKFIyRX-Yxp54m5n54Yxza3Iwho,16655
18
- mwxlib-0.81.0.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
19
- mwxlib-0.81.0.dist-info/METADATA,sha256=y4i0aywQSMfWTp28-JohFotBFpwOlP2_J-7KmSz-t2E,1893
20
- mwxlib-0.81.0.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
21
- mwxlib-0.81.0.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
22
- mwxlib-0.81.0.dist-info/RECORD,,
18
+ mwxlib-0.81.2.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
19
+ mwxlib-0.81.2.dist-info/METADATA,sha256=_7B7dFMBRvG7kIXyhuUBz8Ntv1Ul0tDDK1Qlv3hYc5Y,1893
20
+ mwxlib-0.81.2.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
21
+ mwxlib-0.81.2.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
22
+ mwxlib-0.81.2.dist-info/RECORD,,