mwxlib 0.98.1__py3-none-any.whl → 0.98.6__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 +5 -4
- mwx/framework.py +38 -41
- mwx/graphman.py +49 -57
- mwx/matplot2g.py +3 -3
- mwx/mgplt.py +1 -1
- mwx/nutshell.py +112 -107
- mwx/plugins/ffmpeg_view.py +2 -2
- mwx/utilus.py +1 -1
- mwxlib-0.98.6.dist-info/METADATA +228 -0
- {mwxlib-0.98.1.dist-info → mwxlib-0.98.6.dist-info}/RECORD +13 -13
- {mwxlib-0.98.1.dist-info → mwxlib-0.98.6.dist-info}/WHEEL +1 -1
- mwxlib-0.98.1.dist-info/METADATA +0 -54
- {mwxlib-0.98.1.dist-info → mwxlib-0.98.6.dist-info}/LICENSE +0 -0
- {mwxlib-0.98.1.dist-info → mwxlib-0.98.6.dist-info}/top_level.txt +0 -0
mwx/controls.py
CHANGED
|
@@ -9,7 +9,7 @@ import wx.lib.scrolledpanel as scrolled
|
|
|
9
9
|
from . import images
|
|
10
10
|
from .utilus import SSM
|
|
11
11
|
from .utilus import funcall as _F
|
|
12
|
-
from .framework import pack, Menu
|
|
12
|
+
from .framework import pack, Menu, postcall
|
|
13
13
|
|
|
14
14
|
import numpy as np
|
|
15
15
|
from numpy import nan, inf # noqa: necessary to eval
|
|
@@ -20,7 +20,7 @@ def _Tip(*tips):
|
|
|
20
20
|
return '\n'.join(filter(None, tips)).strip()
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
class Param
|
|
23
|
+
class Param:
|
|
24
24
|
"""Standard Parameter
|
|
25
25
|
|
|
26
26
|
Args:
|
|
@@ -438,6 +438,8 @@ class Knob(wx.Panel):
|
|
|
438
438
|
self.label.SetLabel(v.name + t)
|
|
439
439
|
self.label.Refresh()
|
|
440
440
|
|
|
441
|
+
## Note: wxAssertionError in text.SetValue
|
|
442
|
+
@postcall
|
|
441
443
|
def update_ctrl(self, valid=True, notify=False):
|
|
442
444
|
"""Called when value is being changed (internal use only)."""
|
|
443
445
|
v = self.__par
|
|
@@ -724,8 +726,7 @@ class ControlPanel(scrolled.ScrolledPanel):
|
|
|
724
726
|
except AttributeError:
|
|
725
727
|
p.value = v
|
|
726
728
|
except Exception as e: # failed to eval
|
|
727
|
-
print(f"- Failed to reset {p!r}
|
|
728
|
-
pass
|
|
729
|
+
print(f"- Failed to reset {p!r}.", e)
|
|
729
730
|
|
|
730
731
|
reset_params = set_params #: for backward compatibility
|
|
731
732
|
|
mwx/framework.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#! python3
|
|
2
2
|
"""mwxlib framework.
|
|
3
3
|
"""
|
|
4
|
-
__version__ = "0.98.
|
|
4
|
+
__version__ = "0.98.6"
|
|
5
5
|
__author__ = "Kazuya O'moto <komoto@jeol.co.jp>"
|
|
6
6
|
|
|
7
7
|
from contextlib import contextmanager
|
|
@@ -222,8 +222,6 @@ class KeyCtrlInterfaceMixin:
|
|
|
222
222
|
spec-map : 'C-c'
|
|
223
223
|
esc-map : 'escape'
|
|
224
224
|
"""
|
|
225
|
-
message = print # override this in subclass
|
|
226
|
-
|
|
227
225
|
@postcall
|
|
228
226
|
def post_message(self, *args, **kwargs):
|
|
229
227
|
return self.message(*args, **kwargs)
|
|
@@ -332,17 +330,22 @@ class CtrlInterface(KeyCtrlInterfaceMixin):
|
|
|
332
330
|
"""
|
|
333
331
|
handler = property(lambda self: self.__handler)
|
|
334
332
|
|
|
333
|
+
message = print # override this in subclass
|
|
334
|
+
|
|
335
335
|
def __init__(self):
|
|
336
336
|
self.__key = ''
|
|
337
337
|
self.__button = ''
|
|
338
338
|
self.__isDragging = False
|
|
339
|
-
self.__handler = FSM({
|
|
339
|
+
self.__handler = FSM({ # DNA<CtrlInterface>
|
|
340
|
+
None : {
|
|
341
|
+
},
|
|
342
|
+
0 : {
|
|
343
|
+
},
|
|
344
|
+
},
|
|
345
|
+
)
|
|
340
346
|
|
|
341
347
|
_M = self._mouse_handler
|
|
342
|
-
|
|
343
|
-
def _N(event, evt):
|
|
344
|
-
if self.handler(event, evt) is None:
|
|
345
|
-
evt.Skip()
|
|
348
|
+
_N = self._normal_handler
|
|
346
349
|
|
|
347
350
|
def activate(evt):
|
|
348
351
|
self.handler('focus_set', evt)
|
|
@@ -383,7 +386,7 @@ class CtrlInterface(KeyCtrlInterfaceMixin):
|
|
|
383
386
|
self.Bind(wx.EVT_MOUSE_AUX2_DCLICK, lambda v: _M('Xbutton2 dblclick', v))
|
|
384
387
|
|
|
385
388
|
self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, lambda v: _N('capture_lost', v))
|
|
386
|
-
self.Bind(wx.EVT_MOUSE_CAPTURE_CHANGED, lambda v: _N('
|
|
389
|
+
self.Bind(wx.EVT_MOUSE_CAPTURE_CHANGED, lambda v: _N('capture_changed', v))
|
|
387
390
|
|
|
388
391
|
def on_hotkey_press(self, evt): #<wx._core.KeyEvent>
|
|
389
392
|
"""Called when a key is pressed."""
|
|
@@ -461,6 +464,10 @@ class CtrlInterface(KeyCtrlInterfaceMixin):
|
|
|
461
464
|
self.SetFocusIgnoringChildren() # let the panel accept keys
|
|
462
465
|
except AttributeError:
|
|
463
466
|
pass
|
|
467
|
+
|
|
468
|
+
def _normal_handler(self, event, evt): #<wx._core.Event>
|
|
469
|
+
if self.handler(event, evt) is None:
|
|
470
|
+
evt.Skip()
|
|
464
471
|
|
|
465
472
|
|
|
466
473
|
## --------------------------------
|
|
@@ -763,15 +770,10 @@ class Frame(wx.Frame, KeyCtrlInterfaceMixin):
|
|
|
763
770
|
evt.Skip()
|
|
764
771
|
self.Bind(wx.EVT_CHAR_HOOK, hook_char)
|
|
765
772
|
|
|
766
|
-
def close(evt):
|
|
767
|
-
"""Close the window."""
|
|
768
|
-
self.Close()
|
|
769
|
-
|
|
770
773
|
self.__handler = FSM({ # DNA<Frame>
|
|
771
774
|
None : {
|
|
772
775
|
},
|
|
773
776
|
0 : {
|
|
774
|
-
'M-q pressed' : (0, close),
|
|
775
777
|
},
|
|
776
778
|
},
|
|
777
779
|
)
|
|
@@ -829,15 +831,10 @@ class MiniFrame(wx.MiniFrame, KeyCtrlInterfaceMixin):
|
|
|
829
831
|
## To default close >>> self.Unbind(wx.EVT_CLOSE)
|
|
830
832
|
self.Bind(wx.EVT_CLOSE, lambda v: self.Show(0))
|
|
831
833
|
|
|
832
|
-
def close(evt):
|
|
833
|
-
"""Close the window."""
|
|
834
|
-
self.Close()
|
|
835
|
-
|
|
836
834
|
self.__handler = FSM({ # DNA<MiniFrame>
|
|
837
835
|
None : {
|
|
838
836
|
},
|
|
839
837
|
0 : {
|
|
840
|
-
'M-q pressed' : (0, close),
|
|
841
838
|
},
|
|
842
839
|
},
|
|
843
840
|
)
|
|
@@ -1010,7 +1007,7 @@ class AuiNotebook(aui.AuiNotebook):
|
|
|
1010
1007
|
self._mgr.LoadPerspective(frames)
|
|
1011
1008
|
self._mgr.Update()
|
|
1012
1009
|
except Exception as e:
|
|
1013
|
-
print("- Failed to load perspective
|
|
1010
|
+
print("- Failed to load perspective.", e)
|
|
1014
1011
|
finally:
|
|
1015
1012
|
self.Parent.Thaw()
|
|
1016
1013
|
|
|
@@ -1278,16 +1275,13 @@ class ShellFrame(MiniFrame):
|
|
|
1278
1275
|
|
|
1279
1276
|
@self.Scratch.define_key('C-j')
|
|
1280
1277
|
def eval_line(evt):
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
evt.Skip(False)
|
|
1278
|
+
self.Scratch.buffer.eval_line()
|
|
1279
|
+
evt.Skip(False) # Don't skip explicitly.
|
|
1284
1280
|
|
|
1285
|
-
@self.Scratch.define_key('C-S-j')
|
|
1286
1281
|
@self.Scratch.define_key('M-j')
|
|
1287
1282
|
def eval_buffer(evt):
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
evt.Skip(False)
|
|
1283
|
+
self.Scratch.buffer.exec_region()
|
|
1284
|
+
evt.Skip(False) # Don't skip explicitly.
|
|
1291
1285
|
|
|
1292
1286
|
## Session
|
|
1293
1287
|
self.SESSION_FILE = get_rootpath(".debrc")
|
|
@@ -1298,7 +1292,9 @@ class ShellFrame(MiniFrame):
|
|
|
1298
1292
|
os.path.abspath(debrc) if debrc else self.SESSION_FILE)
|
|
1299
1293
|
|
|
1300
1294
|
def load_session(self, filename):
|
|
1301
|
-
"""Load session from file.
|
|
1295
|
+
"""Load session from file.
|
|
1296
|
+
Buffers, pointers, and the entire layout are loaded.
|
|
1297
|
+
"""
|
|
1302
1298
|
def _fload(editor, filename):
|
|
1303
1299
|
try:
|
|
1304
1300
|
buffer = editor.default_buffer or editor.new_buffer()
|
|
@@ -1325,7 +1321,9 @@ class ShellFrame(MiniFrame):
|
|
|
1325
1321
|
self.Position = (0, 0)
|
|
1326
1322
|
|
|
1327
1323
|
def save_session(self):
|
|
1328
|
-
"""Save session to file.
|
|
1324
|
+
"""Save session to file.
|
|
1325
|
+
Buffers, pointers, and the entire layout are saved.
|
|
1326
|
+
"""
|
|
1329
1327
|
def _fsave(editor, filename):
|
|
1330
1328
|
try:
|
|
1331
1329
|
buffer = editor.default_buffer
|
|
@@ -1340,20 +1338,20 @@ class ShellFrame(MiniFrame):
|
|
|
1340
1338
|
with open(self.SESSION_FILE, 'w', encoding='utf-8', newline='') as o:
|
|
1341
1339
|
o.write("#! Session file (This file is generated automatically)\n")
|
|
1342
1340
|
|
|
1343
|
-
for book in self.
|
|
1341
|
+
for book in (self.Scratch, self.Log):
|
|
1344
1342
|
for buf in book.all_buffers:
|
|
1345
1343
|
if buf.mtdelta is not None:
|
|
1346
|
-
o.write("self.
|
|
1347
|
-
.format(buf.filename, buf.markline+1
|
|
1344
|
+
o.write("self.{}.load_file({!r}, {})\n"
|
|
1345
|
+
.format(book.Name, buf.filename, buf.markline+1))
|
|
1348
1346
|
o.write('\n'.join((
|
|
1349
1347
|
"self.SetSize({})".format(self.Size),
|
|
1350
1348
|
"self.SetPosition({})".format(self.Position),
|
|
1351
|
-
"self.
|
|
1352
|
-
"self.
|
|
1349
|
+
"self.Scratch.loadPerspective({!r})".format(self.Scratch.savePerspective()),
|
|
1350
|
+
"self.Log.loadPerspective({!r})".format(self.Log.savePerspective()),
|
|
1353
1351
|
## Note: Perspectives should be called after all pages have been added.
|
|
1354
|
-
"
|
|
1355
|
-
"
|
|
1356
|
-
"
|
|
1352
|
+
"self.ghost.loadPerspective({!r})".format(self.ghost.savePerspective()),
|
|
1353
|
+
"self.watcher.loadPerspective({!r})".format(self.watcher.savePerspective()),
|
|
1354
|
+
"self._mgr.LoadPerspective({!r})".format(self._mgr.SavePerspective()),
|
|
1357
1355
|
"self._mgr.Update()\n",
|
|
1358
1356
|
)))
|
|
1359
1357
|
|
|
@@ -1547,9 +1545,8 @@ class ShellFrame(MiniFrame):
|
|
|
1547
1545
|
pane = self._mgr.GetPane(win)
|
|
1548
1546
|
if pane.IsDocked():
|
|
1549
1547
|
if not self.console.IsShown():
|
|
1550
|
-
self._mgr.RestoreMaximizedPane()
|
|
1551
|
-
self._mgr.Update()
|
|
1552
|
-
return
|
|
1548
|
+
self._mgr.RestoreMaximizedPane() # いったん表示切替
|
|
1549
|
+
self._mgr.Update() # 更新後に best_size 取得
|
|
1553
1550
|
if pane.IsShown():
|
|
1554
1551
|
pane.best_size = win.Size
|
|
1555
1552
|
self.popup_window(win, not pane.IsShown())
|
|
@@ -1597,7 +1594,7 @@ class ShellFrame(MiniFrame):
|
|
|
1597
1594
|
self.indicator.Value = 1
|
|
1598
1595
|
self.message("Quit")
|
|
1599
1596
|
|
|
1600
|
-
def _load(self, filename, lineno, editor):
|
|
1597
|
+
def _load(self, filename, lineno, editor): # for backward compatibility
|
|
1601
1598
|
"""Load file in the session (internal use only)."""
|
|
1602
1599
|
if isinstance(editor, str):
|
|
1603
1600
|
editor = getattr(self, editor, None)
|
mwx/graphman.py
CHANGED
|
@@ -50,7 +50,7 @@ def split_paths(obj):
|
|
|
50
50
|
return os.path.split(obj)
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
class Thread
|
|
53
|
+
class Thread:
|
|
54
54
|
"""Thread manager for graphman.Layer
|
|
55
55
|
|
|
56
56
|
The worker:thread runs the given target.
|
|
@@ -342,7 +342,6 @@ class LayerInterface(CtrlInterface):
|
|
|
342
342
|
'thread_error' : [ None ], # failed in error
|
|
343
343
|
'page_shown' : [ None, _F(self.Draw, True) ],
|
|
344
344
|
'page_closed' : [ None, _F(self.Draw, False) ],
|
|
345
|
-
'page_hidden' : [ None, _F(self.Draw, False) ],
|
|
346
345
|
},
|
|
347
346
|
0 : {
|
|
348
347
|
'C-c pressed' : (0, _F(copy_params)),
|
|
@@ -387,7 +386,6 @@ class LayerInterface(CtrlInterface):
|
|
|
387
386
|
lambda v: Menu.Popup(self, self.menu))
|
|
388
387
|
|
|
389
388
|
self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
|
|
390
|
-
self.Bind(wx.EVT_SHOW, self.OnShow)
|
|
391
389
|
|
|
392
390
|
try:
|
|
393
391
|
self.Init()
|
|
@@ -427,15 +425,6 @@ class LayerInterface(CtrlInterface):
|
|
|
427
425
|
del self.Arts
|
|
428
426
|
evt.Skip()
|
|
429
427
|
|
|
430
|
-
def OnShow(self, evt):
|
|
431
|
-
if not self:
|
|
432
|
-
return
|
|
433
|
-
if evt.IsShown():
|
|
434
|
-
self.handler('page_shown', self)
|
|
435
|
-
elif isinstance(self.Parent, aui.AuiNotebook):
|
|
436
|
-
self.handler('page_hidden', self)
|
|
437
|
-
evt.Skip()
|
|
438
|
-
|
|
439
428
|
Shown = property(
|
|
440
429
|
lambda self: self.IsShown(),
|
|
441
430
|
lambda self,v: self.Show(v))
|
|
@@ -443,16 +432,19 @@ class LayerInterface(CtrlInterface):
|
|
|
443
432
|
def IsShown(self):
|
|
444
433
|
"""Returns True if the window is physically visible on the screen.
|
|
445
434
|
|
|
446
|
-
|
|
447
|
-
|
|
435
|
+
(override) Equivalent to ``IsShownOnScreen``.
|
|
436
|
+
Note: The instance could be a page within a notebook.
|
|
448
437
|
"""
|
|
449
438
|
## return self.pane.IsShown()
|
|
450
439
|
return self.IsShownOnScreen()
|
|
451
440
|
|
|
452
|
-
def Show(self, show=True
|
|
453
|
-
"""
|
|
454
|
-
|
|
455
|
-
|
|
441
|
+
def Show(self, show=True):
|
|
442
|
+
"""Shows or hides the window.
|
|
443
|
+
|
|
444
|
+
(override) Show associated pane window.
|
|
445
|
+
Note: This might be called from a thread.
|
|
446
|
+
"""
|
|
447
|
+
wx.CallAfter(self.parent.show_pane, self, show)
|
|
456
448
|
|
|
457
449
|
Drawn = property(
|
|
458
450
|
lambda self: self.IsDrawn(),
|
|
@@ -478,21 +470,16 @@ class LayerInterface(CtrlInterface):
|
|
|
478
470
|
if canvas:
|
|
479
471
|
canvas.draw_idle()
|
|
480
472
|
except Exception as e:
|
|
481
|
-
print(f"- Failed to draw Arts of {self.__module__}
|
|
473
|
+
print(f"- Failed to draw Arts of {self.__module__}.", e)
|
|
482
474
|
del self.Arts
|
|
483
475
|
|
|
484
476
|
|
|
485
|
-
class Layer(
|
|
477
|
+
class Layer(LayerInterface, ControlPanel):
|
|
486
478
|
"""Graphman.Layer
|
|
487
479
|
"""
|
|
488
480
|
def __init__(self, parent, session=None, **kwargs):
|
|
489
481
|
ControlPanel.__init__(self, parent, **kwargs)
|
|
490
482
|
LayerInterface.__init__(self, parent, session)
|
|
491
|
-
|
|
492
|
-
## Explicit (override) precedence
|
|
493
|
-
IsShown = LayerInterface.IsShown
|
|
494
|
-
Shown = LayerInterface.Shown
|
|
495
|
-
Show = LayerInterface.Show
|
|
496
483
|
|
|
497
484
|
|
|
498
485
|
class Graph(GraphPlot):
|
|
@@ -942,9 +929,6 @@ class Frame(mwx.Frame):
|
|
|
942
929
|
pane.Float()
|
|
943
930
|
show = True
|
|
944
931
|
|
|
945
|
-
## Fork page shown/closed events to emulatie EVT_SHOW => plug.on_show.
|
|
946
|
-
## cf. >>> win.EventHandler.ProcessEvent(wx.ShowEvent(win.Id, show))
|
|
947
|
-
##
|
|
948
932
|
## Note: We need to distinguish cases whether:
|
|
949
933
|
## - pane.window is AuiNotebook or normal Panel,
|
|
950
934
|
## - pane.window is floating (win.Parent is AuiFloatingFrame) or docked.
|
|
@@ -1023,6 +1007,7 @@ class Frame(mwx.Frame):
|
|
|
1023
1007
|
plug.handler('page_closed', plug)
|
|
1024
1008
|
else:
|
|
1025
1009
|
win.handler('page_closed', win)
|
|
1010
|
+
evt.Skip()
|
|
1026
1011
|
|
|
1027
1012
|
## --------------------------------
|
|
1028
1013
|
## Plugin <Layer> interface
|
|
@@ -1070,15 +1055,10 @@ class Frame(mwx.Frame):
|
|
|
1070
1055
|
module.Plugin = cls
|
|
1071
1056
|
return cls
|
|
1072
1057
|
|
|
1073
|
-
class _Plugin(
|
|
1058
|
+
class _Plugin(LayerInterface, cls):
|
|
1074
1059
|
def __init__(self, parent, session=None, **kwargs):
|
|
1075
1060
|
cls.__init__(self, parent, **kwargs)
|
|
1076
1061
|
LayerInterface.__init__(self, parent, session)
|
|
1077
|
-
|
|
1078
|
-
## Explicit (override) precedence
|
|
1079
|
-
IsShown = LayerInterface.IsShown
|
|
1080
|
-
Shown = LayerInterface.Shown
|
|
1081
|
-
Show = LayerInterface.Show
|
|
1082
1062
|
|
|
1083
1063
|
_Plugin.__module__ = cls.__module__ = module.__name__
|
|
1084
1064
|
_Plugin.__name__ = cls.__name__ + str("~")
|
|
@@ -1110,7 +1090,7 @@ class Frame(mwx.Frame):
|
|
|
1110
1090
|
else:
|
|
1111
1091
|
module = import_module(name)
|
|
1112
1092
|
except Exception as e:
|
|
1113
|
-
print(f"- Unable to load {root!r}
|
|
1093
|
+
print(f"- Unable to load {root!r}.", e)
|
|
1114
1094
|
return False
|
|
1115
1095
|
|
|
1116
1096
|
## the module must have a class `Plugin`.
|
|
@@ -1172,7 +1152,7 @@ class Frame(mwx.Frame):
|
|
|
1172
1152
|
|
|
1173
1153
|
module = self.load_module(root)
|
|
1174
1154
|
if not module:
|
|
1175
|
-
return
|
|
1155
|
+
return False # failed to import
|
|
1176
1156
|
|
|
1177
1157
|
try:
|
|
1178
1158
|
name = module.Plugin.__module__
|
|
@@ -1328,18 +1308,21 @@ class Frame(mwx.Frame):
|
|
|
1328
1308
|
|
|
1329
1309
|
def reload_plug(self, name):
|
|
1330
1310
|
plug = self.get_plug(name)
|
|
1331
|
-
if not plug:
|
|
1311
|
+
if not plug or not plug.reloadable:
|
|
1332
1312
|
return
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1313
|
+
session = {}
|
|
1314
|
+
try:
|
|
1315
|
+
print("Reloading {}...".format(plug))
|
|
1316
|
+
plug.save_session(session)
|
|
1317
|
+
except Exception:
|
|
1318
|
+
traceback.print_exc()
|
|
1319
|
+
print("- Failed to save session of", plug)
|
|
1320
|
+
self.load_plug(plug.__module__, force=1, session=session)
|
|
1321
|
+
|
|
1322
|
+
## Update shell.target --> new plug
|
|
1323
|
+
for shell in self.shellframe.all_shells:
|
|
1324
|
+
if shell.target is plug:
|
|
1325
|
+
shell.handler('shell_activated', shell)
|
|
1343
1326
|
|
|
1344
1327
|
@ignore(ResourceWarning)
|
|
1345
1328
|
def edit_plug(self, name):
|
|
@@ -1398,12 +1381,16 @@ class Frame(mwx.Frame):
|
|
|
1398
1381
|
|
|
1399
1382
|
def load_index(self, filename=None, view=None):
|
|
1400
1383
|
"""Load frames :ref to the Index file.
|
|
1384
|
+
|
|
1385
|
+
If no view given, the currently selected view is chosen.
|
|
1401
1386
|
"""
|
|
1402
1387
|
if not view:
|
|
1403
1388
|
view = self.selected_view
|
|
1404
1389
|
|
|
1405
1390
|
if not filename:
|
|
1391
|
+
fn = view.frame.pathname if view.frame else ''
|
|
1406
1392
|
with wx.FileDialog(self, "Select index file to import",
|
|
1393
|
+
defaultDir=os.path.dirname(fn or ''),
|
|
1407
1394
|
defaultFile=self.ATTRIBUTESFILE,
|
|
1408
1395
|
wildcard="Index (*.index)|*.index|"
|
|
1409
1396
|
"ALL files (*.*)|*.*",
|
|
@@ -1431,15 +1418,16 @@ class Frame(mwx.Frame):
|
|
|
1431
1418
|
def save_index(self, filename=None, frames=None):
|
|
1432
1419
|
"""Save frames :ref to the Index file.
|
|
1433
1420
|
"""
|
|
1421
|
+
view = self.selected_view
|
|
1434
1422
|
if not frames:
|
|
1435
|
-
frames =
|
|
1423
|
+
frames = view.all_frames
|
|
1436
1424
|
if not frames:
|
|
1437
1425
|
return None
|
|
1438
1426
|
|
|
1439
1427
|
if not filename:
|
|
1440
|
-
fn =
|
|
1428
|
+
fn = view.frame.pathname if view.frame else ''
|
|
1441
1429
|
with wx.FileDialog(self, "Select index file to export",
|
|
1442
|
-
defaultDir=os.path.dirname(fn),
|
|
1430
|
+
defaultDir=os.path.dirname(fn or ''),
|
|
1443
1431
|
defaultFile=self.ATTRIBUTESFILE,
|
|
1444
1432
|
wildcard="Index (*.index)|*.index",
|
|
1445
1433
|
style=wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) as dlg:
|
|
@@ -1463,8 +1451,8 @@ class Frame(mwx.Frame):
|
|
|
1463
1451
|
frame.name = os.path.basename(fn) # new name and pathname
|
|
1464
1452
|
output_frames.append(frame)
|
|
1465
1453
|
print(' ', self.message("\b done."))
|
|
1466
|
-
except (PermissionError, OSError):
|
|
1467
|
-
print('-', self.message("\b failed."))
|
|
1454
|
+
except (PermissionError, OSError) as e:
|
|
1455
|
+
print('-', self.message("\b failed.", e))
|
|
1468
1456
|
|
|
1469
1457
|
frames = output_frames
|
|
1470
1458
|
res, mis = self.write_attributes(filename, frames)
|
|
@@ -1504,7 +1492,7 @@ class Frame(mwx.Frame):
|
|
|
1504
1492
|
except FileNotFoundError:
|
|
1505
1493
|
pass
|
|
1506
1494
|
except Exception as e:
|
|
1507
|
-
print("- Failed to read attributes
|
|
1495
|
+
print("- Failed to read attributes.", e)
|
|
1508
1496
|
wx.MessageBox(str(e), style=wx.ICON_ERROR)
|
|
1509
1497
|
finally:
|
|
1510
1498
|
return res, mis # finally raises no exception
|
|
@@ -1526,7 +1514,7 @@ class Frame(mwx.Frame):
|
|
|
1526
1514
|
print(pformat(tuple(new.items())), file=o)
|
|
1527
1515
|
|
|
1528
1516
|
except Exception as e:
|
|
1529
|
-
print("- Failed to write attributes
|
|
1517
|
+
print("- Failed to write attributes.", e)
|
|
1530
1518
|
wx.MessageBox(str(e), style=wx.ICON_ERROR)
|
|
1531
1519
|
finally:
|
|
1532
1520
|
return new, mis # finally raises no exception
|
|
@@ -1607,7 +1595,10 @@ class Frame(mwx.Frame):
|
|
|
1607
1595
|
paths = [paths]
|
|
1608
1596
|
|
|
1609
1597
|
if paths is None:
|
|
1598
|
+
fn = view.frame.pathname if view.frame else ''
|
|
1610
1599
|
with wx.FileDialog(self, "Open image files",
|
|
1600
|
+
defaultDir=os.path.dirname(fn or ''),
|
|
1601
|
+
defaultFile='',
|
|
1611
1602
|
wildcard='|'.join(self.wildcards),
|
|
1612
1603
|
style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST
|
|
1613
1604
|
|wx.FD_MULTIPLE) as dlg:
|
|
@@ -1653,16 +1644,17 @@ class Frame(mwx.Frame):
|
|
|
1653
1644
|
|
|
1654
1645
|
def save_buffer(self, path=None, frame=None):
|
|
1655
1646
|
"""Save buffer of the frame to a file.
|
|
1656
|
-
|
|
1657
|
-
If no view given, the currently selected view is chosen.
|
|
1658
1647
|
"""
|
|
1648
|
+
view = self.selected_view
|
|
1659
1649
|
if not frame:
|
|
1660
|
-
frame =
|
|
1650
|
+
frame = view.frame
|
|
1661
1651
|
if not frame:
|
|
1662
1652
|
return None
|
|
1663
1653
|
|
|
1664
1654
|
if not path:
|
|
1655
|
+
fn = view.frame.pathname if view.frame else ''
|
|
1665
1656
|
with wx.FileDialog(self, "Save buffer as",
|
|
1657
|
+
defaultDir=os.path.dirname(fn or ''),
|
|
1666
1658
|
defaultFile=re.sub(r'[\/:*?"<>|]', '_', frame.name),
|
|
1667
1659
|
wildcard='|'.join(self.wildcards),
|
|
1668
1660
|
style=wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT) as dlg:
|
mwx/matplot2g.py
CHANGED
|
@@ -110,7 +110,7 @@ def _Property(name):
|
|
|
110
110
|
lambda self: delattr(self.parent, name))
|
|
111
111
|
|
|
112
112
|
|
|
113
|
-
class AxesImagePhantom
|
|
113
|
+
class AxesImagePhantom:
|
|
114
114
|
"""Phantom of frame facade
|
|
115
115
|
|
|
116
116
|
Args:
|
|
@@ -957,7 +957,7 @@ class GraphPlot(MatplotPanel):
|
|
|
957
957
|
self.message("Write buffer to clipboard.")
|
|
958
958
|
except Exception as e:
|
|
959
959
|
traceback.print_exc()
|
|
960
|
-
self.message("- Failed to write to clipboard
|
|
960
|
+
self.message("- Failed to write to clipboard.", e)
|
|
961
961
|
|
|
962
962
|
def read_buffer_from_clipboard(self):
|
|
963
963
|
"""Read buffer data from clipboard."""
|
|
@@ -974,7 +974,7 @@ class GraphPlot(MatplotPanel):
|
|
|
974
974
|
self.load(Clipboard.imread())
|
|
975
975
|
except Exception as e:
|
|
976
976
|
traceback.print_exc()
|
|
977
|
-
self.message("- No data in clipboard
|
|
977
|
+
self.message("- No data in clipboard.", e)
|
|
978
978
|
|
|
979
979
|
def destroy_colorbar(self):
|
|
980
980
|
if self.cbar:
|