mwxlib 1.0rc4__py3-none-any.whl → 1.0.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/controls.py CHANGED
@@ -957,7 +957,7 @@ class Icon(wx.Bitmap):
957
957
 
958
958
 
959
959
  class ClassicButton(wx.Button):
960
- """Flat button
960
+ """Classic button
961
961
 
962
962
  Args:
963
963
  label : button label
@@ -1035,7 +1035,7 @@ class ToggleButton(wx.ToggleButton):
1035
1035
 
1036
1036
 
1037
1037
  class TextCtrl(wx.Control):
1038
- """Text panel
1038
+ """Text control
1039
1039
 
1040
1040
  Args:
1041
1041
  label : button label
@@ -1089,7 +1089,7 @@ class TextCtrl(wx.Control):
1089
1089
 
1090
1090
 
1091
1091
  class Choice(wx.Control):
1092
- """Editable Choice (ComboBox) panel
1092
+ """Editable Choice (ComboBox) control
1093
1093
 
1094
1094
  Args:
1095
1095
  label : button label
mwx/framework.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #! python3
2
2
  """mwxlib framework.
3
3
  """
4
- __version__ = "1.0rc4"
4
+ __version__ = "1.0.3"
5
5
  __author__ = "Kazuya O'moto <komoto@jeol.co.jp>"
6
6
 
7
7
  from contextlib import contextmanager
mwx/graphman.py CHANGED
@@ -964,11 +964,6 @@ class Frame(mwx.Frame):
964
964
  else:
965
965
  win.handler('page_closed', win)
966
966
 
967
- if pane.dock_direction:
968
- pane.Dock()
969
- else:
970
- pane.Float()
971
-
972
967
  ## Modify the floating position of the pane when displayed.
973
968
  ## Note: This is a known bug in wxWidgets 3.17 -- 3.20,
974
969
  ## and will be fixed in wxPython 4.2.1.
@@ -1000,6 +995,11 @@ class Frame(mwx.Frame):
1000
995
  pane.CaptionVisible(False) # no caption bar
1001
996
  pane.Gripper(dock not in (0, 5)) # show a grip when docked
1002
997
  pane.Dockable(dock)
998
+
999
+ if pane.dock_direction:
1000
+ pane.Dock()
1001
+ else:
1002
+ pane.Float()
1003
1003
 
1004
1004
  def OnPaneClose(self, evt): #<wx.aui.AuiManagerEvent>
1005
1005
  pane = evt.GetPane()
mwx/images.py CHANGED
@@ -135,6 +135,19 @@ clock = PyEmbeddedImage(
135
135
  b'vqHBv3R3pmbxzgwz4Z+EaTXtwqIogrzjxIJ4QVVV1UyihxgjFv3/K09Bu/lEkBgg5rLZH+fT'
136
136
  b'5dvfn7iFAAAAAElFTkSuQmCC')
137
137
 
138
+ #----------------------------------------------------------------------
139
+ cog = PyEmbeddedImage(
140
+ b'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAAK/INwWK6QAAABl0'
141
+ b'RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGSSURBVCjPVVFNSwJhEF78Ad79'
142
+ b'Cf6PvXQRsotUlzKICosuRYmR2RJR0KE6lBFFZVEbpFBSqKu2rum6llFS9HHI4iUhT153n6Zt'
143
+ b'IWMOM+/MM88z7wwH7s9Ub16SJcnbmrNcxVm2q7Z8/QPvEOtntpj92NkCqITLepEpjix7xQti'
144
+ b'LOoQ2b6+E7YAN/5nfOEJ2WbKqOIOJ4bYVMEQx4LfBBQDsvFMhUcCVU1/CxVXmDBGA5ZETrhD'
145
+ b'CQVcYAPbyEJBhvrnBVPiSpNr6cYDNCQwo4zzU/ySckkgDYuNuVpI42T9k4gLKGMPs/xPzzov'
146
+ b'QiY2hQYe0jlJfyNNhTqiWDYBq/wBMcSRpnyPzu1oS7WtxjVBSthU1vgVksiQ3Dn6Gp5ah2YO'
147
+ b'KQo5GiuHPA6xT1EKpxQNCNYejgIR457KKio0S56YckjSa9jo//3mrj+BV0QQagqGTOo+Y7gZ'
148
+ b'If1puP3WHoLhEb2PjTlCTCWGXtbp8DCX3hZuOdaIc9A+aQvWk4ihq95p67a7nP+u+Ws+r0dq'
149
+ b'l9z/zv0NCYhdCPKZ7oYAAAAASUVORK5CYII=')
150
+
138
151
  #----------------------------------------------------------------------
