mwxlib 1.0.4__py3-none-any.whl → 1.0.8__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
@@ -426,7 +426,7 @@ class Knob(wx.Panel):
426
426
  self.ctrl.SetItems(items)
427
427
  self.ctrl.SetStringSelection(str(v))
428
428
  else:
429
- self.ctrl.SetRange(0, len(v)-1) #<wx.Slider> <wx.SpinButton>
429
+ self.ctrl.SetRange(0, len(v)-1) #<wx.Slider> #<wx.SpinButton>
430
430
 
431
431
  def update_label(self):
432
432
  """Called when label is being changed (internal use only)."""
@@ -482,7 +482,7 @@ class Knob(wx.Panel):
482
482
  v.index = j
483
483
  v.reset(v.value)
484
484
 
485
- def OnScroll(self, evt): #<wx._core.ScrollEvent><wx._controls.SpinEvent><wx._core.CommandEvent>
485
+ def OnScroll(self, evt): #<wx._core.ScrollEvent> #<wx._controls.SpinEvent> #<wx._core.CommandEvent>
486
486
  v = self.__par
487
487
  j = self.ctrl.GetValue()
488
488
  if j != v.index:
mwx/framework.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #! python3
2
2
  """mwxlib framework.
3
3
  """
4
- __version__ = "1.0.4"
4
+ __version__ = "1.0.8"
5
5
  __author__ = "Kazuya O'moto <komoto@jeol.co.jp>"
6
6
 
7
7
  from contextlib import contextmanager
@@ -266,8 +266,7 @@ class KeyCtrlInterfaceMixin:
266
266
  ## Check text selection for [C-c/C-x].
267
267
  wnd = wx.Window.FindFocus()
268
268
  if isinstance(wnd, wx.TextEntry) and wnd.StringSelection\
269
- or isinstance(wnd, stc.StyledTextCtrl) and wnd.SelectedText:
270
- ## or any other of pre-selection-p?
269
+ or isinstance(wnd, stc.StyledTextCtrl) and wnd.SelectedText:
271
270
  self.handler('quit', evt)
272
271
  else:
273
272
  self.message(evt.key + '-')
@@ -275,6 +274,9 @@ class KeyCtrlInterfaceMixin:
275
274
 
276
275
  def post_command_hook(self, evt):
277
276
  """Called when exiting extension mode (internal use only)."""
277
+ ## Check if the event has reached a top-level window.
278
+ if isinstance(self, wx.TopLevelWindow):
279
+ return
278
280
  keymap = self.handler.previous_state
279
281
  if keymap:
280
282
  self.message("{} {}".format(keymap, evt.key))
@@ -395,9 +397,9 @@ class CtrlInterface(KeyCtrlInterfaceMixin):
395
397
 
396
398
  def on_hotkey_press(self, evt): #<wx._core.KeyEvent>
397
399
  """Called when a key is pressed."""
398
- if evt.EventObject is not self:
399
- evt.Skip()
400
- return
400
+ ## if evt.EventObject is not self:
401
+ ## evt.Skip()
402
+ ## return
401
403
  key = hotkey(evt)
402
404
  self.__key = regulate_key(key + '-')
403
405
  if self.handler('{} pressed'.format(key), evt) is None:
@@ -729,11 +731,6 @@ class Frame(wx.Frame, KeyCtrlInterfaceMixin):
729
731
 
730
732
  message = property(lambda self: self.statusbar)
731
733
 
732
- def post_command_hook(self, evt):
733
- ## (override) Don't skip events as a TopLevelWindow.
734
- pass
735
- post_command_hook.__name__ = str('noskip')
736
-
737
734
  def __init__(self, *args, **kwargs):
738
735
  wx.Frame.__init__(self, *args, **kwargs)
739
736
 
@@ -808,11 +805,6 @@ class MiniFrame(wx.MiniFrame, KeyCtrlInterfaceMixin):
808
805
 
809
806
  message = property(lambda self: self.statusbar)
810
807
 
811
- def post_command_hook(self, evt):
812
- ## (override) Don't skip events as a TopLevelWindow.
813
- pass
814
- post_command_hook.__name__ = str('noskip')
815
-
816
808
  def __init__(self, *args, **kwargs):
