mwxlib 1.6.2__py3-none-any.whl → 1.6.4__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.2"
4
+ __version__ = "1.6.4"
5
5
  __author__ = "Kazuya O'moto <komoto@jeol.co.jp>"
6
6
 
7
7
  from contextlib import contextmanager
mwx/graphman.py CHANGED
@@ -488,18 +488,22 @@ class Layer(LayerInterface, KnobCtrlPanel):
488
488
  LayerInterface.__init__(self, parent, session)
489
489
 
490
490
 
491
- def _register__dummy_plug__(cls, module):
491
+ def _register__dummy_plug__(cls, module, flag):
492
492
  if issubclass(cls, LayerInterface):
493
493
  ## warn(f"Duplicate iniheritance of LayerInterface by {cls}.")
494
494
  module.Plugin = cls
495
495
  return cls
496
496
 
497
- class _Plugin(LayerInterface, cls):
497
+ class _Plugin(cls, LayerInterface):
498
498
  def __init__(self, parent, session=None, **kwargs):
499
499
  cls.__init__(self, parent, **kwargs)
500
500
  LayerInterface.__init__(self, parent, session)
501
+ Show = LayerInterface.Show
502
+ IsShown = LayerInterface.IsShown
501
503
 
504
+ _Plugin.reloadable = getattr(cls, "reloadable", flag)
502
505
  _Plugin.__module__ = module.__name__
506
+ _Plugin.__qualname__ = cls.__qualname__ + "~"
503
507
  _Plugin.__name__ = cls.__name__ + "~"
504
508
  _Plugin.__doc__ = cls.__doc__
505
509
  module.Plugin = _Plugin
@@ -1069,6 +1073,9 @@ class Frame(mwx.Frame):
1069
1073
  name = root.__module__
1070
1074
  else:
1071
1075
  name = root
1076
+ if name == "__main__":
1077
+ name = inspect.getfile(__import__("__main__"))
1078
+
1072
1079
  dirname_, name = os.path.split(name) # if the name is full-path:str
1073
1080
  if name.endswith(".py"):
1074
1081
  name = name[:-3]
@@ -1102,29 +1109,30 @@ class Frame(mwx.Frame):
1102
1109
 
1103
1110
  ## Load or reload the module, and check whether it contains a class named `Plugin`.
1104
1111
  try:
1105
- if name in sys.modules:
1112
+ loadable = (not name.startswith("__main__")) # Check if the module is loadable.
1113
+ if not loadable:
1114
+ module = types.ModuleType(name) # dummy module (cannot reload)
1115
+ module.__file__ = "<scratch>"
1116
+ ## sys.modules[name] = module
1117
+ elif name in sys.modules:
1106
1118
  module = reload(sys.modules[name])
1107
1119
  else:
1108
1120
  module = import_module(name)
1109
- except ModuleNotFoundError:
1110
- module = types.ModuleType(name) # dummy module (cannot reload)
1111
- module.__file__ = "<scratch>"
1112
- ## sys.modules[name] = module
1113
1121
  except Exception:
1114
1122
  traceback.print_exc() # Unable to load the module.
1115
1123
  return False
1116
-
1117
- ## Register dummy plug; Add module.Plugin <Layer>.
1118
- if not hasattr(module, 'Plugin'):
1119
- if inspect.isclass(root):
1120
- _register__dummy_plug__(root, module)
1121
- module.__dummy_plug__ = root
1122
1124
  else:
1123
- if hasattr(module, '__dummy_plug__'):
1124
- cls = module.__dummy_plug__ # old class (imported)
1125
- cls = getattr(module, cls.__name__) # new class (reloaded)
1126
- _register__dummy_plug__(cls, module)
1127
- module.__dummy_plug__ = cls
1125
+ ## Register dummy plug; Add module.Plugin <Layer>.
1126
+ if not hasattr(module, 'Plugin'):
1127
+ if inspect.isclass(root):
1128
+ _register__dummy_plug__(root, module, loadable)
1129
+ module.__dummy_plug__ = root
1130
+ else:
1131
+ if hasattr(module, '__dummy_plug__'): # Reloading dummy plug...
1132
+ cls = module.__dummy_plug__ # old class (imported)
1133
+ root = getattr(module, cls.__name__) # new class (reloaded)
1134
+ _register__dummy_plug__(root, module, loadable)
1135
+ module.__dummy_plug__ = root
1128
1136
 
1129
1137
  ## Note: name (module.__name__) != Plugin.__module__ if module is a package.
1130
1138
  try:
mwx/nutshell.py CHANGED
@@ -485,8 +485,8 @@ class EditorInterface(AutoCompInterfaceMixin, CtrlInterface):
485
485
  This class is mixed-in ``wx.stc.StyledTextCtrl``.