139
152
  colour = PyEmbeddedImage(
140
153
  b'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0'
mwx/matplot2g.py CHANGED
@@ -21,7 +21,13 @@ from .matplot2 import MatplotPanel
21
21
  from .matplot2 import NORMAL, DRAGGING, PAN, ZOOM, MARK, LINE, REGION
22
22
 
23
23
 
24
- def _imcv(src):
24
+ def _to_array(x):
25
+ if isinstance(x, (list, tuple)):
26
+ x = np.array(x)
27
+ return x
28
+
29
+
30
+ def _to_cvtype(src):
25
31
  """Convert the image to a type that can be applied to the cv2 function.
26
32
  Note:
27
33
  CV2 normally accepts uint8/16 and float32/64.
@@ -31,36 +37,27 @@ def _imcv(src):
31
37
  return src
32
38
 
33
39
 
34
- def _to_buffer(img, grayscale=True):
40
+ def _to_buffer(img):
35
41
  if isinstance(img, Image.Image):
36
42
  ## return np.asarray(img) # ref
37
43
  return np.array(img) # copy
38
44
 
39
- if isinstance(img, wx.Bitmap):
45
+ if isinstance(img, wx.Bitmap): # bitmap to image
40
46
  img = img.ConvertToImage()
41
47
 
42
- if isinstance(img, wx.Image):
48
+ if isinstance(img, wx.Image): # image to RGB array; RGB to grayscale
43
49
  w, h = img.GetSize()
44
- buf = np.frombuffer(img.GetDataBuffer(), dtype='uint8')
45
- return buf.reshape(h, w, 3)
46
-
47
- if img.ndim > 2 and grayscale:
50
+ img = np.frombuffer(img.GetDataBuffer(), dtype='uint8').reshape(h, w, 3)
48
51
  return cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
49
52
  return img
50
53
 
51
54
 
52
- def _to_array(x):
53
- if isinstance(x, (list, tuple)):
54
- x = np.array(x)
55
- return x
56
-
57
-
58
- def imconvert(src, cutoff=0, threshold=None, binning=1):
59
- """Convert buffer to image<uint8>
55
+ def _to_image(src, cutoff=0, threshold=None, binning=1):
56
+ """Convert buffer to image <uint8>
60
57
 
61
58
  >>> dst = (src-a) * 255 / (b-a)
62
59
 
63
- cf. convertScaleAbs(src[, dst[, alpha[, beta]]]) -> dst<uint8>
60
+ cf. convertScaleAbs(src[, dst[, alpha[, beta]]]) -> dst <uint8>
64
61
 
65
62
  >>> dst = |src * alpha + beta|
66
63
  alpha = 255 / (b-a)
@@ -83,13 +80,13 @@ def imconvert(src, cutoff=0, threshold=None, binning=1):
83
80
 
84
81
  if bins > 1:
85
82
  ## src = src[::bins,::bins]
86
- src = _imcv(src)
83
+ src = _to_cvtype(src)
87
84
  src = cv2.resize(src, None, fx=1/bins, fy=1/bins, interpolation=cv2.INTER_AREA)
88
85
 
89
- if src.dtype == np.uint8:
90
- return bins, (0,255), src
86
+ if src.dtype == np.uint8: # RGB or gray image <uint8>
87
+ return bins, (0, 255), src
91
88
 
92
- if hasattr(cutoff, '__iter__'):
89
+ if hasattr(cutoff, '__iter__'): # cutoff vlim:list is specified.
93
90
  a, b = cutoff
94
91
  elif cutoff > 0:
95
92
  a = np.percentile(src, cutoff)
@@ -137,7 +134,7 @@ class AxesImagePhantom:
137
134
  self.__attributes = attributes
138
135
  self.__attributes['localunit'] = self.__localunit
139
136
  self.__buf = _to_buffer(buf)
140
- bins, vlim, img = imconvert(self.__buf,
137
+ bins, vlim, img = _to_image(self.__buf,
141
138
  cutoff = self.parent.score_percentile,
142
139
  threshold = self.parent.nbytes_threshold,
143
140
  )
@@ -284,7 +281,7 @@ class AxesImagePhantom:
284
281
  if buf is not None:
285
282
  self.__buf = _to_buffer(buf)
286
283
 
287
- bins, vlim, img = imconvert(self.__buf,
284
+ bins, vlim, img = _to_image(self.__buf,
288
285
  cutoff = self.parent.score_percentile,
289
286
  threshold = self.parent.nbytes_threshold,
290
287
  )
@@ -954,7 +951,7 @@ class GraphPlot(MatplotPanel):
954
951
  data = frame.roi
955
952
  GraphPlot.clipboard_name = name
956
953
  GraphPlot.clipboard_data = data
957
- bins, vlim, img = imconvert(data, frame.vlim)
954
+ bins, vlim, img = _to_image(data, frame.vlim)
958
955
  Clipboard.imwrite(img)
959
956
  self.message("Write buffer to clipboard.")
960
957
  except Exception as e:
mwx/nutshell.py CHANGED
@@ -147,10 +147,14 @@ def can_edit(f):
147
147
  def ask(f, prompt="Enter value", type=str):
148
148
  """Get response from the user using a dialog box."""
149
149
  @wraps(f)
150
- def _f(*v):
151
- with wx.TextEntryDialog(None, prompt, f.__name__) as dlg:
150
+ def _f(evt, value=''):
151
+ with wx.TextEntryDialog(None, prompt, f.__name__, value) as dlg:
152
152
  if dlg.ShowModal() == wx.ID_OK:
153
- return f(type(dlg.Value))
153
+ value = dlg.Value
154
+ try:
155
+ return f(type(value))
156
+ except ValueError:
157
+ return _f(evt, value) # show the prompt again
154
158
  return _f
155
159
 
156
160
 
@@ -2711,7 +2715,6 @@ class Nautilus(EditorInterface, Shell):
2711
2715
  obj.this = inspect.getmodule(obj)
2712
2716
  obj.shell = self # overwrite the facade <wx.py.shell.ShellFacade>
2713
2717
  except AttributeError:
2714
- ## print("- cannot overwrite target vars:", e)
2715
2718
  pass
2716
2719
  self.parent.handler('title_window', obj)
2717
2720
 
@@ -3276,9 +3279,10 @@ class Nautilus(EditorInterface, Shell):
3276
3279
  Delete target shell to prevent referencing the dead shell.
3277
3280
  """
3278
3281
  def _del():
3282
+ obj = self.target
3279
3283
  try:
3280
- if not self.target.shell:
3281
- del self.target.shell # delete the facade <wx.py.shell.ShellFacade>
3284
+ if not obj.shell:
3285
+ del obj.shell # delete the facade <wx.py.shell.ShellFacade>
3282
3286
  except AttributeError:
3283
3287
  pass
3284
3288
  wx.CallAfter(_del)
@@ -3288,11 +3292,14 @@ class Nautilus(EditorInterface, Shell):
3288
3292
  Reset localvars assigned for the shell target.
3289
3293
  """
3290
3294
  self.trace_position()
3291
- self.parent.handler('title_window', self.target)
3295
+ obj = self.target
3292
3296
  try:
3293
- self.target.shell = self # overwrite the facade <wx.py.shell.ShellFacade>
3297
+ obj.self = obj
3298
+ obj.this = inspect.getmodule(obj)
3299
+ obj.shell = self # overwrite the facade <wx.py.shell.ShellFacade>
3294
3300
  except AttributeError:
3295
3301
  pass
3302
+ self.parent.handler('title_window', obj)
3296
3303
 
3297
3304
  def on_inactivated(self, shell):
3298
3305
  """Called when shell:self is inactivated.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mwxlib
3
- Version: 1.0rc4
3
+ Version: 1.0.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
@@ -1,14 +1,14 @@
1
1
  mwx/__init__.py,sha256=psabnAMei5VzB2TsB2qBNLrIZMX0LiqjlXCpNGmDejk,668
2
2
  mwx/bookshelf.py,sha256=so-xSLq08sMlJBErTxOaDoKUAMa_g1CkIP2pNnff68c,5607
3
- mwx/controls.py,sha256=LZqee9K8uPxs-Iqcp1zMMNBjFpGPrHbcMaIBuBOL7oo,47647
4
- mwx/framework.py,sha256=AlmzB7g3rkgBOKvgxZs1UZpnIovfiI2FNsVfN-F9O5A,75810
5
- mwx/graphman.py,sha256=1GGBk4kJYRQ7zkvO2rvHxHoINrIfHSB7cabQKWhTyaI,69669
6
- mwx/images.py,sha256=_-Eh3xF7Khu42ivkYp97NXIzSNGbjcidqtWjZQFGtqE,47827
3
+ mwx/controls.py,sha256=fL_DdAjW9fIRFzlZYP296vo76e7d9cgLp4_fcWariUY,47654
4
+ mwx/framework.py,sha256=PFUIaqPkHe-5ozh0Otg8EM8zcjHPnoijdXvSJekMLRY,75809
5
+ mwx/graphman.py,sha256=mDnhy3jAzZCo8_p6ZcA-NDPMuOyW_R2r_fuxUIAM7D8,69669
6
+ mwx/images.py,sha256=oxCn0P-emiWujSS2gUgU5TUnr5cPjix2jBcjOBDr24I,48701
7
7
  mwx/matplot2.py,sha256=zA56jIdRUdzu-wrmPai1PSOjzqV2Erqw2yFKW-jwdA8,32901
8
- mwx/matplot2g.py,sha256=-vONEcU1UzAvsl5tgEluiDhebyA1_SU3HNnUN25ZQzU,64414
8
+ mwx/matplot2g.py,sha256=diwWNxzyy-c8KBDaolHaMqWdFXSYhEumgwXIZ9wAEYk,64467
9
9
  mwx/matplot2lg.py,sha256=JRWjWnLJUytbSq6wxs4P0gbVUr3xoLSF6Wwqd5V_pJI,27404
10
10
  mwx/mgplt.py,sha256=M5rt-H7Uq1OHnlFvMA4a3945UBvppbR9L_mw8NL_YZ0,5602
11
- mwx/nutshell.py,sha256=Kp4REs2TsiVhoBZn8SapcrkfcnKp_IQiOaLZJDggpuA,141809
11
+ mwx/nutshell.py,sha256=6JC855mDnZ8juWDkQ6DqXaiCJB88GJ4wgqH8VqYfSnM,142028
12
12
  mwx/utilus.py,sha256=Yyw8L1f-ikhyd7wtFXYtsOswofWxmB4GAmLOZnhUXeU,37388
13
13
  mwx/wxmon.py,sha256=yzWqrbY6LzpfRwQeytYUeqFhFuLVm_XEvrVAL_k0HBQ,12756
14
14
  mwx/wxpdb.py,sha256=--TQr-_zs9dWPYV2V4s3Zr4abvN14o5wD8anT9frHUg,18875
@@ -21,8 +21,8 @@ mwx/plugins/frame_listview.py,sha256=gowjQ-ARNonMkDSXkQgPKq4U9YBJ-vQ0jK2krBVOdCs
21
21
  mwx/plugins/line_profile.py,sha256=zzm6_7lnAnNepLbh07ordp3nRWDFQJtu719ZVjrVf8s,819
22
22
  mwx/py/__init__.py,sha256=xykgfOytOwNuvXsfkLoumFZSTN-iBsHOjczYXngjmUE,12
23
23
  mwx/py/filling.py,sha256=fumUG1F5M9TL-Dfqni4G85uk7TmvnUunTbdcPDV0vfo,16857
24
- mwxlib-1.0rc4.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
25
- mwxlib-1.0rc4.dist-info/METADATA,sha256=-ZzR93Ze3uYiaIWArAhSj9NFfTUDcJLxt0xhD-MhaGs,7260
26
- mwxlib-1.0rc4.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
27
- mwxlib-1.0rc4.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
28
- mwxlib-1.0rc4.dist-info/RECORD,,
24
+ mwxlib-1.0.3.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
25
+ mwxlib-1.0.3.dist-info/METADATA,sha256=LnXTIWenG879NSl5xuUgY8rJMXF8B589tXumD0VUzho,7259
26
+ mwxlib-1.0.3.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
27
+ mwxlib-1.0.3.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
28
+ mwxlib-1.0.3.dist-info/RECORD,,