mwxlib 1.3.3__py3-none-any.whl → 1.4.0__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 +75 -84
- mwx/graphman.py +33 -27
- mwx/matplot2.py +9 -9
- mwx/matplot2g.py +68 -57
- mwx/matplot2lg.py +6 -6
- mwx/nutshell.py +45 -33
- mwx/plugins/ffmpeg_view.py +1 -1
- mwx/wxpdb.py +6 -6
- {mwxlib-1.3.3.dist-info → mwxlib-1.4.0.dist-info}/METADATA +1 -2
- mwxlib-1.4.0.dist-info/RECORD +28 -0
- {mwxlib-1.3.3.dist-info → mwxlib-1.4.0.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.4.0.dist-info}/top_level.txt +0 -0
mwx/matplot2g.py
CHANGED
|
@@ -206,9 +206,9 @@ class AxesImagePhantom:
|
|
|
206
206
|
cx, cy = self.center
|
|
207
207
|
self.__art.set_extent((cx-w, cx+w, cy-h, cy+h))
|
|
208
208
|
|
|
209
|
-
selector = _Property('
|
|
210
|
-
markers = _Property('
|
|
211
|
-
region = _Property('
|
|
209
|
+
selector = _Property('selector')
|
|
210
|
+
markers = _Property('markers')
|
|
211
|
+
region = _Property('region')
|
|
212
212
|
|
|
213
213
|
artist = property(
|
|
214
214
|
lambda self: self.__art)
|
|
@@ -319,8 +319,8 @@ class AxesImagePhantom:
|
|
|
319
319
|
@property
|
|
320
320
|
def roi(self):
|
|
321
321
|
"""Current buffer ROI (region of interest)."""
|
|
322
|
-
if self.parent.
|
|
323
|
-
nx, ny = self.xytopixel(*self.parent.
|
|
322
|
+
if self.parent.region.size:
|
|
323
|
+
nx, ny = self.xytopixel(*self.parent.region)
|
|
324
324
|
sx = slice(max(0,nx[0]), nx[1]) # nx slice
|
|
325
325
|
sy = slice(max(0,ny[1]), ny[0]) # ny slice 反転 (降順)
|
|
326
326
|
return self.__buf[sy,sx]
|
|
@@ -691,10 +691,14 @@ class GraphPlot(MatplotPanel):
|
|
|
691
691
|
|
|
692
692
|
self.draw()
|
|
693
693
|
self.writeln()
|
|
694
|
-
self.trace_point(*self.
|
|
694
|
+
self.trace_point(*self.selector)
|
|
695
695
|
|
|
696
696
|
return self.frame
|
|
697
697
|
|
|
698
|
+
def __iter__(self):
|
|
699
|
+
for art in self.__Arts:
|
|
700
|
+
yield art.buffer
|
|
701
|
+
|
|
698
702
|
def __getitem__(self, j):
|
|
699
703
|
if isinstance(j, str):
|
|
700
704
|
j = self.index(j)
|
|
@@ -758,19 +762,26 @@ class GraphPlot(MatplotPanel):
|
|
|
758
762
|
def __contains__(self, j):
|
|
759
763
|
if isinstance(j, str):
|
|
760
764
|
return j in (art.name for art in self.__Arts)
|
|
765
|
+
elif isinstance(j, np.ndarray):
|
|
766
|
+
return any(j is art.buffer for art in self.__Arts)
|
|
761
767
|
else:
|
|
762
768
|
return j in self.__Arts
|
|
763
769
|
|
|
764
770
|
def index(self, j):
|
|
765
771
|
if isinstance(j, str):
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
772
|
+
return next(i for i, art in enumerate(self.__Arts) if j == art.name)
|
|
773
|
+
elif isinstance(j, np.ndarray):
|
|
774
|
+
return next(i for i, art in enumerate(self.__Arts) if j is art.buffer)
|
|
775
|
+
else:
|
|
776
|
+
return self.__Arts.index(j) # j:frame -> int
|
|
769
777
|
|
|
770
778
|
def find_frame(self, j):
|
|
771
779
|
if isinstance(j, str):
|
|
772
|
-
return next((art for art in self.__Arts if art.name
|
|
773
|
-
|
|
780
|
+
return next((art for art in self.__Arts if j == art.name), None)
|
|
781
|
+
elif isinstance(j, np.ndarray):
|
|
782
|
+
return next((art for art in self.__Arts if j is art.buffer), None)
|
|
783
|
+
else:
|
|
784
|
+
return self.__Arts[j] # j:int -> frame
|
|
774
785
|
|
|
775
786
|
def get_all_frames(self):
|
|
776
787
|
"""List of arts <matplotlib.image.AxesImage>."""
|
|
@@ -876,7 +887,7 @@ class GraphPlot(MatplotPanel):
|
|
|
876
887
|
if self.frame:
|
|
877
888
|
self.handler('frame_selected', self.frame)
|
|
878
889
|
self.on_picker_unlock(evt)
|
|
879
|
-
self.trace_point(*self.
|
|
890
|
+
self.trace_point(*self.selector)
|
|
880
891
|
|
|
881
892
|
def on_focus_kill(self, evt):
|
|
882
893
|
"""Called when focus is killed (override)."""
|
|
@@ -914,10 +925,10 @@ class GraphPlot(MatplotPanel):
|
|
|
914
925
|
if len(x) == 0: # no selection
|
|
915
926
|
return
|
|
916
927
|
|
|
917
|
-
if len(x) == 1: # 1-
|
|
928
|
+
if len(x) == 1: # 1-selector trace point (called from Marker:setter)
|
|
918
929
|
return self.trace_point(x[0], y[0], type)
|
|
919
930
|
|
|
920
|
-
if len(x) == 2: # 2-
|
|
931
|
+
if len(x) == 2: # 2-selector trace line (called from selector:setter)
|
|
921
932
|
nx, ny = frame.xytopixel(x, y)
|
|
922
933
|
dx = x[1] - x[0]
|
|
923
934
|
dy = y[1] - y[0]
|
|
@@ -926,7 +937,7 @@ class GraphPlot(MatplotPanel):
|
|
|
926
937
|
li = np.hypot(nx[1]-nx[0], ny[1]-ny[0])
|
|
927
938
|
self.message(f"[Line] Length: {li:.1f} pixel ({lu:g}u) Angle: {a:.1f} deg")
|
|
928
939
|
|
|
929
|
-
elif type == REGION: # N-
|
|
940
|
+
elif type == REGION: # N-selector trace polygon (called from region:setter)
|
|
930
941
|
nx, ny = frame.xytopixel(x, y)
|
|
931
942
|
xo, yo = min(nx), min(ny) # top-left
|
|
932
943
|
xr, yr = max(nx), max(ny) # bottom-right
|
|
@@ -1059,7 +1070,7 @@ class GraphPlot(MatplotPanel):
|
|
|
1059
1070
|
self.handler('region_picked', evt)
|
|
1060
1071
|
|
|
1061
1072
|
elif evt.artist is self.selected:
|
|
1062
|
-
if (self.
|
|
1073
|
+
if (self.selector.shape[1] < 2 # single selector
|
|
1063
1074
|
or wx.GetKeyState(wx.WXK_SHIFT)): # or polygon mode
|
|
1064
1075
|
return
|
|
1065
1076
|
self.__isPicked = 'line' # image pick gurad
|
|
@@ -1082,7 +1093,7 @@ class GraphPlot(MatplotPanel):
|
|
|
1082
1093
|
nx, ny = self.frame.xytopixel(x, y)
|
|
1083
1094
|
x, y = self.frame.xyfrompixel(nx, ny)
|
|
1084
1095
|
evt.ind = (ny, nx)
|
|
1085
|
-
self.
|
|
1096
|
+
self.selector = (x, y)
|
|
1086
1097
|
|
|
1087
1098
|
def _inaxes(self, evt):
|
|
1088
1099
|
try:
|
|
@@ -1115,7 +1126,7 @@ class GraphPlot(MatplotPanel):
|
|
|
1115
1126
|
|
|
1116
1127
|
def OnMotion(self, evt):
|
|
1117
1128
|
"""Called when mouse moves in axes (overridden)."""
|
|
1118
|
-
if self.
|
|
1129
|
+
if self.selector.shape[1] < 2:
|
|
1119
1130
|
self.trace_point(evt.xdata, evt.ydata)
|
|
1120
1131
|
|
|
1121
1132
|
def OnPageDown(self, evt):
|
|
@@ -1134,8 +1145,8 @@ class GraphPlot(MatplotPanel):
|
|
|
1134
1145
|
self.fit_to_axes()
|
|
1135
1146
|
|
|
1136
1147
|
def OnEscapeSelection(self, evt):
|
|
1137
|
-
xs, ys = self.
|
|
1138
|
-
del self.
|
|
1148
|
+
xs, ys = self.selector
|
|
1149
|
+
del self.selector
|
|
1139
1150
|
if len(xs) > 1:
|
|
1140
1151
|
self.handler('line_removed', self.frame)
|
|
1141
1152
|
|
|
@@ -1205,9 +1216,9 @@ class GraphPlot(MatplotPanel):
|
|
|
1205
1216
|
return self.calc_point(x, y, centred)
|
|
1206
1217
|
|
|
1207
1218
|
def OnSelectorAppend(self, evt):
|
|
1208
|
-
xs, ys = self.
|
|
1219
|
+
xs, ys = self.selector
|
|
1209
1220
|
x, y = self.calc_point(evt.xdata, evt.ydata)
|
|
1210
|
-
self.
|
|
1221
|
+
self.selector = np.append(xs, x), np.append(ys, y)
|
|
1211
1222
|
self.handler('line_drawn', self.frame)
|
|
1212
1223
|
|
|
1213
1224
|
def OnDragLock(self, evt):
|
|
@@ -1219,28 +1230,28 @@ class GraphPlot(MatplotPanel):
|
|
|
1219
1230
|
return
|
|
1220
1231
|
org = self.p_event # the last pressed
|
|
1221
1232
|
self.__lastpoint = self.calc_point(org.xdata, org.ydata)
|
|
1222
|
-
self.__orgpoints = self.
|
|
1233
|
+
self.__orgpoints = self.selector
|
|
1223
1234
|
|
|
1224
1235
|
def OnDragMove(self, evt, shift=False):
|
|
1225
1236
|
x, y = self.calc_point(evt.xdata, evt.ydata)
|
|
1226
1237
|
xo, yo = self.__lastpoint
|
|
1227
1238
|
if shift:
|
|
1228
1239
|
x, y = self.calc_shiftpoint(xo, yo, x, y)
|
|
1229
|
-
self.
|
|
1240
|
+
self.selector = np.append(xo, x), np.append(yo, y)
|
|
1230
1241
|
self.handler('line_draw', self.frame)
|
|
1231
1242
|
|
|
1232
1243
|
def OnDragShiftMove(self, evt):
|
|
1233
1244
|
self.OnDragMove(evt, shift=True)
|
|
1234
1245
|
|
|
1235
1246
|
def OnDragEscape(self, evt):
|
|
1236
|
-
self.
|
|
1247
|
+
self.selector = self.__orgpoints
|
|
1237
1248
|
self.handler('line_draw', self.frame)
|
|
1238
1249
|
|
|
1239
1250
|
def OnDragEnd(self, evt):
|
|
1240
1251
|
x, y = self.calc_point(evt.xdata, evt.ydata)
|
|
1241
1252
|
xo, yo = self.__lastpoint
|
|
1242
1253
|
if x == xo and y == yo:
|
|
1243
|
-
self.
|
|
1254
|
+
self.selector = ([x], [y])
|
|
1244
1255
|
self.handler('line_drawn', self.frame)
|
|
1245
1256
|
|
|
1246
1257
|
## --------------------------------
|
|
@@ -1264,7 +1275,7 @@ class GraphPlot(MatplotPanel):
|
|
|
1264
1275
|
return
|
|
1265
1276
|
org = self.p_event # the last pressed
|
|
1266
1277
|
self.__lastpoint = self.calc_point(org.xdata, org.ydata)
|
|
1267
|
-
self.__orgpoints = self.
|
|
1278
|
+
self.__orgpoints = self.selector
|
|
1268
1279
|
|
|
1269
1280
|
def OnLineDragMove(self, evt, shift=False):
|
|
1270
1281
|
x, y = self.calc_point(evt.xdata, evt.ydata)
|
|
@@ -1276,21 +1287,21 @@ class GraphPlot(MatplotPanel):
|
|
|
1276
1287
|
i = j-1 if j else 1
|
|
1277
1288
|
xo, yo = xo[i], yo[i] # となりの点を基準とする
|
|
1278
1289
|
x, y = self.calc_shiftpoint(xo, yo, x, y)
|
|
1279
|
-
xs, ys = self.
|
|
1290
|
+
xs, ys = self.selector
|
|
1280
1291
|
xs[j], ys[j] = x, y
|
|
1281
|
-
self.
|
|
1292
|
+
self.selector = (xs, ys)
|
|
1282
1293
|
self.handler('line_draw', self.frame)
|
|
1283
1294
|
else:
|
|
1284
1295
|
xs = xo + (x - xc)
|
|
1285
1296
|
ys = yo + (y - yc)
|
|
1286
|
-
self.
|
|
1297
|
+
self.selector = (xs, ys)
|
|
1287
1298
|
self.handler('line_move', self.frame)
|
|
1288
1299
|
|
|
1289
1300
|
def OnLineDragShiftMove(self, evt):
|
|
1290
1301
|
self.OnLineDragMove(evt, shift=True)
|
|
1291
1302
|
|
|
1292
1303
|
def OnLineDragEscape(self, evt):
|
|
1293
|
-
self.
|
|
1304
|
+
self.selector = self.__orgpoints
|
|
1294
1305
|
if self.__linesel:
|
|
1295
1306
|
self.handler('line_drawn', self.frame)
|
|
1296
1307
|
else:
|
|
@@ -1303,7 +1314,7 @@ class GraphPlot(MatplotPanel):
|
|
|
1303
1314
|
self.handler('line_moved', self.frame)
|
|
1304
1315
|
|
|
1305
1316
|
def OnLineShift(self, evt):
|
|
1306
|
-
if self.
|
|
1317
|
+
if self.selector.size and self.frame:
|
|
1307
1318
|
ux, uy = self.frame.xy_unit
|
|
1308
1319
|
du = {
|
|
1309
1320
|
'up' : ( 0., uy),
|
|
@@ -1311,7 +1322,7 @@ class GraphPlot(MatplotPanel):
|
|
|
1311
1322
|
'left' : (-ux, 0.),
|
|
1312
1323
|
'right' : ( ux, 0.),
|
|
1313
1324
|
}
|
|
1314
|
-
self.
|
|
1325
|
+
self.selector += np.resize(du[evt.key], (2,1))
|
|
1315
1326
|
self.handler('line_move', self.frame)
|
|
1316
1327
|
|
|
1317
1328
|
def OnLineShiftEnd(self, evt):
|
|
@@ -1322,7 +1333,7 @@ class GraphPlot(MatplotPanel):
|
|
|
1322
1333
|
## --------------------------------
|
|
1323
1334
|
|
|
1324
1335
|
@property
|
|
1325
|
-
def
|
|
1336
|
+
def region(self):
|
|
1326
1337
|
"""Rectangle points data array [l,r],[b,t]."""
|
|
1327
1338
|
x, y = self.rected.get_data(orig=0)
|
|
1328
1339
|
if len(x) and len(y):
|
|
@@ -1331,16 +1342,16 @@ class GraphPlot(MatplotPanel):
|
|
|
1331
1342
|
return np.array(((xo, x), (yo, y)))
|
|
1332
1343
|
return np.resize(0., (2,0))
|
|
1333
1344
|
|
|
1334
|
-
@
|
|
1335
|
-
def
|
|
1345
|
+
@region.setter
|
|
1346
|
+
def region(self, v):
|
|
1336
1347
|
x, y = v
|
|
1337
1348
|
if len(x) > 1:
|
|
1338
1349
|
self.set_current_rect(x, y)
|
|
1339
1350
|
self.handler('region_drawn', self.frame)
|
|
1340
1351
|
|
|
1341
|
-
@
|
|
1342
|
-
def
|
|
1343
|
-
if self.
|
|
1352
|
+
@region.deleter
|
|
1353
|
+
def region(self):
|
|
1354
|
+
if self.region.size:
|
|
1344
1355
|
self.del_current_rect()
|
|
1345
1356
|
self.handler('region_removed', self.frame)
|
|
1346
1357
|
|
|
@@ -1400,7 +1411,7 @@ class GraphPlot(MatplotPanel):
|
|
|
1400
1411
|
self.draw(self.rected)
|
|
1401
1412
|
|
|
1402
1413
|
def OnRegionAppend(self, evt):
|
|
1403
|
-
xs, ys = self.
|
|
1414
|
+
xs, ys = self.selector
|
|
1404
1415
|
if len(xs) > 0 and self.frame:
|
|
1405
1416
|
ux, uy = self.frame.xy_unit
|
|
1406
1417
|
xs = (xs.min()-ux/2, xs.max()+ux/2)
|
|
@@ -1506,8 +1517,8 @@ class GraphPlot(MatplotPanel):
|
|
|
1506
1517
|
|
|
1507
1518
|
def OnRegionMotion(self, evt):
|
|
1508
1519
|
x, y = evt.xdata, evt.ydata
|
|
1509
|
-
if self.
|
|
1510
|
-
(l,r), (b,t) = self.
|
|
1520
|
+
if self.region.size:
|
|
1521
|
+
(l,r), (b,t) = self.region
|
|
1511
1522
|
d = self.rected.pickradius / self.ddpu[0]
|
|
1512
1523
|
x0 = l+d < x < r-d
|
|
1513
1524
|
y0 = b+d < y < t-d
|
|
@@ -1532,20 +1543,20 @@ class GraphPlot(MatplotPanel):
|
|
|
1532
1543
|
self.set_wxcursor(wx.CURSOR_ARROW) # outside
|
|
1533
1544
|
|
|
1534
1545
|
## --------------------------------
|
|
1535
|
-
##
|
|
1546
|
+
## Marker interface
|
|
1536
1547
|
## --------------------------------
|
|
1537
1548
|
|
|
1538
1549
|
#: Limit number of markers to display 最大(表示)数を制限する
|
|
1539
1550
|
maxnum_markers = 1000
|
|
1540
1551
|
|
|
1541
1552
|
@property
|
|
1542
|
-
def
|
|
1553
|
+
def markers(self):
|
|
1543
1554
|
"""Marked points data array [[x],[y]]."""
|
|
1544
1555
|
xm, ym = self.marked.get_data(orig=0)
|
|
1545
1556
|
return np.array((xm, ym))
|
|
1546
1557
|
|
|
1547
|
-
@
|
|
1548
|
-
def
|
|
1558
|
+
@markers.setter
|
|
1559
|
+
def markers(self, v):
|
|
1549
1560
|
x, y = v
|
|
1550
1561
|
if not hasattr(x, '__iter__'):
|
|
1551
1562
|
x, y = [x], [y]
|
|
@@ -1557,9 +1568,9 @@ class GraphPlot(MatplotPanel):
|
|
|
1557
1568
|
self.update_art_of_mark()
|
|
1558
1569
|
self.handler('mark_drawn', self.frame)
|
|
1559
1570
|
|
|
1560
|
-
@
|
|
1561
|
-
def
|
|
1562
|
-
if self.
|
|
1571
|
+
@markers.deleter
|
|
1572
|
+
def markers(self):
|
|
1573
|
+
if self.markers.size:
|
|
1563
1574
|
self.marked.set_data([], [])
|
|
1564
1575
|
self.__marksel = []
|
|
1565
1576
|
self.update_art_of_mark()
|
|
@@ -1585,7 +1596,7 @@ class GraphPlot(MatplotPanel):
|
|
|
1585
1596
|
self.marked.set_data(xm, ym)
|
|
1586
1597
|
self.marked.set_visible(1)
|
|
1587
1598
|
self.update_art_of_mark()
|
|
1588
|
-
self.
|
|
1599
|
+
self.selector = (x, y)
|
|
1589
1600
|
|
|
1590
1601
|
def del_current_mark(self):
|
|
1591
1602
|
j = self.__marksel
|
|
@@ -1620,12 +1631,12 @@ class GraphPlot(MatplotPanel):
|
|
|
1620
1631
|
color='red', size=7, #fontsize=8,
|
|
1621
1632
|
)
|
|
1622
1633
|
)
|
|
1623
|
-
self.
|
|
1624
|
-
self.trace_point(*self.
|
|
1634
|
+
self.selector = self.get_current_mark()
|
|
1635
|
+
self.trace_point(*self.selector, type=MARK)
|
|
1625
1636
|
self.draw(self.marked)
|
|
1626
1637
|
|
|
1627
1638
|
def OnMarkAppend(self, evt):
|
|
1628
|
-
xs, ys = self.
|
|
1639
|
+
xs, ys = self.selector
|
|
1629
1640
|
if not self.__marksel and len(xs) > 0:
|
|
1630
1641
|
self.set_current_mark(xs, ys)
|
|
1631
1642
|
self.handler('mark_drawn', self.frame)
|
|
@@ -1645,7 +1656,7 @@ class GraphPlot(MatplotPanel):
|
|
|
1645
1656
|
self.__marksel = [k]
|
|
1646
1657
|
self.update_art_of_mark()
|
|
1647
1658
|
|
|
1648
|
-
if self.
|
|
1659
|
+
if self.selector.shape[1] > 1:
|
|
1649
1660
|
self.handler('line_drawn', self.frame) # 多重マーカー選択時
|
|
1650
1661
|
|
|
1651
1662
|
def OnMarkDeselected(self, evt): #<matplotlib.backend_bases.PickEvent>
|
|
@@ -1692,12 +1703,12 @@ class GraphPlot(MatplotPanel):
|
|
|
1692
1703
|
xs, ys = self.get_current_mark()
|
|
1693
1704
|
self.xlim += xs[-1] - (self.xlim[1] + self.xlim[0]) / 2
|
|
1694
1705
|
self.ylim += ys[-1] - (self.ylim[1] + self.ylim[0]) / 2
|
|
1695
|
-
self.
|
|
1706
|
+
self.selector = (xs, ys)
|
|
1696
1707
|
self.trace_point(xs, ys, type=MARK)
|
|
1697
1708
|
self.draw()
|
|
1698
1709
|
|
|
1699
1710
|
def OnMarkSkipNext(self, evt):
|
|
1700
|
-
n = self.
|
|
1711
|
+
n = self.markers.shape[1]
|
|
1701
1712
|
j = self.__marksel
|
|
1702
1713
|
if j:
|
|
1703
1714
|
self.next_mark((j[-1]+1) % n)
|
|
@@ -1705,7 +1716,7 @@ class GraphPlot(MatplotPanel):
|
|
|
1705
1716
|
self.next_mark(0)
|
|
1706
1717
|
|
|
1707
1718
|
def OnMarkSkipPrevious(self, evt):
|
|
1708
|
-
n = self.
|
|
1719
|
+
n = self.markers.shape[1]
|
|
1709
1720
|
j = self.__marksel
|
|
1710
1721
|
if j:
|
|
1711
1722
|
self.next_mark((j[-1]-1) % n)
|
mwx/matplot2lg.py
CHANGED
|
@@ -512,8 +512,8 @@ class LineProfile(LinePlot):
|
|
|
512
512
|
self.__plot.set_xdata(x * ru)
|
|
513
513
|
if self.region is not None:
|
|
514
514
|
self.region *= ru
|
|
515
|
-
sel = self.
|
|
516
|
-
self.
|
|
515
|
+
sel = self.selector
|
|
516
|
+
self.selector = (sel[0] * ru, sel[1])
|
|
517
517
|
self.draw()
|
|
518
518
|
|
|
519
519
|
def set_linewidth(self, w):
|
|
@@ -730,16 +730,16 @@ class LineProfile(LinePlot):
|
|
|
730
730
|
|
|
731
731
|
peaks = np.sort(np.append(maxima, minima))
|
|
732
732
|
if peaks.size:
|
|
733
|
-
self.
|
|
733
|
+
self.selector = x[peaks], y[peaks]
|
|
734
734
|
|
|
735
735
|
def OnMarkErase(self, evt):
|
|
736
736
|
"""Erase markers on peaks."""
|
|
737
|
-
## del self.
|
|
737
|
+
## del self.selector
|
|
738
738
|
self.OnEscapeSelection(evt)
|
|
739
739
|
|
|
740
740
|
def OnMarkSelectionBegin(self, evt):
|
|
741
741
|
org = self.p_event
|
|
742
|
-
xs, ys = self.
|
|
742
|
+
xs, ys = self.selector
|
|
743
743
|
xc, yc = org.xdata, org.ydata
|
|
744
744
|
## xc, yc = evt.xdata, evt.ydata
|
|
745
745
|
if xs.size:
|
|
@@ -750,7 +750,7 @@ class LineProfile(LinePlot):
|
|
|
750
750
|
self.draw()
|
|
751
751
|
|
|
752
752
|
def OnMarkSelectionMove(self, evt):
|
|
753
|
-
xs, ys = self.
|
|
753
|
+
xs, ys = self.selector
|
|
754
754
|
xc, yc = evt.xdata, evt.ydata
|
|
755
755
|
if xs.size:
|
|
756
756
|
ld = np.hypot((xs-xc)*self.ddpu[0], (ys-yc)*self.ddpu[1])
|
mwx/nutshell.py
CHANGED
|
@@ -321,7 +321,9 @@ class AutoCompInterfaceMixin:
|
|
|
321
321
|
cmdl = self.GetTextRange(self.bol, self.cpos)
|
|
322
322
|
hint = re.search(r"[\w.]*$", cmdl).group(0) # extract the last word
|
|
323
323
|
|
|
324
|
-
ls = [x for x in self.fragmwords if x.startswith(hint)] # case-sensitive match
|
|
324
|
+
## ls = [x for x in self.fragmwords if x.startswith(hint)] # case-sensitive match
|
|
325
|
+
q = hint.lower()
|
|
326
|
+
ls = [x for x in self.fragmwords if x.lower().startswith(q)] # case-insensitive match
|
|
325
327
|
words = sorted(ls, key=lambda s:s.upper())
|
|
326
328
|
|
|
327
329
|
self._gen_autocomp(0, hint, words)
|
|
@@ -360,9 +362,9 @@ class AutoCompInterfaceMixin:
|
|
|
360
362
|
self.message("\b failed.", e)
|
|
361
363
|
return
|
|
362
364
|
else:
|
|
363
|
-
## Add unimported module names.
|
|
364
|
-
|
|
365
|
-
keys = [x[len(text)+1:] for x in self.modules if x.startswith(
|
|
365
|
+
## Add unimported module names (case-insensitive match).
|
|
366
|
+
q = f"{text}.{hint}".lower()
|
|
367
|
+
keys = [x[len(text)+1:] for x in self.modules if x.lower().startswith(q)]
|
|
366
368
|
modules.update(k for k in keys if '.' not in k)
|
|
367
369
|
|
|
368
370
|
elif (m := re.match(r"(import|from)\s+(.*)", cmdl)):
|
|
@@ -1108,7 +1110,7 @@ class EditorInterface(AutoCompInterfaceMixin, CtrlInterface):
|
|
|
1108
1110
|
self.ensureLineOnScreen(lc)
|
|
1109
1111
|
return lc
|
|
1110
1112
|
|
|
1111
|
-
def
|
|
1113
|
+
def get_indent_region(self, line):
|
|
1112
1114
|
"""Line numbers of folding head and tail containing the line."""
|
|
1113
1115
|
lc = line
|
|
1114
1116
|
le = lc + 1
|
|
@@ -1730,7 +1732,7 @@ class Buffer(EditorInterface, EditWindow):
|
|
|
1730
1732
|
self.__mtime = -1
|
|
1731
1733
|
else:
|
|
1732
1734
|
try:
|
|
1733
|
-
self.__path.resolve(True) # Check if the path
|
|
1735
|
+
self.__path.resolve(True) # Check if the path is valid.
|
|
1734
1736
|
except FileNotFoundError:
|
|
1735
1737
|
self.__mtime = False # valid path (but not found)
|
|
1736
1738
|
except OSError:
|
|
@@ -1895,7 +1897,7 @@ class Buffer(EditorInterface, EditWindow):
|
|
|
1895
1897
|
'*delete pressed' : (2, skip),
|
|
1896
1898
|
'*backspace pressed' : (2, skip),
|
|
1897
1899
|
'*backspace released' : (2, self.call_word_autocomp),
|
|
1898
|
-
|
|
1900
|
+
'*S-backspace pressed' : (0, clear_autocomp, fork),
|
|
1899
1901
|
'*alt pressed' : (2, ),
|
|
1900
1902
|
'*ctrl pressed' : (2, ),
|
|
1901
1903
|
'*shift pressed' : (2, ),
|
|
@@ -1922,7 +1924,7 @@ class Buffer(EditorInterface, EditWindow):
|
|
|
1922
1924
|
'*delete pressed' : (3, skip),
|
|
1923
1925
|
'*backspace pressed' : (3, skip),
|
|
1924
1926
|
'*backspace released' : (3, self.call_apropos_autocomp),
|
|
1925
|
-
|
|
1927
|
+
'*S-backspace pressed' : (0, clear_autocomp, fork),
|
|
1926
1928
|
'*alt pressed' : (3, ),
|
|
1927
1929
|
'*ctrl pressed' : (3, ),
|
|
1928
1930
|
'*shift pressed' : (3, ),
|
|
@@ -2212,10 +2214,9 @@ class EditorBook(AuiNotebook, CtrlInterface):
|
|
|
2212
2214
|
evt.Skip()
|
|
2213
2215
|
|
|
2214
2216
|
def OnPageClose(self, evt): #<wx._aui.AuiNotebookEvent>
|
|
2215
|
-
|
|
2216
|
-
buf = list(nb.get_pages())[evt.Selection]
|
|
2217
|
+
buf = self.GetPage(evt.Selection)
|
|
2217
2218
|
if buf.need_buffer_save:
|
|
2218
|
-
if wx.MessageBox( # Confirm
|
|
2219
|
+
if wx.MessageBox( # Confirm closing the buffer.
|
|
2219
2220
|
"You are closing unsaved content.\n\n"
|
|
2220
2221
|
"The changes will be discarded.\n"
|
|
2221
2222
|
"Continue closing?",
|
|
@@ -2273,11 +2274,6 @@ class EditorBook(AuiNotebook, CtrlInterface):
|
|
|
2273
2274
|
## Buffer list controls
|
|
2274
2275
|
## --------------------------------
|
|
2275
2276
|
|
|
2276
|
-
@property
|
|
2277
|
-
def all_buffers(self): # (deprecated) for backward compatibility
|
|
2278
|
-
"""Returns all buffers."""
|
|
2279
|
-
return [self.GetPage(j) for j in range(self.PageCount)]
|
|
2280
|
-
|
|
2281
2277
|
def get_all_buffers(self, fn=None):
|
|
2282
2278
|
"""Yields all buffers with specified fn:filename or code."""
|
|
2283
2279
|
if fn is None:
|
|
@@ -2352,18 +2348,34 @@ class EditorBook(AuiNotebook, CtrlInterface):
|
|
|
2352
2348
|
if j != -1:
|
|
2353
2349
|
self.DeletePage(j) # the focus moves
|
|
2354
2350
|
if not self.buffer: # no buffers
|
|
2355
|
-
self.new_buffer
|
|
2351
|
+
wx.CallAfter(self.new_buffer) # Note: post-call to avoid a crash.
|
|
2356
2352
|
|
|
2357
2353
|
def delete_all_buffers(self):
|
|
2358
2354
|
"""Initialize list of buffers."""
|
|
2359
2355
|
self.DeleteAllPages()
|
|
2360
|
-
self.new_buffer
|
|
2356
|
+
wx.CallAfter(self.new_buffer) # Note: post-call to avoid a crash.
|
|
2361
2357
|
|
|
2362
2358
|
def next_buffer(self):
|
|
2363
|
-
self.Selection
|
|
2359
|
+
if self.Selection < self.PageCount - 1:
|
|
2360
|
+
self.Selection += 1
|
|
2361
|
+
else:
|
|
2362
|
+
books = list(self.Parent.get_pages(type(self)))
|
|
2363
|
+
k = books.index(self)
|
|
2364
|
+
if k < len(books) - 1:
|
|
2365
|
+
other_editor = books[k+1]
|
|
2366
|
+
other_editor.Selection = 0
|
|
2367
|
+
other_editor.CurrentPage.SetFocus()
|
|
2364
2368
|
|
|
2365
2369
|
def previous_buffer(self):
|
|
2366
|
-
self.Selection
|
|
2370
|
+
if self.Selection > 0:
|
|
2371
|
+
self.Selection -= 1
|
|
2372
|
+
else:
|
|
2373
|
+
books = list(self.Parent.get_pages(type(self)))
|
|
2374
|
+
k = books.index(self)
|
|
2375
|
+
if k > 0:
|
|
2376
|
+
other_editor = books[k-1]
|
|
2377
|
+
other_editor.Selection = other_editor.PageCount - 1
|
|
2378
|
+
other_editor.CurrentPage.SetFocus()
|
|
2367
2379
|
|
|
2368
2380
|
## --------------------------------
|
|
2369
2381
|
## File I/O
|
|
@@ -2402,7 +2414,7 @@ class EditorBook(AuiNotebook, CtrlInterface):
|
|
|
2402
2414
|
if not buf:
|
|
2403
2415
|
buf = self.create_buffer("*temp file*")
|
|
2404
2416
|
elif buf.need_buffer_save and verbose:
|
|
2405
|
-
if wx.MessageBox( # Confirm
|
|
2417
|
+
if wx.MessageBox( # Confirm loading the buffer.
|
|
2406
2418
|
"You are leaving unsaved content.\n\n"
|
|
2407
2419
|
"The changes will be discarded.\n"
|
|
2408
2420
|
"Continue loading?",
|
|
@@ -2456,7 +2468,7 @@ class EditorBook(AuiNotebook, CtrlInterface):
|
|
|
2456
2468
|
buf = buf or self.buffer
|
|
2457
2469
|
if buf.need_buffer_load and verbose:
|
|
2458
2470
|
self.swap_buffer(buf)
|
|
2459
|
-
if wx.MessageBox( # Confirm
|
|
2471
|
+
if wx.MessageBox( # Confirm saving the buffer.
|
|
2460
2472
|
"The file has been modified externally.\n\n"
|
|
2461
2473
|
"The contents of the file will be overwritten.\n"
|
|
2462
2474
|
"Continue saving?",
|
|
@@ -2520,7 +2532,7 @@ class EditorBook(AuiNotebook, CtrlInterface):
|
|
|
2520
2532
|
"""Confirm the close with the dialog."""
|
|
2521
2533
|
buf = buf or self.buffer
|
|
2522
2534
|
if buf.need_buffer_save:
|
|
2523
|
-
if wx.MessageBox( # Confirm
|
|
2535
|
+
if wx.MessageBox( # Confirm closing the buffer.
|
|
2524
2536
|
"You are closing unsaved content.\n\n"
|
|
2525
2537
|
"The changes will be discarded.\n"
|
|
2526
2538
|
"Continue closing?",
|
|
@@ -2528,12 +2540,12 @@ class EditorBook(AuiNotebook, CtrlInterface):
|
|
|
2528
2540
|
style=wx.YES_NO|wx.ICON_INFORMATION) != wx.YES:
|
|
2529
2541
|
self.post_message("The close has been canceled.")
|
|
2530
2542
|
return None
|
|
2531
|
-
|
|
2543
|
+
self.delete_buffer(buf)
|
|
2532
2544
|
|
|
2533
2545
|
def kill_all_buffers(self):
|
|
2534
2546
|
for buf in self.get_all_buffers():
|
|
2535
2547
|
if buf.need_buffer_save:
|
|
2536
|
-
if wx.MessageBox( # Confirm
|
|
2548
|
+
if wx.MessageBox( # Confirm closing the buffer.
|
|
2537
2549
|
"You are closing unsaved content.\n\n"
|
|
2538
2550
|
"The changes will be discarded.\n"
|
|
2539
2551
|
"Continue closing?",
|
|
@@ -2541,7 +2553,7 @@ class EditorBook(AuiNotebook, CtrlInterface):
|
|
|
2541
2553
|
style=wx.YES_NO|wx.ICON_INFORMATION) != wx.YES:
|
|
2542
2554
|
self.post_message("The close has been canceled.")
|
|
2543
2555
|
return None
|
|
2544
|
-
|
|
2556
|
+
self.delete_all_buffers()
|
|
2545
2557
|
|
|
2546
2558
|
|
|
2547
2559
|
class Interpreter(interpreter.Interpreter):
|
|
@@ -2903,7 +2915,7 @@ class Nautilus(EditorInterface, Shell):
|
|
|
2903
2915
|
'*delete pressed' : (2, skip),
|
|
2904
2916
|
'*backspace pressed' : (2, self.OnBackspace),
|
|
2905
2917
|
'*backspace released' : (2, self.call_word_autocomp),
|
|
2906
|
-
|
|
2918
|
+
'*S-backspace pressed' : (0, clear_autocomp, fork),
|
|
2907
2919
|
'C-j pressed' : (2, _F(self.eval_line)),
|
|
2908
2920
|
'*alt pressed' : (2, ),
|
|
2909
2921
|
'*ctrl pressed' : (2, ),
|
|
@@ -2931,7 +2943,7 @@ class Nautilus(EditorInterface, Shell):
|
|
|
2931
2943
|
'*delete pressed' : (3, skip),
|
|
2932
2944
|
'*backspace pressed' : (3, self.OnBackspace),
|
|
2933
2945
|
'*backspace released' : (3, self.call_apropos_autocomp),
|
|
2934
|
-
|
|
2946
|
+
'*S-backspace pressed' : (0, clear_autocomp, fork),
|
|
2935
2947
|
'C-j pressed' : (3, _F(self.eval_line)),
|
|
2936
2948
|
'*alt pressed' : (3, ),
|
|
2937
2949
|
'*ctrl pressed' : (3, ),
|
|
@@ -2959,7 +2971,7 @@ class Nautilus(EditorInterface, Shell):
|
|
|
2959
2971
|
'*delete pressed' : (4, skip),
|
|
2960
2972
|
'*backspace pressed' : (4, self.OnBackspace),
|
|
2961
2973
|
'*backspace released' : (4, self.call_text_autocomp),
|
|
2962
|
-
|
|
2974
|
+
'*S-backspace pressed' : (0, clear_autocomp, fork),
|
|
2963
2975
|
'C-j pressed' : (4, _F(self.eval_line)),
|
|
2964
2976
|
'*alt pressed' : (4, ),
|
|
2965
2977
|
'*ctrl pressed' : (4, ),
|
|
@@ -2988,7 +3000,7 @@ class Nautilus(EditorInterface, Shell):
|
|
|
2988
3000
|
'*delete pressed' : (5, skip),
|
|
2989
3001
|
'*backspace pressed' : (5, self.OnBackspace),
|
|
2990
3002
|
'*backspace released' : (5, self.call_module_autocomp),
|
|
2991
|
-
|
|
3003
|
+
'*S-backspace pressed' : (0, clear_autocomp, fork),
|
|
2992
3004
|
'*alt pressed' : (5, ),
|
|
2993
3005
|
'*ctrl pressed' : (5, ),
|
|
2994
3006
|
'*shift pressed' : (5, ),
|
|
@@ -3366,7 +3378,7 @@ class Nautilus(EditorInterface, Shell):
|
|
|
3366
3378
|
(override) Don't remove trailing ps2 + spaces.
|
|
3367
3379
|
Don't invoke ``GotoLine``.
|
|
3368
3380
|
"""
|
|
3369
|
-
region = self.
|
|
3381
|
+
region = self.get_command_region(self.cline)
|
|
3370
3382
|
if region:
|
|
3371
3383
|
p, q = (self.PositionFromLine(x) for x in region)
|
|
3372
3384
|
p += len(sys.ps1)
|
|
@@ -3378,7 +3390,7 @@ class Nautilus(EditorInterface, Shell):
|
|
|
3378
3390
|
return command
|
|
3379
3391
|
return ''
|
|
3380
3392
|
|
|
3381
|
-
def
|
|
3393
|
+
def get_command_region(self, line):
|
|
3382
3394
|
"""Line numbers of prompt head and tail containing the line."""
|
|
3383
3395
|
lc = line
|
|
3384
3396
|
le = lc + 1
|
|
@@ -3639,7 +3651,7 @@ class Nautilus(EditorInterface, Shell):
|
|
|
3639
3651
|
err = re.findall(py_error_re, msg, re.M)
|
|
3640
3652
|
lines = [int(ln) for fn, ln in err if fn == filename]
|
|
3641
3653
|
if lines:
|
|
3642
|
-
region = self.
|
|
3654
|
+
region = self.get_command_region(self.cline)
|
|
3643
3655
|
lx = region[0] + lines[-1] - 1
|
|
3644
3656
|
self.red_pointer = lx
|
|
3645
3657
|
self.message(e)
|
mwx/plugins/ffmpeg_view.py
CHANGED
|
@@ -115,7 +115,7 @@ class Plugin(Layer):
|
|
|
115
115
|
self.layout((self.mc,), expand=2)
|
|
116
116
|
self.layout((self.ss, self.to, self.rw, self.fw,
|
|
117
117
|
self.snp, self.crop, self.exp),
|
|
118
|
-
expand=0, row=7, style='button', lw=
|
|
118
|
+
expand=0, row=7, style='button', lw=28, cw=0, tw=64)
|
|
119
119
|
|
|
120
120
|
self.menu[0:5] = [
|
|
121
121
|
(1, "&Load file", Icon('open'),
|