817
809
  wx.MiniFrame.__init__(self, *args, **kwargs)
818
810
 
mwx/graphman.py CHANGED
@@ -261,6 +261,12 @@ class LayerInterface(CtrlInterface):
261
261
  ## thread_type = Thread
262
262
  thread = None
263
263
 
264
+ ## layout helper function (internal use only)
265
+ pack = mwx.pack
266
+
267
+ ## funcall = interactive_call (internal use only)
268
+ funcall = staticmethod(_F)
269
+
264
270
  ## for debug (internal use only)
265
271
  pane = property(lambda self: self.parent.get_pane(self))
266
272
 
mwx/matplot2.py CHANGED
@@ -160,6 +160,12 @@ class MatplotPanel(wx.Panel):
160
160
  if self.handler.fork(self.handler.current_event, evt) is None:
161
161
  evt.Skip()
162
162
 
163
+ def skip(evt): #<wx._core.KeyEvent> #<matplotlib.backend_bases.MouseEvent>
164
+ try:
165
+ evt.Skip()
166
+ except AttributeError:
167
+ pass
168
+
163
169
  self.__handler = FSM({ # DNA<MatplotPanel>
164
170
  None : {
165
171
  'canvas_draw' : [ None, self.OnDraw ], # before canvas.draw
@@ -188,6 +194,7 @@ class MatplotPanel(wx.Panel):
188
194
  'space pressed' : (PAN, self.OnPanBegin),
189
195
  'ctrl pressed' : (PAN, self.OnPanBegin),
190
196
  'z pressed' : (ZOOM, self.OnZoomBegin),
197
+ '* pressed' : (NORMAL, skip),
191
198
  'xaxis motion' : (XAXIS, self.OnAxisEnter),
192
199
  'yaxis motion' : (YAXIS, self.OnAxisEnter),
193
200
  'y2axis motion' : (YAXIS, self.OnAxisEnter),
mwx/matplot2g.py CHANGED
@@ -48,6 +48,8 @@ def _to_buffer(img):
48
48
  if isinstance(img, wx.Image): # image to RGB array; RGB to grayscale
49
49
  w, h = img.GetSize()
50
50
  img = np.frombuffer(img.GetDataBuffer(), dtype='uint8').reshape(h, w, 3)
51
+
52
+ if img.ndim > 2:
51
53
  return cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
52
54
  return img
53
55
 
mwx/nutshell.py CHANGED
@@ -1785,16 +1785,6 @@ class Buffer(EditorInterface, EditWindow):
1785
1785
  """
1786
1786
  return self.mtdelta is not None and self.mtdelta > 0
1787
1787
 
1788
- def pre_command_hook(self, evt):
1789
- self.parent.handler(self.handler.current_event, evt)
1790
- return EditorInterface.pre_command_hook(self, evt)
1791
- pre_command_hook.__name__ = str('pre_command_dispatch') # alias
1792
-
1793
- def post_command_hook(self, evt):
1794
- self.parent.handler(self.handler.current_event, evt)
1795
- return EditorInterface.post_command_hook(self, evt)
1796
- post_command_hook.__name__ = str('post_command_dispatch') # alias
1797
-
1798
1788
  def __init__(self, parent, filename, **kwargs):
1799
1789
  EditWindow.__init__(self, parent, **kwargs)
1800
1790
  EditorInterface.__init__(self)
@@ -1847,7 +1837,7 @@ class Buffer(EditorInterface, EditWindow):
1847
1837
  """Fork events to the parent."""
1848
1838
  self.parent.handler(self.handler.current_event, evt)
1849
1839
 
1850
- ## Note: Key events are not propagated from Buffer to EditorBook.
1840
+ ## Note: Mouse events are not propagated from Buffer to EditorBook.
1851
1841
  ## They are explicitly dispatched from buffer.handler to editor.handler.
1852
1842
 
1853
1843
  self.handler.update({ # DNA<Buffer>
@@ -1867,8 +1857,9 @@ class Buffer(EditorInterface, EditWindow):
1867
1857
  '*[LR]win pressed' : (-1, ),
1868
1858
  },
1869
1859
  0 : { # Normal mode
1870
- '* pressed' : (0, skip, dispatch),
1860
+ '* pressed' : (0, skip),
1871
1861
  '* released' : (0, skip, dispatch),
1862
+ '*button* pressed' : (0, skip, dispatch),
1872
1863
  'escape pressed' : (-1, self.on_enter_escmap),
1873
1864
  'C-h pressed' : (0, self.call_helpTip),
1874
1865
  '. pressed' : (2, self.OnEnterDot),
@@ -2209,10 +2200,11 @@ class EditorBook(AuiNotebook, CtrlInterface):
2209
2200
  'buffer_activated' : [ None, dispatch, self.on_activated ],
2210
2201
  'buffer_inactivated' : [ None, dispatch, self.on_inactivated ],
2211
2202
  'buffer_caption_updated' : [ None, dispatch ],
2212
- '*button* pressed' : [ None, dispatch, skip ],
2213
- '*button* released' : [ None, dispatch, skip ],
2214
2203
  },
2215
2204
  0 : { # Normal mode
2205
+ '* pressed' : (0, skip),
2206
+ '* released' : (0, skip, dispatch),
2207
+ '*button* pressed' : (0, skip, dispatch),
2216
2208
  'M-up pressed' : (0, _F(self.previous_buffer)),
2217
2209
  'M-down pressed' : (0, _F(self.next_buffer)),
2218
2210
  },
@@ -2817,8 +2809,6 @@ class Nautilus(EditorInterface, Shell):
2817
2809
  'shell_modified' : [ None, dispatch ],
2818
2810
  'shell_activated' : [ None, dispatch, self.on_activated ],
2819
2811
  'shell_inactivated' : [ None, dispatch, self.on_inactivated ],
2820
- '*button* pressed' : [ None, dispatch, skip ],
2821
- '*button* released' : [ None, dispatch, skip ],
2822
2812
  },
2823
2813
  -1 : { # original action of the wx.py.shell
2824
2814
  '* pressed' : (0, skip, self.on_exit_escmap),
@@ -2835,7 +2825,8 @@ class Nautilus(EditorInterface, Shell):
2835
2825
  },
2836
2826
  0 : { # Normal mode
2837
2827
  '* pressed' : (0, skip),
2838
- '* released' : (0, skip),
2828
+ '* released' : (0, skip, dispatch),
2829
+ '*button* pressed' : (0, skip, dispatch),
2839
2830
  'escape pressed' : (-1, self.on_enter_escmap),
2840
2831
  'space pressed' : (0, self.OnSpace),
2841
2832
  '*backspace pressed' : (0, self.OnBackspace),
@@ -109,8 +109,8 @@ class Plugin(Layer):
109
109
  self.snp = Button(self, handler=self.snapshot, icon='clip')
110
110
  self.exp = Button(self, handler=self.export, icon='save')
111
111
 
112
- self.rw = Button(self, handler=lambda v: self.seekdelta(-100), icon='|<-')
113
- self.fw = Button(self, handler=lambda v: self.seekdelta(+100), icon='->|')
112
+ self.rw = Button(self, handler=lambda v: self.seekto(-100), icon='|<-')
113
+ self.fw = Button(self, handler=lambda v: self.seekto(+100), icon='->|')
114
114
 
115
115
  self.layout((self.mc,), expand=2)
116
116
  self.layout((self.ss, self.to, self.rw, self.fw,
@@ -130,14 +130,24 @@ class Plugin(Layer):
130
130
  self.parent.handler.bind("unknown_format", self.load_media)
131
131
 
132
132
  self.handler.update({ # DNA<ffmpeg_viewer>
133
- 0 : {
134
- 'play' : (1, ),
135
- 'space pressed' : (1, _F(self.mc.Play)),
133
+ 0 : { # MEDIASTATE_STOPPED
134
+ 'play' : (2, ),
135
+ 'space pressed' : (2, _F(self.mc.Play)),
136
+ 'left pressed' : (0, _F(self.seekd, -1000)),
137
+ 'right pressed' : (0, _F(self.seekd, 1000)),
136
138
  },
137
- 1 : {
139
+ 1 : { # MEDIASTATE_PAUSED
138
140
  'stop' : (0, ),
139
- 'pause' : (0, ),
141
+ 'space pressed' : (2, _F(self.mc.Play)),
142
+ 'left pressed' : (1, _F(self.seekd, -1000)),
143
+ 'right pressed' : (1, _F(self.seekd, 1000)),
144
+ },
145
+ 2 : { # MEDIASTATE_PLAYING
146
+ 'stop' : (0, ),
147
+ 'pause' : (1, ),
140
148
  'space pressed' : (1, _F(self.mc.Pause)),
149
+ 'left pressed' : (2, _F(self.seekd, -1000)),
150
+ 'right pressed' : (2, _F(self.seekd, 1000)),
141
151
  },
142
152
  })
143
153
 
@@ -145,10 +155,8 @@ class Plugin(Layer):
145
155
  self.mc.Bind(wx.media.EVT_MEDIA_PLAY, partial(self.handler, 'play'))
146
156
  self.mc.Bind(wx.media.EVT_MEDIA_STOP, partial(self.handler, 'stop'))
147
157
 
148
- ## self.mc.Bind(wx.EVT_KEY_DOWN, self.on_hotkey_down)
149
- ## self.mc.Bind(wx.EVT_KEY_UP, self.on_hotkey_up)
150
- self.mc.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
151
- self.mc.Bind(wx.EVT_KEY_UP, self.OnKeyUp)
158
+ self.mc.Bind(wx.EVT_KEY_DOWN, self.on_hotkey_down)
159
+ self.mc.Bind(wx.EVT_KEY_UP, self.on_hotkey_up)
152
160
 
153
161
  self.Bind(wx.EVT_SHOW, self.OnShow)
154
162
 
@@ -158,14 +166,6 @@ class Plugin(Layer):
158
166
  finally:
159
167
  return Layer.Destroy(self)
160
168
 
161
- def OnKeyDown(self, evt):
162
- if self.handler('{} pressed'.format(hotkey(evt)), evt) is None:
163
- evt.Skip()
164
-
165
- def OnKeyUp(self, evt):
166
- if self.handler('{} released'.format(hotkey(evt)), evt) is None:
167
- evt.Skip()
168
-
169
169
  def OnShow(self, evt):
170
170
  if not evt.IsShown():
171
171
  if self.mc:
@@ -250,18 +250,24 @@ class Plugin(Layer):
250
250
  crop = "{}:{}:0:0".format(*self.video_size)
251
251
  self.crop.Value = crop
252
252
 
253
- def seekdelta(self, offset):
254
- """Seek relative position [ms]."""
255
- if wx.GetKeyState(wx.WXK_SHIFT):
256
- offset /= 10
253
+ def seekto(self, offset):
254
+ """Seek position with offset [ms] from the `to` position."""
257
255
  try:
258
256
  t = self.to.value + offset/1000
259
- except Exception as e:
260
- print(e)
261
- else:
262
- if self._path and 0 <= t < self.video_dur:
257
+ if 0 <= t < self.video_dur:
263
258
  self.to.value = round(t, 3)
264
- self.set_offset(self.to) # => seek
259
+ self.set_offset(self.to)
260
+ except AttributeError:
261
+ pass
262
+
263
+ def seekd(self, offset):
264
+ """Seek position with offset [ms] from the current position."""
265
+ try:
266
+ t = self.mc.Tell() + offset
267
+ if 0 <= t < self.video_dur * 1000:
268
+ self.mc.Seek(self.DELTA + t)
269
+ except AttributeError:
270
+ pass
265
271
 
266
272
  def snapshot(self):
267
273
  """Create a snapshot of the current frame.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mwxlib
3
- Version: 1.0.4
3
+ Version: 1.0.8
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,28 +1,28 @@
1
1
  mwx/__init__.py,sha256=psabnAMei5VzB2TsB2qBNLrIZMX0LiqjlXCpNGmDejk,668
2
2
  mwx/bookshelf.py,sha256=so-xSLq08sMlJBErTxOaDoKUAMa_g1CkIP2pNnff68c,5607
3
- mwx/controls.py,sha256=iXNTk4ge6sHStenjxC7bFKgQHvqxMwfb82IbgiDmtEk,47944
4
- mwx/framework.py,sha256=PZwNHchv_Z1sDUaPTR1d90Bt0UV6mNx_X53Nnekd0tA,75809
5
- mwx/graphman.py,sha256=mDnhy3jAzZCo8_p6ZcA-NDPMuOyW_R2r_fuxUIAM7D8,69669
3
+ mwx/controls.py,sha256=cNZkgwSv90lPIz61FvMtYxHIt8hJD_RQYXxsgTQIdLc,47949
4
+ mwx/framework.py,sha256=7UOFDQD5cBnJSpjGtBJ6nEfQj4lPbnLHLGYh2o0YX_4,75565
5
+ mwx/graphman.py,sha256=04bEw7TEIs6X1QrgqBSLJoIhJnW5TwHTW_wZOvJYSwo,69840
6
6
  mwx/images.py,sha256=oxCn0P-emiWujSS2gUgU5TUnr5cPjix2jBcjOBDr24I,48701
7
- mwx/matplot2.py,sha256=zA56jIdRUdzu-wrmPai1PSOjzqV2Erqw2yFKW-jwdA8,32901
8
- mwx/matplot2g.py,sha256=diwWNxzyy-c8KBDaolHaMqWdFXSYhEumgwXIZ9wAEYk,64467
7
+ mwx/matplot2.py,sha256=RuVWXC2A_qgZRNmBBptbHDn5MyxaWBqp3ru4bP_lDE0,33150
8
+ mwx/matplot2g.py,sha256=4G5uZJZzATEC3QEVZ4pGHetEDfu5NJNUFyeAaQScK5s,64495
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=blsRL7RDJ3C4Dkiq6Jg09INF1ROfEdWi274IohR2Lpk,142048
11
+ mwx/nutshell.py,sha256=-6EUNTpbbcaAt1ftYEgm19MySeAOasyFjPfw_G933E8,141602
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
15
15
  mwx/wxwil.py,sha256=hhyB1lPrF9ixeObxCOKQv0Theu-B-kpJg_yVU3EGSNg,5406
16
16
  mwx/wxwit.py,sha256=1hHtMi2YEy2T_LnUpwdmrIdtCuvxMOFyykqnbq6jLP0,7294
17
17
  mwx/plugins/__init__.py,sha256=jnJ-Sl9XJ_7BFDslD_r7dsbxsOT57q_IaEriV53XIGY,41
18
- mwx/plugins/ffmpeg_view.py,sha256=ZKkSLpyuzpVuRbaPib04rChzlwAifNp3pcgxABeqE4k,10693
18
+ mwx/plugins/ffmpeg_view.py,sha256=Yp1BMeNfkTTPwykvWW1_h4wrvhBSeBUdAvKhnMQIa6g,11102
19
19
  mwx/plugins/fft_view.py,sha256=08A_Y73XirV7kXpwf-v0mUA0Hr0MOfdMXv3tvL1hvWA,2789
20
20
  mwx/plugins/frame_listview.py,sha256=gowjQ-ARNonMkDSXkQgPKq4U9YBJ-vQ0jK2krBVOdCs,10420
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.0.4.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
25
- mwxlib-1.0.4.dist-info/METADATA,sha256=xUi5IB8tDvqX39GOIY2xmz-W765moTc-xpV_9G9eGLs,7259
26
- mwxlib-1.0.4.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
27
- mwxlib-1.0.4.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
28
- mwxlib-1.0.4.dist-info/RECORD,,
24
+ mwxlib-1.0.8.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
25
+ mwxlib-1.0.8.dist-info/METADATA,sha256=wDntpV53vitECSUlpXqzoxKAr4Fhm1FwTexuDJrtavM,7259
26
+ mwxlib-1.0.8.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
27
+ mwxlib-1.0.8.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
28
+ mwxlib-1.0.8.dist-info/RECORD,,
File without changes