mwxlib 1.0.0__py3-none-any.whl → 1.7.13__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.
- mwx/__init__.py +6 -4
- mwx/bookshelf.py +133 -57
- mwx/controls.py +441 -375
- mwx/framework.py +531 -513
- mwx/graphman.py +683 -677
- mwx/images.py +16 -0
- mwx/matplot2.py +225 -216
- mwx/matplot2g.py +735 -652
- mwx/matplot2lg.py +192 -183
- mwx/mgplt.py +20 -22
- mwx/nutshell.py +1063 -939
- mwx/plugins/ffmpeg_view.py +74 -75
- mwx/plugins/fft_view.py +13 -15
- mwx/plugins/frame_listview.py +55 -52
- mwx/plugins/line_profile.py +1 -1
- mwx/py/filling.py +9 -8
- mwx/testsuite.py +38 -0
- mwx/utilus.py +273 -210
- mwx/wxmon.py +39 -38
- mwx/wxpdb.py +81 -83
- mwx/wxwil.py +18 -18
- mwx/wxwit.py +32 -35
- {mwxlib-1.0.0.dist-info → mwxlib-1.7.13.dist-info}/METADATA +12 -5
- mwxlib-1.7.13.dist-info/RECORD +28 -0
- {mwxlib-1.0.0.dist-info → mwxlib-1.7.13.dist-info}/WHEEL +1 -1
- mwxlib-1.0.0.dist-info/LICENSE +0 -21
- mwxlib-1.0.0.dist-info/RECORD +0 -28
- {mwxlib-1.0.0.dist-info → mwxlib-1.7.13.dist-info}/top_level.txt +0 -0
mwx/__init__.py
CHANGED
|
@@ -8,11 +8,13 @@ from .framework import Frame, MiniFrame, ShellFrame, deb
|
|
|
8
8
|
|
|
9
9
|
## Controls
|
|
10
10
|
from .controls import Param, LParam, Knob, ControlPanel, Clipboard, Icon
|
|
11
|
-
from .controls import Button, ToggleButton, ClassicButton,
|
|
11
|
+
from .controls import Button, ToggleButton, ClassicButton, TextBox, Choice, Gauge, Indicator
|
|
12
12
|
|
|
13
13
|
## Plugman
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
# from .graphman import Frame as GraphmanFrame, Layer, Thread, Graph
|
|
15
|
+
# from .matplot2 import MatplotPanel
|
|
16
|
+
# from .matplot2g import GraphPlot
|
|
17
|
+
# from .matplot2lg import LinePlot, LineProfile, Histogram
|
|
16
18
|
|
|
17
19
|
## Gnuplot
|
|
18
|
-
|
|
20
|
+
# from .mgplt import Gnuplot, GnuplotFrame
|
mwx/bookshelf.py
CHANGED
|
@@ -2,13 +2,73 @@
|
|
|
2
2
|
import re
|
|
3
3
|
import wx
|
|
4
4
|
|
|
5
|
-
from .framework import CtrlInterface
|
|
5
|
+
from .framework import CtrlInterface
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class MyDropTarget(wx.DropTarget):
|
|
9
|
+
"""DnD loader for files and URL text.
|
|
10
|
+
"""
|
|
11
|
+
def __init__(self, tree):
|
|
12
|
+
wx.DropTarget.__init__(self)
|
|
13
|
+
|
|
14
|
+
self.tree = tree
|
|
15
|
+
self.datado = wx.CustomDataObject("TreeItem")
|
|
16
|
+
self.textdo = wx.TextDataObject()
|
|
17
|
+
self.filedo = wx.FileDataObject()
|
|
18
|
+
self.do = wx.DataObjectComposite()
|
|
19
|
+
self.do.Add(self.datado)
|
|
20
|
+
self.do.Add(self.textdo)
|
|
21
|
+
self.do.Add(self.filedo)
|
|
22
|
+
self.SetDataObject(self.do)
|
|
23
|
+
|
|
24
|
+
def OnDragOver(self, x, y, result):
|
|
25
|
+
item, flags = self.tree.HitTest((x, y))
|
|
26
|
+
items = list(self.tree._gen_items(self.tree.RootItem)) # first level items
|
|
27
|
+
if self.datado.Format.Id != "TreeItem":
|
|
28
|
+
return wx.DragNone # Don't drag and drop.
|
|
29
|
+
if not item:
|
|
30
|
+
item = items[0] # Select the first tree item.
|
|
31
|
+
elif item not in items:
|
|
32
|
+
item = self.tree.GetItemParent(item) # Select the tree item.
|
|
33
|
+
if item != self.tree.Selection:
|
|
34
|
+
self.tree.SelectItem(item)
|
|
35
|
+
return result
|
|
36
|
+
|
|
37
|
+
def OnData(self, x, y, result):
|
|
38
|
+
item = self.tree.Selection
|
|
39
|
+
name = self.tree.GetItemText(item)
|
|
40
|
+
editor = self.tree._find_editor(name)
|
|
41
|
+
self.GetData()
|
|
42
|
+
if self.datado.Data:
|
|
43
|
+
fn = self.datado.Data.tobytes().decode()
|
|
44
|
+
if result == wx.DragMove:
|
|
45
|
+
try:
|
|
46
|
+
buf = self.tree._buffer # only for the same process buffer DnD
|
|
47
|
+
buf.parent.kill_buffer(buf) # the focus moves
|
|
48
|
+
wx.CallAfter(self.tree.SetFocus)
|
|
49
|
+
except AttributeError:
|
|
50
|
+
pass
|
|
51
|
+
editor.load_file(fn)
|
|
52
|
+
self.datado.SetData(b"")
|
|
53
|
+
elif self.textdo.Text:
|
|
54
|
+
fn = self.textdo.Text.strip()
|
|
55
|
+
res = editor.parent.handler("text_dropped", fn)
|
|
56
|
+
if res is None or not any(res):
|
|
57
|
+
editor.load_file(fn)
|
|
58
|
+
result = wx.DragCopy
|
|
59
|
+
self.textdo.SetText("")
|
|
60
|
+
else:
|
|
61
|
+
for fn in self.filedo.Filenames:
|
|
62
|
+
editor.load_file(fn)
|
|
63
|
+
self.filedo.SetData(wx.DF_FILENAME, None)
|
|
64
|
+
return result
|
|
6
65
|
|
|
7
66
|
|
|
8
67
|
class EditorTreeCtrl(wx.TreeCtrl, CtrlInterface):
|
|
9
68
|
"""TreeList/Ctrl
|
|
10
69
|
|
|
11
|
-
|
|
70
|
+
Note:
|
|
71
|
+
This only works with single selection mode.
|
|
12
72
|
"""
|
|
13
73
|
def __init__(self, parent, *args, **kwargs):
|
|
14
74
|
wx.TreeCtrl.__init__(self, parent, *args, **kwargs)
|
|
@@ -18,10 +78,14 @@ class EditorTreeCtrl(wx.TreeCtrl, CtrlInterface):
|
|
|
18
78
|
|
|
19
79
|
self.parent = parent
|
|
20
80
|
|
|
21
|
-
|
|
81
|
+
# self.Bind(wx.EVT_TREE_ITEM_GETTOOLTIP, self.OnItemTooltip)
|
|
22
82
|
self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged)
|
|
23
83
|
self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
|
|
24
84
|
|
|
85
|
+
self.SetDropTarget(MyDropTarget(self))
|
|
86
|
+
|
|
87
|
+
self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.OnBeginDrag)
|
|
88
|
+
|
|
25
89
|
def dispatch(evt):
|
|
26
90
|
"""Fork events to the parent."""
|
|
27
91
|
self.parent.handler(self.handler.current_event, evt)
|
|
@@ -33,8 +97,7 @@ class EditorTreeCtrl(wx.TreeCtrl, CtrlInterface):
|
|
|
33
97
|
'*button* released' : [ None, dispatch ],
|
|
34
98
|
},
|
|
35
99
|
0 : {
|
|
36
|
-
'delete pressed' : (0, self.
|
|
37
|
-
'f5 pressed' : (0, self._refresh),
|
|
100
|
+
'delete pressed' : (0, self.on_delete_buffer),
|
|
38
101
|
},
|
|
39
102
|
})
|
|
40
103
|
self.context = { # DNA<EditorBook>
|
|
@@ -48,47 +111,25 @@ class EditorTreeCtrl(wx.TreeCtrl, CtrlInterface):
|
|
|
48
111
|
'buffer_caption_updated' : [ None, self.on_buffer_filename ],
|
|
49
112
|
},
|
|
50
113
|
}
|
|
114
|
+
|
|
51
115
|
def _attach():
|
|
52
116
|
if self and self.parent:
|
|
53
|
-
for editor in self.parent.
|
|
117
|
+
for editor in self.parent.get_all_editors():
|
|
54
118
|
editor.handler.append(self.context)
|
|
55
119
|
self.build_tree()
|
|
56
120
|
wx.CallAfter(_attach)
|
|
57
|
-
|
|
121
|
+
wx.CallAfter(self.ExpandAll)
|
|
122
|
+
|
|
58
123
|
def OnDestroy(self, evt):
|
|
59
124
|
if self and self.parent:
|
|
60
|
-
for editor in self.parent.
|
|
125
|
+
for editor in self.parent.get_all_editors():
|
|
61
126
|
editor.handler.remove(self.context)
|
|
62
127
|
evt.Skip()
|
|
63
|
-
|
|
64
|
-
def _refresh(self, evt):
|
|
65
|
-
def _item(editor):
|
|
66
|
-
return self._get_item(self.RootItem, editor.Name)
|
|
67
|
-
ls = []
|
|
68
|
-
for editor in self.parent.all_editors:
|
|
69
|
-
if self.IsExpanded(_item(editor)):
|
|
70
|
-
ls.append(editor)
|
|
71
|
-
data = None
|
|
72
|
-
if self.Selection.IsOk():
|
|
73
|
-
data = self.GetItemData(self.Selection)
|
|
74
|
-
if data:
|
|
75
|
-
wx.CallAfter(data.SetFocus)
|
|
76
|
-
wx.CallAfter(self.SetFocus)
|
|
77
|
-
self.build_tree()
|
|
78
|
-
for editor in ls:
|
|
79
|
-
self.Expand(_item(editor))
|
|
80
|
-
|
|
81
|
-
def _delete(self, evt):
|
|
82
|
-
if self.Selection.IsOk():
|
|
83
|
-
data = self.GetItemData(self.Selection)
|
|
84
|
-
if data:
|
|
85
|
-
data.parent.kill_buffer(data) # the focus moves
|
|
86
|
-
wx.CallAfter(self.SetFocus)
|
|
87
|
-
|
|
128
|
+
|
|
88
129
|
## --------------------------------
|
|
89
|
-
## TreeList/Ctrl wrapper interface
|
|
130
|
+
## TreeList/Ctrl wrapper interface.
|
|
90
131
|
## --------------------------------
|
|
91
|
-
|
|
132
|
+
|
|
92
133
|
def build_tree(self, clear=True):
|
|
93
134
|
"""Build tree control.
|
|
94
135
|
All items will be cleared if specified.
|
|
@@ -96,26 +137,30 @@ class EditorTreeCtrl(wx.TreeCtrl, CtrlInterface):
|
|
|
96
137
|
if clear:
|
|
97
138
|
self.DeleteAllItems()
|
|
98
139
|
self.AddRoot(self.Name)
|
|
99
|
-
for editor in self.parent.
|
|
100
|
-
self._set_item(self.RootItem, editor.Name, editor.
|
|
140
|
+
for editor in self.parent.get_all_editors():
|
|
141
|
+
self._set_item(self.RootItem, editor.Name, editor.get_all_buffers())
|
|
101
142
|
self.Refresh()
|
|
102
|
-
|
|
103
|
-
def
|
|
143
|
+
|
|
144
|
+
def _gen_items(self, root, key=None):
|
|
104
145
|
"""Generates the [root/key] items."""
|
|
105
146
|
item, cookie = self.GetFirstChild(root)
|
|
106
147
|
while item:
|
|
107
|
-
|
|
108
|
-
if key == re.sub(r"^\W+\s+(.*)", r"\1", caption):
|
|
148
|
+
if not key:
|
|
109
149
|
yield item
|
|
150
|
+
else:
|
|
151
|
+
## キャプション先頭の識別子 %* を除外して比較する.
|
|
152
|
+
caption = self.GetItemText(item)
|
|
153
|
+
if key == re.sub(r"^\W+\s+(.*)", r"\1", caption):
|
|
154
|
+
yield item
|
|
110
155
|
item, cookie = self.GetNextChild(root, cookie)
|
|
111
|
-
|
|
156
|
+
|
|
112
157
|
def _get_item(self, root, key):
|
|
113
158
|
"""Get the first [root/key] item found."""
|
|
114
|
-
return next(self.
|
|
115
|
-
|
|
159
|
+
return next(self._gen_items(root, key), None)
|
|
160
|
+
|
|
116
161
|
def _set_item(self, root, key, data):
|
|
117
162
|
"""Set the [root/key] item with data recursively."""
|
|
118
|
-
for item in self.
|
|
163
|
+
for item in self._gen_items(root, key):
|
|
119
164
|
buf = self.GetItemData(item)
|
|
120
165
|
if not buf or buf is data:
|
|
121
166
|
break
|
|
@@ -129,32 +174,63 @@ class EditorTreeCtrl(wx.TreeCtrl, CtrlInterface):
|
|
|
129
174
|
self.SetItemData(item, data)
|
|
130
175
|
self.SetItemText(item, data.caption_prefix + data.name)
|
|
131
176
|
return item
|
|
132
|
-
|
|
177
|
+
|
|
133
178
|
## --------------------------------
|
|
134
|
-
## Actions for bookshelf
|
|
179
|
+
## Actions for bookshelf interface.
|
|
135
180
|
## --------------------------------
|
|
136
|
-
|
|
181
|
+
|
|
137
182
|
def on_buffer_new(self, buf):
|
|
138
183
|
self.build_tree(clear=0)
|
|
139
|
-
|
|
184
|
+
|
|
140
185
|
def on_buffer_deleted(self, buf):
|
|
141
186
|
self.Delete(buf.__itemId)
|
|
142
|
-
|
|
143
|
-
## Note: [buffer_activated][EVT_SET_FOCUS] > [buffer_new]
|
|
144
|
-
## buf.__itemId がない場合がある (delete_buffer 直後など)
|
|
145
|
-
@postcall
|
|
187
|
+
|
|
188
|
+
## Note: [buffer_activated][EVT_SET_FOCUS] > [buffer_new] の順で呼ばれる.
|
|
189
|
+
## buf.__itemId がない場合がある (delete_buffer 直後など).
|
|
146
190
|
def on_buffer_selected(self, buf):
|
|
147
191
|
if self and buf:
|
|
148
|
-
self.SelectItem(buf.__itemId)
|
|
149
|
-
|
|
192
|
+
wx.CallAfter(lambda: self.SelectItem(buf.__itemId))
|
|
193
|
+
|
|
150
194
|
def on_buffer_filename(self, buf):
|
|
151
195
|
if self and buf:
|
|
152
196
|
self.SetItemText(buf.__itemId, buf.caption_prefix + buf.name)
|
|
153
|
-
|
|
197
|
+
|
|
198
|
+
def on_delete_buffer(self, evt):
|
|
199
|
+
item = self.Selection
|
|
200
|
+
if item:
|
|
201
|
+
data = self.GetItemData(item)
|
|
202
|
+
if data:
|
|
203
|
+
data.parent.kill_buffer(data) # the focus moves
|
|
204
|
+
wx.CallAfter(self.SetFocus)
|
|
205
|
+
|
|
206
|
+
def _find_editor(self, name):
|
|
207
|
+
return next(editor for editor in self.parent.get_all_editors() if editor.Name == name)
|
|
208
|
+
|
|
154
209
|
def OnSelChanged(self, evt):
|
|
155
210
|
if self and self.HasFocus():
|
|
156
211
|
data = self.GetItemData(evt.Item)
|
|
157
212
|
if data:
|
|
158
213
|
data.SetFocus()
|
|
159
|
-
|
|
214
|
+
else:
|
|
215
|
+
name = self.GetItemText(evt.Item)
|
|
216
|
+
editor = self._find_editor(name)
|
|
217
|
+
if not editor.IsShown():
|
|
218
|
+
nb = self.Parent
|
|
219
|
+
nb.Selection = nb.FindPage(editor)
|
|
220
|
+
wx.CallAfter(self.SetFocus)
|
|
160
221
|
evt.Skip()
|
|
222
|
+
|
|
223
|
+
def OnBeginDrag(self, evt):
|
|
224
|
+
data = self.GetItemData(evt.Item)
|
|
225
|
+
if data:
|
|
226
|
+
self._buffer = data
|
|
227
|
+
if data.mtdelta is None:
|
|
228
|
+
dd = wx.CustomDataObject("DummyItem") # no file object
|
|
229
|
+
dd.SetData(b"")
|
|
230
|
+
else:
|
|
231
|
+
dd = wx.CustomDataObject("TreeItem")
|
|
232
|
+
dd.SetData(data.filename.encode())
|
|
233
|
+
dropSource = wx.DropSource()
|
|
234
|
+
dropSource.SetData(dd)
|
|
235
|
+
dropSource.DoDragDrop(wx.Drag_AllowMove) # -> wx.DragResult
|
|
236
|
+
del self._buffer
|