486
486
  """
487
487
  def __init__(self):
488
- CtrlInterface.__init__(self)
489
488
  AutoCompInterfaceMixin.__init__(self)
489
+ CtrlInterface.__init__(self)
490
490
 
491
491
  def dispatch(evt):
492
492
  """Fork events to the parent."""
mwx/testsuite.py CHANGED
@@ -17,7 +17,7 @@ Is equivalent to:
17
17
  from contextlib import contextmanager
18
18
  import wx
19
19
 
20
- __all__ = ["testApp", "testFrame"]
20
+ __all__ = ["testApp", "testFrame", "register_plug"]
21
21
 
22
22
 
23
23
  @contextmanager
@@ -31,8 +31,22 @@ def testApp():
31
31
 
32
32
  @contextmanager
33
33
  def testFrame(**kwargs):
34
- with testApp():
34
+ with testApp() as app:
35
35
  frm = wx.Frame(None, **kwargs)
36
36
  yield frm
37
37
  frm.Show()
38
+ app.SetTopWindow(frm)
38
39
  ## wx.Frame.run = staticmethod(testFrame)
40
+
41
+
42
+ def register_plug(cls=None, **kwargs):
43
+ if cls is None:
44
+ return lambda f: register(f, **kwargs)
45
+
46
+ from mwx.graphman import Frame
47
+ with testApp() as app:
48
+ frm = app.GetTopWindow() or Frame(None)
49
+ frm.load_plug(cls, force=1, show=1, **kwargs)
50
+ frm.Show()
51
+ app.SetTopWindow(frm)
52
+ return cls
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mwxlib
3
- Version: 1.6.2
3
+ Version: 1.6.4
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
@@ -1,15 +1,15 @@
1
1
  mwx/__init__.py,sha256=pS7ZG8QKRypiFFiaWAq_opBB6I_1viZ0zUMk2TbjzE0,667
2
2
  mwx/bookshelf.py,sha256=yW17nMNPXKHM7LLXLpr9DaRhyFHz_OBAZ_DsuEK2QzA,8387
3
3
  mwx/controls.py,sha256=B9f_A0ev3SPf75K-LIZCusMLeDGYz1O3cMml7IOrDrM,49870
4
- mwx/framework.py,sha256=8E9hGW9YPJBpv55ZvPrIQnVcNeDtWP-RRvgXOJbvYXc,77463
5
- mwx/graphman.py,sha256=l6SjyjZj0_aDj-_dwNDlVI6aD3BQqbhoLe95NAzAEqo,69699
4
+ mwx/framework.py,sha256=T-6ILuhLC7wQ0jB4CcovzLxzQ3NwtbfCIRMwfJxg6qE,77463
5
+ mwx/graphman.py,sha256=Omv14il6ufr_RZayTJiPY-6fX-jAt6g5erGw4OuZlqA,70199
6
6
  mwx/images.py,sha256=Kkfy9QI_hMtwShSjUS4-ZpC_EkVuah_XhpBOR4wAKkM,49792
7
7
  mwx/matplot2.py,sha256=cjdN12RENqWFw1v9QyO05XQc6dK3Pn_ltdC3OfmhGfg,32995
8
8
  mwx/matplot2g.py,sha256=0gxjl7UKx8QGRI2thpniA7dQu9fpHGG0mvl7Ml2exrc,65474
9
9
  mwx/matplot2lg.py,sha256=jE-LYPEVaEapQN8L-eviRyEx4Lw-8GyLGzZotrIZShU,27413
10
10
  mwx/mgplt.py,sha256=SVUJ0ls4gC9xulbWxK2qqmDxf0uBCflvwoPkxoF5s3M,5566
11
- mwx/nutshell.py,sha256=Sa5PKSiXxT74Mj_vE9fUinxkfm5Xtg1MGGUjwbRH-yY,147552
12
- mwx/testsuite.py,sha256=pBB7ZNicI_thrg6LmNPgUOgfMWwRoAaYWN1nFy6t6S4,790
11
+ mwx/nutshell.py,sha256=JHFiY-X1pEdFBzSQRXO_loIhJyPuWljWhhGzie3m7TU,147552
12
+ mwx/testsuite.py,sha256=Sd4w4UGmD6bFrKQlAOSJBGio3uDgnLQgzXS1CbY86rw,1199
13
13
  mwx/utilus.py,sha256=JOYBTHoo_GmYykX72PgiPzgD2M-1pcOR8gMBLc2bnck,39016
14
14
  mwx/wxmon.py,sha256=aS6lSjDm0PxIhfyBPtg-wIP0v-R3g2K5a3k2mclWSrQ,12798
15
15
  mwx/wxpdb.py,sha256=ehRawAnqQberUeDN9j_-drWYQzu23w5UeQyto4nj53g,18812
@@ -22,7 +22,7 @@ mwx/plugins/frame_listview.py,sha256=yd2NCgspqGfTNhj1wxuW8r1zapIm7vNzVX2iytk8CDM
22
22
  mwx/plugins/line_profile.py,sha256=zzm6_7lnAnNepLbh07ordp3nRWDFQJtu719ZVjrVf8s,819
23
23
  mwx/py/__init__.py,sha256=xykgfOytOwNuvXsfkLoumFZSTN-iBsHOjczYXngjmUE,12
24
24
  mwx/py/filling.py,sha256=vWCJoHd_oyXOeXTHtXGY7wfNQeNAZhV3GZu4xlc8GDY,16867
25
- mwxlib-1.6.2.dist-info/METADATA,sha256=RshZtfKDFUVVMf92eAGQhe08pmtZjPR3ClIhuYOpGRc,7381
26
- mwxlib-1.6.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
- mwxlib-1.6.2.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
28
- mwxlib-1.6.2.dist-info/RECORD,,
25
+ mwxlib-1.6.4.dist-info/METADATA,sha256=ZafN1sf9Ovxith57qzq87MOYTCEkWFctSAhfIZpux2E,7381
26
+ mwxlib-1.6.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
+ mwxlib-1.6.4.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
28
+ mwxlib-1.6.4.dist-info/RECORD,,
File without changes