mwxlib 1.3.3__py3-none-any.whl → 1.3.11__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/bookshelf.py +12 -3
- mwx/controls.py +91 -80
- mwx/framework.py +73 -82
- mwx/graphman.py +10 -10
- mwx/matplot2.py +9 -9
- mwx/matplot2g.py +68 -57
- mwx/matplot2lg.py +6 -6
- mwx/nutshell.py +40 -28
- mwx/plugins/ffmpeg_view.py +1 -1
- mwx/wxpdb.py +6 -6
- {mwxlib-1.3.3.dist-info → mwxlib-1.3.11.dist-info}/METADATA +1 -2
- mwxlib-1.3.11.dist-info/RECORD +28 -0
- {mwxlib-1.3.3.dist-info → mwxlib-1.3.11.dist-info}/WHEEL +1 -1
- mwxlib-1.3.3.dist-info/LICENSE +0 -21
- mwxlib-1.3.3.dist-info/RECORD +0 -29
- {mwxlib-1.3.3.dist-info → mwxlib-1.3.11.dist-info}/top_level.txt +0 -0
mwx/bookshelf.py
CHANGED
|
@@ -26,7 +26,9 @@ class MyDropTarget(wx.DropTarget):
|
|
|
26
26
|
items = list(self.tree._gen_items(self.tree.RootItem)) # first level items
|
|
27
27
|
if not item:
|
|
28
28
|
item = items[0]
|
|
29
|
-
|
|
29
|
+
elif item not in items:
|
|
30
|
+
item = self.tree.GetItemParent(item) # Select the parent item
|
|
31
|
+
if item != self.tree.Selection:
|
|
30
32
|
self.tree.SelectItem(item)
|
|
31
33
|
return result
|
|
32
34
|
|
|
@@ -37,6 +39,13 @@ class MyDropTarget(wx.DropTarget):
|
|
|
37
39
|
self.GetData()
|
|
38
40
|
if self.datado.Data:
|
|
39
41
|
fn = self.datado.Data.tobytes().decode()
|
|
42
|
+
if result == wx.DragMove:
|
|
43
|
+
try:
|
|
44
|
+
buf = self.tree._buffer # only for the same process buffer DnD
|
|
45
|
+
buf.parent.kill_buffer(buf) # the focus moves
|
|
46
|
+
wx.CallAfter(self.tree.SetFocus)
|
|
47
|
+
except AttributeError:
|
|
48
|
+
pass
|
|
40
49
|
editor.load_file(fn)
|
|
41
50
|
self.datado.SetData(b"")
|
|
42
51
|
elif self.textdo.Text:
|
|
@@ -56,7 +65,6 @@ class MyDropTarget(wx.DropTarget):
|
|
|
56
65
|
class EditorTreeCtrl(wx.TreeCtrl, CtrlInterface):
|
|
57
66
|
"""TreeList/Ctrl
|
|
58
67
|
|
|
59
|
-
Construct treectrl in the order of tree:list.
|
|
60
68
|
Note:
|
|
61
69
|
This only works with single selection mode.
|
|
62
70
|
"""
|
|
@@ -200,7 +208,6 @@ class EditorTreeCtrl(wx.TreeCtrl, CtrlInterface):
|
|
|
200
208
|
name = self.GetItemText(evt.Item)
|
|
201
209
|
editor = self.Parent.FindWindow(name) # window.Name (not page.caption)
|
|
202
210
|
if not editor.IsShown():
|
|
203
|
-
## editor.SetFocus()
|
|
204
211
|
self.Parent.Selection = self.Parent.FindPage(editor)
|
|
205
212
|
wx.CallAfter(self.SetFocus)
|
|
206
213
|
evt.Skip()
|
|
@@ -208,8 +215,10 @@ class EditorTreeCtrl(wx.TreeCtrl, CtrlInterface):
|
|
|
208
215
|
def OnBeginDrag(self, evt):
|
|
209
216
|
data = self.GetItemData(evt.Item)
|
|
210
217
|
if data:
|
|
218
|
+
self._buffer = data
|
|
211
219
|
dd = wx.CustomDataObject("TreeItem")
|
|
212
220
|
dd.SetData(data.filename.encode())
|
|
213
221
|
dropSource = wx.DropSource()
|
|
214
222
|
dropSource.SetData(dd)
|
|
215
223
|
dropSource.DoDragDrop(wx.Drag_AllowMove) # -> wx.DragResult
|
|
224
|
+
del self._buffer
|
mwx/controls.py
CHANGED
|
@@ -40,6 +40,7 @@ class Param:
|
|
|
40
40
|
- control -> when index is changed by knobs or reset (handler)
|
|
41
41
|
- updated -> when button is pressed (updater)
|
|
42
42
|
- checked -> when tick turns on/off (checker)
|
|
43
|
+
- notified -> when value changed
|
|
43
44
|
- overflow -> when value overflows
|
|
44
45
|
- underflow -> when value underflows
|
|
45
46
|
"""
|
|
@@ -63,6 +64,7 @@ class Param:
|
|
|
63
64
|
'control' : [ _F(handler) ] if handler else [],
|
|
64
65
|
'updated' : [ _F(updater) ] if updater else [],
|
|
65
66
|
'checked' : [ _F(checker) ] if checker else [],
|
|
67
|
+
'notified' : [],
|
|
66
68
|
'overflow' : [],
|
|
67
69
|
'underflow' : [],
|
|
68
70
|
})
|
|
@@ -130,14 +132,10 @@ class Param:
|
|
|
130
132
|
def value(self, v):
|
|
131
133
|
if v is None:
|
|
132
134
|
v = nan
|
|
133
|
-
if np.isnan(v) or np.isinf(v):
|
|
135
|
+
if np.isnan(v) or np.isinf(v): # Skip events for nan and inf.
|
|
134
136
|
self.__value = v
|
|
135
137
|
for knob in self.knobs:
|
|
136
|
-
knob.update_ctrl(None
|
|
137
|
-
return
|
|
138
|
-
elif v == self.__value:
|
|
139
|
-
for knob in self.knobs:
|
|
140
|
-
knob.update_ctrl(True, notify=False)
|
|
138
|
+
knob.update_ctrl(None)
|
|
141
139
|
return
|
|
142
140
|
|
|
143
141
|
## If the value is out of range, it will be modified.
|
|
@@ -152,6 +150,7 @@ class Param:
|
|
|
152
150
|
self.callback('overflow', self)
|
|
153
151
|
for knob in self.knobs:
|
|
154
152
|
knob.update_ctrl(valid, notify=True)
|
|
153
|
+
self.callback('notified', self)
|
|
155
154
|
|
|
156
155
|
@property
|
|
157
156
|
def std_value(self):
|
|
@@ -234,6 +233,7 @@ class LParam(Param):
|
|
|
234
233
|
- control -> when index is changed by knobs or reset (handler)
|
|
235
234
|
- updated -> when button is pressed (updater)
|
|
236
235
|
- checked -> when tick turns on/off (checker)
|
|
236
|
+
- notified -> when value changed
|
|
237
237
|
- overflow -> when value overflows
|
|
238
238
|
- underflow -> when value underflows
|
|
239
239
|
"""
|
|
@@ -289,13 +289,13 @@ class Knob(wx.Panel):
|
|
|
289
289
|
|
|
290
290
|
Args:
|
|
291
291
|
param : <Param> or <LParam> object
|
|
292
|
-
type :
|
|
292
|
+
type : control type (slider[*], [hv]spin, choice, None)
|
|
293
293
|
style : style of label
|
|
294
294
|
None -> static text (default)
|
|
295
295
|
button -> label with flat button
|
|
296
296
|
chkbox -> label with checkbox
|
|
297
297
|
checkbox -> label with checkbox
|
|
298
|
-
cw : width of
|
|
298
|
+
cw : width of control
|
|
299
299
|
lw : width of label
|
|
300
300
|
tw : width of textbox
|
|
301
301
|
h : height of widget (defaults to 22)
|
|
@@ -317,10 +317,8 @@ class Knob(wx.Panel):
|
|
|
317
317
|
style=None, cw=-1, lw=-1, tw=-1, h=22, **kwargs):
|
|
318
318
|
wx.Panel.__init__(self, parent, **kwargs)
|
|
319
319
|
|
|
320
|
-
assert isinstance(param, Param)
|
|
321
|
-
"Argument `param` must be an instance of Param"
|
|
320
|
+
assert isinstance(param, Param), "Argument `param` must be an instance of Param"
|
|
322
321
|
|
|
323
|
-
self.__bit = 1
|
|
324
322
|
self.__par = param
|
|
325
323
|
self.__par.knobs.append(self) # パラメータの関連付けを行う
|
|
326
324
|
|
|
@@ -337,72 +335,72 @@ class Knob(wx.Panel):
|
|
|
337
335
|
label = self.__par.name + ' '
|
|
338
336
|
|
|
339
337
|
if style == 'chkbox' or style == 'checkbox':
|
|
340
|
-
self.
|
|
341
|
-
self.
|
|
338
|
+
self._label = wx.CheckBox(self, label=label, size=(lw,-1))
|
|
339
|
+
self._label.Bind(wx.EVT_CHECKBOX, self.OnCheck)
|
|
342
340
|
elif style == 'button':
|
|
343
|
-
self.
|
|
344
|
-
|
|
345
|
-
self.
|
|
341
|
+
self._label = pb.PlateButton(self, label=label, size=(lw,-1),
|
|
342
|
+
style=pb.PB_STYLE_DEFAULT|pb.PB_STYLE_SQUARE)
|
|
343
|
+
self._label.Bind(wx.EVT_BUTTON, self.OnPress)
|
|
346
344
|
elif not style:
|
|
347
|
-
self.
|
|
345
|
+
self._label = wx.StaticText(self, label=label, size=(lw,-1))
|
|
348
346
|
else:
|
|
349
|
-
raise Exception("unknown style: {!r}"
|
|
347
|
+
raise Exception(f"unknown style: {style!r}")
|
|
350
348
|
|
|
351
|
-
self.
|
|
352
|
-
self.
|
|
353
|
-
self.
|
|
349
|
+
self._label.Bind(wx.EVT_MIDDLE_DOWN, lambda v: self.__par.reset())
|
|
350
|
+
self._label.SetToolTip(self.__par._tooltip)
|
|
351
|
+
self._label.Enable(lw) # skip focus
|
|
354
352
|
|
|
355
|
-
self.
|
|
356
|
-
self.
|
|
357
|
-
self.
|
|
358
|
-
self.
|
|
359
|
-
self.
|
|
360
|
-
self.
|
|
361
|
-
self.
|
|
353
|
+
self._text = wx.TextCtrl(self, size=(tw,h), style=wx.TE_PROCESS_ENTER)
|
|
354
|
+
self._text.Bind(wx.EVT_TEXT_ENTER, self.OnTextEnter)
|
|
355
|
+
self._text.Bind(wx.EVT_KILL_FOCUS, self.OnTextExit)
|
|
356
|
+
self._text.Bind(wx.EVT_KEY_DOWN, self.OnTextKeyDown)
|
|
357
|
+
self._text.Bind(wx.EVT_KEY_UP, self.OnTextKeyUp)
|
|
358
|
+
self._text.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)
|
|
359
|
+
self._text.Bind(wx.EVT_MIDDLE_DOWN, lambda v: self.__par.reset())
|
|
362
360
|
|
|
363
|
-
self.
|
|
361
|
+
self._text.Enable(tw) # skip focus
|
|
364
362
|
|
|
365
363
|
if type == 'slider':
|
|
366
|
-
self.
|
|
367
|
-
self.
|
|
368
|
-
self.
|
|
369
|
-
self.
|
|
364
|
+
self._ctrl = wx.Slider(self, size=(cw,h), style=wx.SL_HORIZONTAL)
|
|
365
|
+
self._ctrl.Bind(wx.EVT_SCROLL_CHANGED, self.OnScroll)
|
|
366
|
+
self._ctrl.Bind(wx.EVT_KEY_DOWN, self.OnCtrlKeyDown)
|
|
367
|
+
self._ctrl.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)
|
|
370
368
|
|
|
371
369
|
elif type == 'slider*':
|
|
372
|
-
self.
|
|
373
|
-
self.
|
|
374
|
-
self.
|
|
375
|
-
self.
|
|
376
|
-
self.
|
|
370
|
+
self._ctrl = wx.Slider(self, size=(cw,h), style=wx.SL_HORIZONTAL)
|
|
371
|
+
self._ctrl.Bind(wx.EVT_SCROLL, self.OnScroll) # called while dragging
|
|
372
|
+
self._ctrl.Bind(wx.EVT_SCROLL_CHANGED, lambda v: None) # pass no action
|
|
373
|
+
self._ctrl.Bind(wx.EVT_KEY_DOWN, self.OnCtrlKeyDown)
|
|
374
|
+
self._ctrl.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)
|
|
377
375
|
|
|
378
376
|
elif type == 'spin' or type =='hspin':
|
|
379
|
-
self.
|
|
380
|
-
self.
|
|
381
|
-
self.
|
|
377
|
+
self._ctrl = wx.SpinButton(self, size=(cw,h), style=wx.SP_HORIZONTAL)
|
|
378
|
+
self._ctrl.Bind(wx.EVT_SPIN, self.OnScroll)
|
|
379
|
+
self._ctrl.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)
|
|
382
380
|
|
|
383
381
|
elif type == 'vspin':
|
|
384
|
-
self.
|
|
385
|
-
self.
|
|
386
|
-
self.
|
|
382
|
+
self._ctrl = wx.SpinButton(self, size=(cw,h), style=wx.SP_VERTICAL)
|
|
383
|
+
self._ctrl.Bind(wx.EVT_SPIN, self.OnScroll)
|
|
384
|
+
self._ctrl.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)
|
|
387
385
|
|
|
388
386
|
elif type == 'choice':
|
|
389
|
-
self.
|
|
390
|
-
self.
|
|
391
|
-
self.
|
|
392
|
-
self.
|
|
387
|
+
self._ctrl = wx.Choice(self, size=(cw,h))
|
|
388
|
+
self._ctrl.Bind(wx.EVT_CHOICE, self.OnScroll)
|
|
389
|
+
self._ctrl.SetValue = self._ctrl.SetSelection # setter of choice
|
|
390
|
+
self._ctrl.GetValue = self._ctrl.GetSelection # getter (ditto)
|
|
393
391
|
|
|
394
392
|
else:
|
|
395
|
-
raise Exception("unknown type: {!r}"
|
|
393
|
+
raise Exception(f"unknown type: {type!r}")
|
|
396
394
|
|
|
397
|
-
self.
|
|
398
|
-
self.
|
|
395
|
+
self._ctrl.Bind(wx.EVT_MIDDLE_DOWN, lambda v: self.__par.reset())
|
|
396
|
+
self._ctrl.Enable(cw) # skip focus
|
|
399
397
|
|
|
400
398
|
c = (cw and type != 'vspin')
|
|
401
399
|
self.SetSizer(
|
|
402
400
|
pack(self, (
|
|
403
|
-
(self.
|
|
404
|
-
(self.
|
|
405
|
-
(self.
|
|
401
|
+
(self._label, 0, wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT, lw and 1),
|
|
402
|
+
(self._text, 0, wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT, tw and 1),
|
|
403
|
+
(self._ctrl, c, wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT, cw and 1),
|
|
406
404
|
))
|
|
407
405
|
)
|
|
408
406
|
self.update_range()
|
|
@@ -417,33 +415,33 @@ class Knob(wx.Panel):
|
|
|
417
415
|
def update_range(self):
|
|
418
416
|
"""Called when range is being changed (internal use only)."""
|
|
419
417
|
v = self.__par
|
|
420
|
-
if isinstance(self.
|
|
418
|
+
if isinstance(self._ctrl, wx.Choice): #<wx.Choice>
|
|
421
419
|
items = [v.__str__(x) for x in v.range]
|
|
422
|
-
if items != self.
|
|
423
|
-
self.
|
|
424
|
-
self.
|
|
420
|
+
if items != self._ctrl.Items:
|
|
421
|
+
self._ctrl.SetItems(items)
|
|
422
|
+
self._ctrl.SetStringSelection(str(v))
|
|
425
423
|
else:
|
|
426
|
-
self.
|
|
424
|
+
self._ctrl.SetRange(0, len(v)-1) #<wx.Slider> #<wx.SpinButton>
|
|
427
425
|
|
|
428
426
|
def update_label(self):
|
|
429
427
|
"""Called when label is being changed (internal use only)."""
|
|
430
428
|
v = self.__par
|
|
431
|
-
if isinstance(self.
|
|
432
|
-
self.
|
|
429
|
+
if isinstance(self._label, wx.CheckBox):
|
|
430
|
+
self._label.SetValue(v.check)
|
|
433
431
|
|
|
434
432
|
t = ' ' if np.isnan(v.std_value) or v.value == v.std_value else '*'
|
|
435
|
-
self.
|
|
436
|
-
self.
|
|
433
|
+
self._label.SetLabel(v.name + t)
|
|
434
|
+
self._label.Refresh()
|
|
437
435
|
self.Refresh()
|
|
438
436
|
|
|
439
437
|
def update_ctrl(self, valid=True, notify=False):
|
|
440
438
|
"""Called when value is being changed (internal use only)."""
|
|
441
439
|
v = self.__par
|
|
442
|
-
self.
|
|
443
|
-
wx.CallAfter(self.
|
|
440
|
+
self._ctrl.SetValue(v.index)
|
|
441
|
+
wx.CallAfter(self._text.SetValue, str(v)) # for wxAssertionError
|
|
444
442
|
if valid:
|
|
445
443
|
if notify:
|
|
446
|
-
if self.
|
|
444
|
+
if self._text.BackgroundColour != '#ffff80':
|
|
447
445
|
wx.CallAfter(wx.CallLater, 1000,
|
|
448
446
|
self.set_textcolour, '#ffffff')
|
|
449
447
|
self.set_textcolour('#ffff80') # light-yellow
|
|
@@ -459,8 +457,8 @@ class Knob(wx.Panel):
|
|
|
459
457
|
|
|
460
458
|
def set_textcolour(self, c):
|
|
461
459
|
if self:
|
|
462
|
-
self.
|
|
463
|
-
self.
|
|
460
|
+
self._text.BackgroundColour = c
|
|
461
|
+
self._text.Refresh()
|
|
464
462
|
|
|
465
463
|
def shift_ctrl(self, evt, bit):
|
|
466
464
|
"""Called when a key/mouse wheel is pressed/scrolled.
|
|
@@ -474,14 +472,14 @@ class Knob(wx.Panel):
|
|
|
474
472
|
if evt.ControlDown(): bit *= 16
|
|
475
473
|
if evt.AltDown(): bit *= 256
|
|
476
474
|
v = self.__par
|
|
477
|
-
j = self.
|
|
475
|
+
j = self._ctrl.GetValue() + bit
|
|
478
476
|
if j != v.index:
|
|
479
477
|
v.index = j
|
|
480
478
|
v.reset(v.value)
|
|
481
479
|
|
|
482
480
|
def OnScroll(self, evt): #<wx._core.ScrollEvent> #<wx._controls.SpinEvent> #<wx._core.CommandEvent>
|
|
483
481
|
v = self.__par
|
|
484
|
-
j = self.
|
|
482
|
+
j = self._ctrl.GetValue()
|
|
485
483
|
if j != v.index:
|
|
486
484
|
v.index = j
|
|
487
485
|
v.reset(v.value)
|
|
@@ -497,8 +495,8 @@ class Knob(wx.Panel):
|
|
|
497
495
|
if key == wx.WXK_RIGHT: return self.shift_ctrl(evt, 1)
|
|
498
496
|
|
|
499
497
|
def _focus(c):
|
|
500
|
-
if isinstance(c, Knob) and c.
|
|
501
|
-
c.
|
|
498
|
+
if isinstance(c, Knob) and c._ctrl.IsEnabled():
|
|
499
|
+
c._ctrl.SetFocus()
|
|
502
500
|
return True
|
|
503
501
|
|
|
504
502
|
ls = next(x for x in self.Parent.layout_groups if self in x)
|
|
@@ -519,11 +517,11 @@ class Knob(wx.Panel):
|
|
|
519
517
|
|
|
520
518
|
def OnTextEnter(self, evt): #<wx._core.CommandEvent>
|
|
521
519
|
evt.Skip()
|
|
522
|
-
x = self.
|
|
520
|
+
x = self._text.Value.strip()
|
|
523
521
|
self.__par.reset(x)
|
|
524
522
|
|
|
525
523
|
def OnTextExit(self, evt): #<wx._core.FocusEvent>
|
|
526
|
-
x = self.
|
|
524
|
+
x = self._text.Value.strip()
|
|
527
525
|
if x != str(self.__par):
|
|
528
526
|
self.__par.reset(x)
|
|
529
527
|
evt.Skip()
|
|
@@ -537,9 +535,9 @@ class Knob(wx.Panel):
|
|
|
537
535
|
evt.Skip()
|
|
538
536
|
|
|
539
537
|
def Enable(self, p=True):
|
|
540
|
-
self.
|
|
541
|
-
self.
|
|
542
|
-
self.
|
|
538
|
+
self._label.Enable(p)
|
|
539
|
+
self._ctrl.Enable(p)
|
|
540
|
+
self._text.Enable(p)
|
|
543
541
|
|
|
544
542
|
|
|
545
543
|
class KnobCtrlPanel(scrolled.ScrolledPanel):
|
|
@@ -1086,6 +1084,8 @@ class TextBox(wx.Control):
|
|
|
1086
1084
|
if updater:
|
|
1087
1085
|
self._updater = _F(updater)
|
|
1088
1086
|
self._btn.Bind(wx.EVT_BUTTON, lambda v: self._updater(self))
|
|
1087
|
+
|
|
1088
|
+
self.Bind(wx.EVT_NAVIGATION_KEY, self.OnNavKey)
|
|
1089
1089
|
|
|
1090
1090
|
def reset(self, v):
|
|
1091
1091
|
try:
|
|
@@ -1093,9 +1093,12 @@ class TextBox(wx.Control):
|
|
|
1093
1093
|
self._handler(self)
|
|
1094
1094
|
except AttributeError:
|
|
1095
1095
|
pass
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1096
|
+
|
|
1097
|
+
def OnNavKey(self, evt):
|
|
1098
|
+
if evt.EventObject is self._ctrl:
|
|
1099
|
+
self.Navigate(evt.Direction)
|
|
1100
|
+
elif self.IsShown():
|
|
1101
|
+
self._ctrl.SetFocus()
|
|
1099
1102
|
|
|
1100
1103
|
|
|
1101
1104
|
class Choice(wx.Control):
|
|
@@ -1159,6 +1162,8 @@ class Choice(wx.Control):
|
|
|
1159
1162
|
if updater:
|
|
1160
1163
|
self._updater = _F(updater)
|
|
1161
1164
|
self._btn.Bind(wx.EVT_BUTTON, lambda v: self._updater(self))
|
|
1165
|
+
|
|
1166
|
+
self.Bind(wx.EVT_NAVIGATION_KEY, self.OnNavKey)
|
|
1162
1167
|
|
|
1163
1168
|
def reset(self, v):
|
|
1164
1169
|
try:
|
|
@@ -1175,6 +1180,12 @@ class Choice(wx.Control):
|
|
|
1175
1180
|
self._ctrl.Append(s)
|
|
1176
1181
|
self._ctrl.SetStringSelection(s)
|
|
1177
1182
|
evt.Skip()
|
|
1183
|
+
|
|
1184
|
+
def OnNavKey(self, evt):
|
|
1185
|
+
if evt.EventObject is self._ctrl:
|
|
1186
|
+
self.Navigate(evt.Direction)
|
|
1187
|
+
elif self.IsShown():
|
|
1188
|
+
self._ctrl.SetFocus()
|
|
1178
1189
|
|
|
1179
1190
|
|
|
1180
1191
|
class Indicator(wx.Control):
|