mwxlib 1.4.12__py3-none-any.whl → 1.4.20__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 +18 -3
- mwx/framework.py +50 -50
- mwx/graphman.py +24 -29
- mwx/matplot2.py +2 -2
- mwx/matplot2g.py +5 -4
- mwx/mgplt.py +2 -4
- mwx/nutshell.py +170 -88
- mwx/plugins/ffmpeg_view.py +5 -7
- mwx/plugins/frame_listview.py +2 -4
- mwx/utilus.py +1 -2
- mwx/wxmon.py +2 -1
- mwx/wxpdb.py +0 -2
- mwx/wxwit.py +12 -15
- {mwxlib-1.4.12.dist-info → mwxlib-1.4.20.dist-info}/METADATA +1 -1
- mwxlib-1.4.20.dist-info/RECORD +28 -0
- {mwxlib-1.4.12.dist-info → mwxlib-1.4.20.dist-info}/WHEEL +1 -1
- mwxlib-1.4.12.dist-info/RECORD +0 -28
- {mwxlib-1.4.12.dist-info → mwxlib-1.4.20.dist-info}/top_level.txt +0 -0
mwx/controls.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#! python3
|
|
2
2
|
"""mwxlib param controller and wx custom controls.
|
|
3
3
|
"""
|
|
4
|
+
from contextlib import contextmanager
|
|
4
5
|
from itertools import chain
|
|
5
|
-
import
|
|
6
|
+
import io
|
|
6
7
|
import wx
|
|
7
8
|
import wx.lib.platebtn as pb
|
|
8
9
|
import wx.lib.scrolledpanel as scrolled
|
|
@@ -13,7 +14,7 @@ from .utilus import funcall as _F
|
|
|
13
14
|
from .framework import pack, Menu, CtrlInterface
|
|
14
15
|
|
|
15
16
|
import numpy as np
|
|
16
|
-
from numpy import nan, inf # noqa
|
|
17
|
+
from numpy import nan, inf # noqa # necessary to eval
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
def _Tip(*tips):
|
|
@@ -772,6 +773,19 @@ class Clipboard:
|
|
|
772
773
|
This does not work unless wx.App instance exists.
|
|
773
774
|
The clipboard data cannot be transferred unless wx.Frame exists.
|
|
774
775
|
"""
|
|
776
|
+
@contextmanager
|
|
777
|
+
@staticmethod
|
|
778
|
+
def istrstream():
|
|
779
|
+
with io.StringIO(Clipboard.read()) as f:
|
|
780
|
+
yield f
|
|
781
|
+
|
|
782
|
+
@contextmanager
|
|
783
|
+
@staticmethod
|
|
784
|
+
def ostrstream():
|
|
785
|
+
with io.StringIO() as f:
|
|
786
|
+
yield f
|
|
787
|
+
Clipboard.write(f.getvalue())
|
|
788
|
+
|
|
775
789
|
@staticmethod
|
|
776
790
|
def read(verbose=False):
|
|
777
791
|
do = wx.TextDataObject()
|
|
@@ -849,7 +863,7 @@ class Clipboard:
|
|
|
849
863
|
## --------------------------------
|
|
850
864
|
|
|
851
865
|
class Icon(wx.Bitmap):
|
|
852
|
-
"""
|
|
866
|
+
"""Return an iconic bitmap with the specified size (w, h).
|
|
853
867
|
|
|
854
868
|
The key is either Icon.provided_arts or Icon.custom_images key.
|
|
855
869
|
If the key is empty it returns a transparent bitmap, otherwise NullBitmap.
|
|
@@ -1021,6 +1035,7 @@ class Button(pb.PlateButton):
|
|
|
1021
1035
|
|
|
1022
1036
|
def SetBitmap(self, bmp):
|
|
1023
1037
|
"""Set the bitmap displayed in the button.
|
|
1038
|
+
|
|
1024
1039
|
(override) If it fails, it clears the bitmap.
|
|
1025
1040
|
"""
|
|
1026
1041
|
try:
|
mwx/framework.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#! python3
|
|
2
2
|
"""mwxlib framework.
|
|
3
3
|
"""
|
|
4
|
-
__version__ = "1.4.
|
|
4
|
+
__version__ = "1.4.20"
|
|
5
5
|
__author__ = "Kazuya O'moto <komoto@jeol.co.jp>"
|
|
6
6
|
|
|
7
7
|
from contextlib import contextmanager
|
|
@@ -49,7 +49,7 @@ def deb(target=None, loop=True, locals=None, **kwargs):
|
|
|
49
49
|
kwargs.setdefault("execStartupScript", True)
|
|
50
50
|
kwargs.setdefault("ensureClose", True)
|
|
51
51
|
|
|
52
|
-
if "debrc" in kwargs:
|
|
52
|
+
if "debrc" in kwargs: # for backward compatibility
|
|
53
53
|
warn("Deprecated keyword: 'debrc'. Use 'session' instead.", DeprecationWarning)
|
|
54
54
|
kwargs.setdefault('session', kwargs.pop('debrc'))
|
|
55
55
|
|
|
@@ -221,7 +221,7 @@ class KeyCtrlInterfaceMixin:
|
|
|
221
221
|
|
|
222
222
|
@staticmethod
|
|
223
223
|
def getKeyState(key):
|
|
224
|
-
"""
|
|
224
|
+
"""Return state of speckey (cf. wx.GetKeyState)."""
|
|
225
225
|
try:
|
|
226
226
|
return wx.GetKeyState(_speckeys_wxkmap[key])
|
|
227
227
|
except KeyError:
|
|
@@ -618,8 +618,9 @@ class Menu(wx.Menu):
|
|
|
618
618
|
def Destroy(self):
|
|
619
619
|
try:
|
|
620
620
|
self._unbind()
|
|
621
|
-
|
|
622
|
-
|
|
621
|
+
except Exception:
|
|
622
|
+
pass
|
|
623
|
+
return wx.Menu.Destroy(self)
|
|
623
624
|
|
|
624
625
|
@staticmethod
|
|
625
626
|
def Popup(parent, menulist, *args, **kwargs):
|
|
@@ -795,11 +796,9 @@ class Frame(wx.Frame, KeyCtrlInterfaceMixin):
|
|
|
795
796
|
"About this software")
|
|
796
797
|
|
|
797
798
|
def Destroy(self):
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
finally:
|
|
802
|
-
return wx.Frame.Destroy(self)
|
|
799
|
+
self.timer.Stop()
|
|
800
|
+
self.shellframe.Destroy() # shellframe is not my child
|
|
801
|
+
return wx.Frame.Destroy(self)
|
|
803
802
|
|
|
804
803
|
|
|
805
804
|
class MiniFrame(wx.MiniFrame, KeyCtrlInterfaceMixin):
|
|
@@ -876,12 +875,12 @@ class AuiNotebook(aui.AuiNotebook):
|
|
|
876
875
|
|
|
877
876
|
@property
|
|
878
877
|
def _all_tabs(self): # (deprecated) internal use only
|
|
879
|
-
"""
|
|
878
|
+
"""Return all AuiTabCtrl objects (internal use only)."""
|
|
880
879
|
return [x for x in self.Children if isinstance(x, aui.AuiTabCtrl)]
|
|
881
880
|
|
|
882
881
|
@property
|
|
883
882
|
def _all_panes(self): # (deprecated) internal use only
|
|
884
|
-
"""
|
|
883
|
+
"""Return all AuiPaneInfo excluding `dummy` one (internal use only)."""
|
|
885
884
|
return list(self._mgr.AllPanes)[1:]
|
|
886
885
|
|
|
887
886
|
def get_pages(self, type=None):
|
|
@@ -919,7 +918,7 @@ class AuiNotebook(aui.AuiNotebook):
|
|
|
919
918
|
return True
|
|
920
919
|
|
|
921
920
|
def find_tab(self, win):
|
|
922
|
-
"""
|
|
921
|
+
"""Return AuiTabCtrl and AuiNotebookPage for the window.
|
|
923
922
|
|
|
924
923
|
cf. aui.AuiNotebook.FindTab -> bool, tab, idx
|
|
925
924
|
Note:
|
|
@@ -1255,9 +1254,9 @@ class ShellFrame(MiniFrame):
|
|
|
1255
1254
|
'* released' : (0, fork_debugger),
|
|
1256
1255
|
'C-g pressed' : (0, self.Quit, fork_debugger),
|
|
1257
1256
|
'f1 pressed' : (0, self.About),
|
|
1258
|
-
'C-f pressed' : (0, self.
|
|
1259
|
-
'f3 pressed' : (0, self.
|
|
1260
|
-
'S-f3 pressed' : (0, self.
|
|
1257
|
+
'C-f pressed' : (0, self.on_search_dialog),
|
|
1258
|
+
'f3 pressed' : (0, self.repeat_forward_search),
|
|
1259
|
+
'S-f3 pressed' : (0, self.repeat_backward_search),
|
|
1261
1260
|
'f11 pressed' : (0, _F(self.toggle_window, win=self.ghost, alias='toggle_ghost')),
|
|
1262
1261
|
'S-f11 pressed' : (0, _F(self.toggle_window, win=self.watcher, alias='toggle_watcher')),
|
|
1263
1262
|
'f12 pressed' : (0, _F(self.Close, alias="close")),
|
|
@@ -1413,12 +1412,11 @@ class ShellFrame(MiniFrame):
|
|
|
1413
1412
|
del builtins.highlight
|
|
1414
1413
|
except AttributeError:
|
|
1415
1414
|
pass
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
return MiniFrame.Destroy(self)
|
|
1415
|
+
|
|
1416
|
+
self.timer.Stop()
|
|
1417
|
+
self.save_session()
|
|
1418
|
+
self._mgr.UnInit()
|
|
1419
|
+
return MiniFrame.Destroy(self)
|
|
1422
1420
|
|
|
1423
1421
|
def OnClose(self, evt):
|
|
1424
1422
|
if self.debugger.busy:
|
|
@@ -1493,24 +1491,16 @@ class ShellFrame(MiniFrame):
|
|
|
1493
1491
|
evt.Skip()
|
|
1494
1492
|
|
|
1495
1493
|
def OnShow(self, evt):
|
|
1496
|
-
pane
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
self.inspector.watch()
|
|
1500
|
-
self.monitor.watch()
|
|
1501
|
-
else:
|
|
1502
|
-
if pane.IsDocked():
|
|
1503
|
-
self.inspector.unwatch()
|
|
1504
|
-
self.monitor.unwatch()
|
|
1494
|
+
for pane in self._mgr.GetAllPanes():
|
|
1495
|
+
## When the window is hidden, disable docking and keep child panes floating.
|
|
1496
|
+
pane.Dockable(evt.IsShown() or pane.IsDocked())
|
|
1505
1497
|
evt.Skip()
|
|
1506
1498
|
|
|
1507
1499
|
def OnGhostShow(self, evt):
|
|
1508
1500
|
if evt.IsShown():
|
|
1509
1501
|
self.inspector.watch()
|
|
1510
|
-
self.monitor.watch()
|
|
1511
1502
|
else:
|
|
1512
1503
|
self.inspector.unwatch()
|
|
1513
|
-
self.monitor.unwatch()
|
|
1514
1504
|
evt.Skip()
|
|
1515
1505
|
|
|
1516
1506
|
def OnConsolePageChanged(self, evt): #<wx._aui.AuiNotebookEvent>
|
|
@@ -1610,6 +1600,7 @@ class ShellFrame(MiniFrame):
|
|
|
1610
1600
|
|
|
1611
1601
|
def Quit(self, evt=None):
|
|
1612
1602
|
"""Stop debugger and monitor."""
|
|
1603
|
+
self.monitor.unwatch()
|
|
1613
1604
|
self.debugger.unwatch()
|
|
1614
1605
|
self.debugger.send_input('\n') # terminates the reader of threading pdb
|
|
1615
1606
|
shell = self.debugger.interactive_shell # reset interp locals
|
|
@@ -1951,13 +1942,13 @@ class ShellFrame(MiniFrame):
|
|
|
1951
1942
|
return next((x for x in self.get_all_editors() if x.IsShown()), self.Scratch)
|
|
1952
1943
|
|
|
1953
1944
|
## --------------------------------
|
|
1954
|
-
## Find text dialog
|
|
1945
|
+
## Find / Replace text dialog
|
|
1955
1946
|
## --------------------------------
|
|
1956
1947
|
## *** The following code is a modification of <wx.py.frame.Frame> ***
|
|
1957
1948
|
|
|
1958
1949
|
__find_target = None
|
|
1959
1950
|
|
|
1960
|
-
def
|
|
1951
|
+
def on_search_dialog(self, evt):
|
|
1961
1952
|
if self.findDlg is not None:
|
|
1962
1953
|
self.findDlg.SetFocus()
|
|
1963
1954
|
return
|
|
@@ -1967,29 +1958,38 @@ class ShellFrame(MiniFrame):
|
|
|
1967
1958
|
return
|
|
1968
1959
|
self.__find_target = wnd
|
|
1969
1960
|
self.findData.FindString = wnd.topic_at_caret
|
|
1970
|
-
self.
|
|
1971
|
-
|
|
1961
|
+
self.findData.Flags |= wx.FR_DOWN
|
|
1962
|
+
self.findDlg = wx.FindReplaceDialog(wnd, self.findData, "Find")
|
|
1972
1963
|
self.findDlg.Show()
|
|
1973
1964
|
|
|
1974
|
-
def
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1965
|
+
def repeat_forward_search(self, evt):
|
|
1966
|
+
self.OnFindNext(evt, direction=True)
|
|
1967
|
+
|
|
1968
|
+
def repeat_backward_search(self, evt):
|
|
1969
|
+
self.OnFindNext(evt, direction=False)
|
|
1970
|
+
|
|
1971
|
+
def OnFindNext(self, evt, direction=None): #<wx._core.FindDialogEvent>
|
|
1972
|
+
if not self.findData.FindString:
|
|
1973
|
+
self.message("No last search.")
|
|
1974
|
+
return
|
|
1975
|
+
|
|
1976
|
+
if direction is not None:
|
|
1977
|
+
## dir = self.findData.Flags & wx.FR_DOWN # 0:up, 1:down
|
|
1978
|
+
## if direction != dir:
|
|
1979
|
+
## self.findData.Flags ^= wx.FR_DOWN # toggle up/down flag
|
|
1980
|
+
if direction:
|
|
1981
|
+
self.findData.Flags |= wx.FR_DOWN
|
|
1982
|
+
else:
|
|
1983
|
+
self.findData.Flags &= ~wx.FR_DOWN
|
|
1979
1984
|
|
|
1980
1985
|
wnd = wx.Window.FindFocus()
|
|
1981
1986
|
if not isinstance(wnd, stc.StyledTextCtrl):
|
|
1982
1987
|
wnd = self.__find_target
|
|
1983
1988
|
if not wnd:
|
|
1984
1989
|
return
|
|
1985
|
-
wnd.DoFindNext(
|
|
1990
|
+
wnd.DoFindNext(self.findData, self.findDlg or wnd)
|
|
1986
1991
|
if self.findDlg:
|
|
1987
1992
|
self.OnFindClose(None)
|
|
1988
|
-
wnd.EnsureVisible(wnd.cline)
|
|
1989
|
-
wnd.ensureLineMoreOnScreen(wnd.cline)
|
|
1990
|
-
|
|
1991
|
-
def OnFindPrev(self, evt):
|
|
1992
|
-
self.OnFindNext(evt, backward=True)
|
|
1993
1993
|
|
|
1994
1994
|
def OnFindClose(self, evt): #<wx._core.FindDialogEvent>
|
|
1995
1995
|
self.findDlg.Destroy()
|
|
@@ -2003,7 +2003,7 @@ def filling(obj=None, **kwargs):
|
|
|
2003
2003
|
rootLabel=typename(obj),
|
|
2004
2004
|
pos=wx.GetMousePosition(),
|
|
2005
2005
|
**kwargs)
|
|
2006
|
-
frame.filling.text.WrapMode = 0
|
|
2007
|
-
frame.filling.text.Zoom = -1
|
|
2006
|
+
frame.filling.text.WrapMode = 0 # no wrap
|
|
2007
|
+
frame.filling.text.Zoom = -1 # zoom level of size of fonts
|
|
2008
2008
|
frame.Show()
|
|
2009
2009
|
return frame
|
mwx/graphman.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#! python3
|
|
2
2
|
"""Graph manager.
|
|
3
3
|
"""
|
|
4
|
+
from contextlib import contextmanager
|
|
4
5
|
from functools import wraps
|
|
5
6
|
from importlib import reload, import_module
|
|
6
|
-
from contextlib import contextmanager
|
|
7
7
|
from bdb import BdbQuit
|
|
8
8
|
from pprint import pformat
|
|
9
9
|
import threading
|
|
@@ -30,10 +30,10 @@ from .utilus import funcall as _F
|
|
|
30
30
|
from .controls import KnobCtrlPanel, Icon
|
|
31
31
|
from .framework import CtrlInterface, AuiNotebook, Menu, FSM
|
|
32
32
|
|
|
33
|
-
from .matplot2 import MatplotPanel
|
|
33
|
+
from .matplot2 import MatplotPanel # noqa
|
|
34
34
|
from .matplot2g import GraphPlot
|
|
35
|
-
from .matplot2lg import LinePlot
|
|
36
|
-
from .matplot2lg import LineProfile
|
|
35
|
+
from .matplot2lg import LinePlot # noqa
|
|
36
|
+
from .matplot2lg import LineProfile # noqa
|
|
37
37
|
from .matplot2lg import Histogram
|
|
38
38
|
|
|
39
39
|
|
|
@@ -451,7 +451,7 @@ class LayerInterface(CtrlInterface):
|
|
|
451
451
|
lambda self,v: self.Show(v))
|
|
452
452
|
|
|
453
453
|
def IsShown(self):
|
|
454
|
-
"""
|
|
454
|
+
"""Return True if the window is physically visible on the screen.
|
|
455
455
|
|
|
456
456
|
(override) Equivalent to ``IsShownOnScreen``.
|
|
457
457
|
Note: The instance could be a page within a notebook.
|
|
@@ -898,8 +898,6 @@ class Frame(mwx.Frame):
|
|
|
898
898
|
evt.Skip()
|
|
899
899
|
|
|
900
900
|
def Destroy(self):
|
|
901
|
-
## for name in list(self.plugins):
|
|
902
|
-
## self.unload_plug(name) # => plug.Destroy
|
|
903
901
|
self._mgr.UnInit()
|
|
904
902
|
return mwx.Frame.Destroy(self)
|
|
905
903
|
|
|
@@ -1348,7 +1346,7 @@ class Frame(mwx.Frame):
|
|
|
1348
1346
|
plug = _plug
|
|
1349
1347
|
init(shell)
|
|
1350
1348
|
self.shellframe.Show()
|
|
1351
|
-
if wx.GetKeyState(wx.WXK_SHIFT):
|
|
1349
|
+
if wx.GetKeyState(wx.WXK_SHIFT): # open the source code.
|
|
1352
1350
|
self.shellframe.load(plug)
|
|
1353
1351
|
|
|
1354
1352
|
def OnLoadPlugins(self, evt):
|
|
@@ -1383,9 +1381,9 @@ class Frame(mwx.Frame):
|
|
|
1383
1381
|
view = self.selected_view
|
|
1384
1382
|
|
|
1385
1383
|
if not filename:
|
|
1386
|
-
|
|
1384
|
+
default_path = view.frame.pathname if view.frame else None
|
|
1387
1385
|
with wx.FileDialog(self, "Select index file to import",
|
|
1388
|
-
defaultDir=os.path.dirname(
|
|
1386
|
+
defaultDir=os.path.dirname(default_path or ''),
|
|
1389
1387
|
defaultFile=self.ATTRIBUTESFILE,
|
|
1390
1388
|
wildcard="Index (*.index)|*.index|"
|
|
1391
1389
|
"ALL files (*.*)|*.*",
|
|
@@ -1420,9 +1418,9 @@ class Frame(mwx.Frame):
|
|
|
1420
1418
|
return None
|
|
1421
1419
|
|
|
1422
1420
|
if not filename:
|
|
1423
|
-
|
|
1421
|
+
default_path = view.frame.pathname if view.frame else None
|
|
1424
1422
|
with wx.FileDialog(self, "Select index file to export",
|
|
1425
|
-
defaultDir=os.path.dirname(
|
|
1423
|
+
defaultDir=os.path.dirname(default_path or ''),
|
|
1426
1424
|
defaultFile=self.ATTRIBUTESFILE,
|
|
1427
1425
|
wildcard="Index (*.index)|*.index",
|
|
1428
1426
|
style=wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) as dlg:
|
|
@@ -1437,7 +1435,8 @@ class Frame(mwx.Frame):
|
|
|
1437
1435
|
self.message("Export index of {!r}...".format(frame.name))
|
|
1438
1436
|
fn = frame.pathname
|
|
1439
1437
|
if not fn:
|
|
1440
|
-
fn = os.path.join(savedir,
|
|
1438
|
+
fn = os.path.join(savedir,
|
|
1439
|
+
re.sub(r'[\/:*?"<>|]', '_', frame.name)) # replace invalid chars
|
|
1441
1440
|
if not os.path.exists(fn):
|
|
1442
1441
|
if not fn.endswith('.tif'):
|
|
1443
1442
|
fn += '.tif'
|
|
@@ -1466,8 +1465,8 @@ class Frame(mwx.Frame):
|
|
|
1466
1465
|
@classmethod
|
|
1467
1466
|
def read_attributes(self, filename):
|
|
1468
1467
|
"""Read attributes file."""
|
|
1469
|
-
from numpy import nan, inf # noqa
|
|
1470
|
-
import datetime # noqa
|
|
1468
|
+
from numpy import nan, inf # noqa # necessary to eval
|
|
1469
|
+
import datetime # noqa # necessary to eval
|
|
1471
1470
|
try:
|
|
1472
1471
|
res = {}
|
|
1473
1472
|
mis = {}
|
|
@@ -1491,8 +1490,7 @@ class Frame(mwx.Frame):
|
|
|
1491
1490
|
except Exception as e:
|
|
1492
1491
|
print("- Failed to read attributes.", e)
|
|
1493
1492
|
wx.MessageBox(str(e), style=wx.ICON_ERROR)
|
|
1494
|
-
|
|
1495
|
-
return res, mis # finally raises no exception
|
|
1493
|
+
return res, mis
|
|
1496
1494
|
|
|
1497
1495
|
@classmethod
|
|
1498
1496
|
def write_attributes(self, filename, frames):
|
|
@@ -1503,7 +1501,6 @@ class Frame(mwx.Frame):
|
|
|
1503
1501
|
|
|
1504
1502
|
## `res` order may differ from that of given frames,
|
|
1505
1503
|
## so we take a few steps to merge `new` to be exported.
|
|
1506
|
-
|
|
1507
1504
|
res.update(new) # res updates to new info,
|
|
1508
1505
|
new.update(res) # copy res back keeping new order.
|
|
1509
1506
|
|
|
@@ -1513,8 +1510,7 @@ class Frame(mwx.Frame):
|
|
|
1513
1510
|
except Exception as e:
|
|
1514
1511
|
print("- Failed to write attributes.", e)
|
|
1515
1512
|
wx.MessageBox(str(e), style=wx.ICON_ERROR)
|
|
1516
|
-
|
|
1517
|
-
return new, mis # finally raises no exception
|
|
1513
|
+
return new, mis
|
|
1518
1514
|
|
|
1519
1515
|
def load_frame(self, paths=None, view=None):
|
|
1520
1516
|
"""Load frames from files to the view window.
|
|
@@ -1592,9 +1588,9 @@ class Frame(mwx.Frame):
|
|
|
1592
1588
|
paths = [paths]
|
|
1593
1589
|
|
|
1594
1590
|
if paths is None:
|
|
1595
|
-
|
|
1591
|
+
default_path = view.frame.pathname if view.frame else None
|
|
1596
1592
|
with wx.FileDialog(self, "Open image files",
|
|
1597
|
-
defaultDir=os.path.dirname(
|
|
1593
|
+
defaultDir=os.path.dirname(default_path or ''),
|
|
1598
1594
|
defaultFile='',
|
|
1599
1595
|
wildcard='|'.join(self.wildcards),
|
|
1600
1596
|
style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST
|
|
@@ -1649,10 +1645,10 @@ class Frame(mwx.Frame):
|
|
|
1649
1645
|
return None
|
|
1650
1646
|
|
|
1651
1647
|
if not path:
|
|
1652
|
-
|
|
1648
|
+
default_path = view.frame.pathname if view.frame else None
|
|
1653
1649
|
with wx.FileDialog(self, "Save buffer as",
|
|
1654
|
-
defaultDir=os.path.dirname(
|
|
1655
|
-
defaultFile=re.sub(r'[\/:*?"<>|]', '_', frame.name),
|
|
1650
|
+
defaultDir=os.path.dirname(default_path or ''),
|
|
1651
|
+
defaultFile=re.sub(r'[\/:*?"<>|]', '_', frame.name), # replace invalid chars
|
|
1656
1652
|
wildcard='|'.join(self.wildcards),
|
|
1657
1653
|
style=wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) as dlg:
|
|
1658
1654
|
if dlg.ShowModal() != wx.ID_OK:
|
|
@@ -1799,13 +1795,12 @@ class Frame(mwx.Frame):
|
|
|
1799
1795
|
o.write("self._mgr.LoadPerspective({!r})\n".format(self._mgr.SavePerspective()))
|
|
1800
1796
|
|
|
1801
1797
|
def _save(view):
|
|
1802
|
-
name = view.Name
|
|
1803
1798
|
paths = [x.pathname for x in view.all_frames if x.pathname]
|
|
1804
|
-
o.write(f"self.{
|
|
1805
|
-
o.write(f"self.load_frame({paths!r}, self.{
|
|
1799
|
+
o.write(f"self.{view.Name}.unit = {view.unit:g}\n")
|
|
1800
|
+
o.write(f"self.load_frame({paths!r}, self.{view.Name})\n")
|
|
1806
1801
|
try:
|
|
1807
1802
|
index = paths.index(view.frame.pathname)
|
|
1808
|
-
o.write(f"self.{
|
|
1803
|
+
o.write(f"self.{view.Name}.select({index})\n")
|
|
1809
1804
|
except Exception:
|
|
1810
1805
|
pass
|
|
1811
1806
|
|
mwx/matplot2.py
CHANGED
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
"""
|
|
4
4
|
import wx
|
|
5
5
|
|
|
6
|
-
import matplotlib; matplotlib.use('wxagg')
|
|
6
|
+
import matplotlib; matplotlib.use('wxagg') # noqa
|
|
7
7
|
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
|
|
8
8
|
from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg as Toolbar
|
|
9
9
|
from matplotlib.widgets import Cursor
|
|
10
10
|
from matplotlib.figure import Figure
|
|
11
|
-
from matplotlib import cm
|
|
12
11
|
import numpy as np
|
|
13
12
|
|
|
14
13
|
from . import framework as mwx
|
|
@@ -40,6 +39,7 @@ if 1:
|
|
|
40
39
|
class Cursor(Cursor):
|
|
41
40
|
def onmove(self, event):
|
|
42
41
|
"""Internal event handler to draw the cursor when the mouse moves.
|
|
42
|
+
|
|
43
43
|
(override) If the cursor is off the axes, the xdata and ydata will
|
|
44
44
|
be None, and will simply be cleared rather than drawn.
|
|
45
45
|
"""
|
mwx/matplot2g.py
CHANGED
|
@@ -13,7 +13,7 @@ from scipy import ndimage as ndi
|
|
|
13
13
|
|
|
14
14
|
from . import framework as mwx
|
|
15
15
|
from .framework import Menu
|
|
16
|
-
from .utilus import warn
|
|
16
|
+
## from .utilus import warn
|
|
17
17
|
from .utilus import funcall as _F
|
|
18
18
|
from .controls import Clipboard
|
|
19
19
|
from .matplot2 import MatplotPanel
|
|
@@ -636,6 +636,8 @@ class GraphPlot(MatplotPanel):
|
|
|
636
636
|
show : Show immediately when loaded.
|
|
637
637
|
**kwargs: frame attributes.
|
|
638
638
|
"""
|
|
639
|
+
assert buf is not None, "Load buffer must be an array or string (not None)"
|
|
640
|
+
|
|
639
641
|
if isinstance(buf, str):
|
|
640
642
|
buf = Image.open(buf)
|
|
641
643
|
|
|
@@ -1639,8 +1641,7 @@ class GraphPlot(MatplotPanel):
|
|
|
1639
1641
|
color='red', size=7, #fontsize=8,
|
|
1640
1642
|
)
|
|
1641
1643
|
)
|
|
1642
|
-
self.
|
|
1643
|
-
self.trace_point(*self.selector, type=MARK)
|
|
1644
|
+
self.trace_point(*self.get_current_mark(), type=MARK)
|
|
1644
1645
|
self.draw(self.marked)
|
|
1645
1646
|
|
|
1646
1647
|
def OnMarkAppend(self, evt):
|
|
@@ -1663,7 +1664,7 @@ class GraphPlot(MatplotPanel):
|
|
|
1663
1664
|
else:
|
|
1664
1665
|
self.__marksel = [k]
|
|
1665
1666
|
self.update_art_of_mark()
|
|
1666
|
-
|
|
1667
|
+
self.selector = self.get_current_mark()
|
|
1667
1668
|
if self.selector.shape[1] > 1:
|
|
1668
1669
|
self.handler('line_drawn', self.frame) # 多重マーカー選択時
|
|
1669
1670
|
|