mwxlib 0.84.2__py3-none-any.whl → 0.84.4__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/framework.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Author: Kazuya O'moto <komoto@jeol.co.jp>
6
6
  """
7
- __version__ = "0.84.2"
7
+ __version__ = "0.84.4"
8
8
  __author__ = "Kazuya O'moto <komoto@jeol.co.jp>"
9
9
 
10
10
  from functools import wraps, partial
@@ -1200,7 +1200,8 @@ class ShellFrame(MiniFrame):
1200
1200
  with open(self.SESSION_FILE, encoding='utf-8', newline='') as i:
1201
1201
  exec(i.read())
1202
1202
  except Exception:
1203
- pass
1203
+ ## pass
1204
+ traceback.print_exc()
1204
1205
 
1205
1206
  def save_session_as(self):
1206
1207
  """Save session as a new file."""
@@ -1224,7 +1225,7 @@ class ShellFrame(MiniFrame):
1224
1225
  for book in self.all_books:
1225
1226
  for buf in book.all_buffers:
1226
1227
  if buf.mtdelta is not None:
1227
- o.write("self.load({!r}, {!r}, {!r})\n"
1228
+ o.write("self._load({!r}, {!r}, {!r})\n"
1228
1229
  .format(buf.filename, buf.markline+1, book.Name))
1229
1230
  o.write('\n'.join((
1230
1231
  "self.SetSize({})".format(self.Size),
@@ -1436,6 +1437,14 @@ class ShellFrame(MiniFrame):
1436
1437
  self.indicator.Value = 1
1437
1438
  self.message("Quit")
1438
1439
 
1440
+ def _load(self, filename, lineno, bookname):
1441
+ """Load file in the session (internal use only)."""
1442
+ try:
1443
+ book = getattr(self, bookname)
1444
+ return self.load(filename, lineno, book, show=0)
1445
+ except Exception:
1446
+ pass
1447
+
1439
1448
  def load(self, filename, lineno=0, book=None, show=True, focus=False):
1440
1449
  """Load file @where the object is defined.
1441
1450
 
@@ -1456,11 +1465,6 @@ class ShellFrame(MiniFrame):
1456
1465
  if m:
1457
1466
  filename, ln = m.groups()
1458
1467
  lineno = int(ln)
1459
- if isinstance(book, str):
1460
- try:
1461
- book = getattr(self, book)
1462
- except Exception:
1463
- pass
1464
1468
  if not book:
1465
1469
  book = next((x for x in self.all_books
1466
1470
  if x.find_buffer(filename)), self.Log)
@@ -1830,9 +1834,7 @@ try:
1830
1834
  del core
1831
1835
 
1832
1836
  except ImportError as e:
1833
- print("- {!r}".format(e))
1834
- print("Python {}".format(sys.version))
1835
- print("wxPython {}".format(wx.version()))
1837
+ print(e)
1836
1838
  pass
1837
1839
 
1838
1840
  ## class wxpyInspectionTools:
mwx/graphman.py CHANGED
@@ -23,7 +23,7 @@ from wx import aui
23
23
  from . import framework as mwx
24
24
  from .utilus import funcall as _F
25
25
  from .controls import ControlPanel, Icon
26
- from .framework import CtrlInterface
26
+ from .framework import CtrlInterface, AuiNotebook
27
27
  from .matplot2g import GraphPlot
28
28
  from .matplot2lg import Histogram
29
29
 
@@ -222,6 +222,9 @@ class LayerInterface(CtrlInterface):
222
222
  ## funcall = interactive_call
223
223
  funcall = staticmethod(_F)
224
224
 
225
+ ## for debug
226
+ pane = property(lambda self: self.parent.get_pane(self))
227
+
225
228
  @property
226
229
  def Arts(self):
227
230
  """List of arts <matplotlib.artist.Artist>."""
@@ -291,9 +294,9 @@ class LayerInterface(CtrlInterface):
291
294
  'thread_end' : [ None ], # end processing
292
295
  'thread_quit' : [ None ], # terminated by user
293
296
  'thread_error' : [ None ], # failed in error
294
- 'page_shown' : [ None, _F(self.Draw, True) ], # when active
295
- 'page_closed' : [ None, _F(self.Draw, False) ], # when inactive
296
- 'page_hidden' : [ None, _F(self.Draw, False) ], # when hidden (not closed)
297
+ 'page_shown' : [ None, _F(self.Draw, True) ],
298
+ 'page_closed' : [ None, _F(self.Draw, False) ],
299
+ 'page_hidden' : [ None, _F(self.Draw, False) ],
297
300
  },
298
301
  0 : {
299
302
  'C-c pressed' : (0, _F(copy_params)),
@@ -346,6 +349,14 @@ class LayerInterface(CtrlInterface):
346
349
  v.Skip()
347
350
  self.Bind(wx.EVT_WINDOW_DESTROY, destroy)
348
351
 
352
+ def on_show(v):
353
+ if v.IsShown():
354
+ self.handler('page_shown', self)
355
+ else:
356
+ self.handler('page_hidden', self)
357
+ v.Skip()
358
+ self.Bind(wx.EVT_SHOW, on_show)
359
+
349
360
  try:
350
361
  self.Init()
351
362
  if session:
@@ -439,6 +450,9 @@ class Graph(GraphPlot):
439
450
  self.handler.append({ # DNA<Graph>
440
451
  None : {
441
452
  'focus_set' : [ None, _F(self.loader.select_view, view=self) ],
453
+ 'page_shown' : [ None, ],
454
+ 'page_closed' : [ None, ],
455
+ 'page_hidden' : [ None, ],
442
456
  'frame_shown' : [ None, _F(self.update_infobar) ],
443
457
  'S-a pressed' : [ None, _F(self.toggle_infobar) ],
444
458
  'f5 pressed' : [ None, _F(self.refresh) ],
@@ -446,6 +460,14 @@ class Graph(GraphPlot):
446
460
  })
447
461
  ## ドロップターゲットを許可する
448
462
  self.SetDropTarget(MyFileDropLoader(self, self.loader))
463
+
464
+ def on_show(v):
465
+ if v.IsShown():
466
+ self.handler('page_shown', self)
467
+ else:
468
+ self.handler('page_hidden', self)
469
+ v.Skip()
470
+ self.Bind(wx.EVT_SHOW, on_show)
449
471
 
450
472
  def refresh(self):
451
473
  if self.frame:
@@ -527,55 +549,6 @@ class MyFileDropLoader(wx.FileDropTarget):
527
549
  return True
528
550
 
529
551
 
530
- class AuiNotebook(aui.AuiNotebook):
531
- def __init__(self, *args, **kwargs):
532
- kwargs.setdefault('style',
533
- (aui.AUI_NB_DEFAULT_STYLE | aui.AUI_NB_BOTTOM)
534
- ^ aui.AUI_NB_CLOSE_ON_ACTIVE_TAB
535
- ^ aui.AUI_NB_MIDDLE_CLICK_CLOSE
536
- )
537
- aui.AuiNotebook.__init__(self, *args, **kwargs)
538
-
539
- self.Bind(aui.EVT_AUINOTEBOOK_TAB_RIGHT_DOWN, self.on_show_menu)
540
-
541
- self.Bind(aui.EVT_AUINOTEBOOK_PAGE_CHANGED, self.on_page_changed)
542
- self.Bind(aui.EVT_AUINOTEBOOK_PAGE_CHANGING, self.on_page_changing)
543
-
544
- def on_show_menu(self, evt): #<wx._aui.AuiNotebookEvent>
545
- obj = evt.EventObject
546
- try:
547
- win = obj.Pages[evt.Selection].window # GetPage for split notebook
548
- mwx.Menu.Popup(self, win.menu)
549
- except AttributeError:
550
- pass
551
-
552
- def on_page_changed(self, evt): #<wx._aui.AuiNotebookEvent>
553
- win = self.CurrentPage
554
- win.handler('page_shown', win)
555
- evt.Skip()
556
-
557
- def on_page_changing(self, evt): #<wx._aui.AuiNotebookEvent>
558
- org = self.CurrentPage
559
- obj = evt.EventObject
560
- if obj is not self:
561
- ## if wx.VERSION >= (4,1,0):
562
- try:
563
- win = obj.Pages[evt.Selection].window # Changing org --> win <Layer>
564
- atc = self.ActiveTabCtrl # Changing atc --> obj <aui.AuiTabCtrl>
565
- if obj is not atc:
566
- for page in obj.Pages: # Check if there is a page to be hidden.
567
- org = page.window
568
- if org.IsShownOnScreen() and org is not win:
569
- break
570
- else:
571
- evt.Skip() # No windows to be hidden.
572
- return
573
- org.handler('page_hidden', org)
574
- except AttributeError:
575
- pass
576
- evt.Skip()
577
-
578
-
579
552
  class Frame(mwx.Frame):
580
553
  """Graph and Plug manager frame
581
554
 
@@ -629,6 +602,7 @@ class Frame(mwx.Frame):
629
602
  ]
630
603
  self.select_view(self.graph)
631
604
 
605
+ ## Set winow.Name for inspection.
632
606
  self.graph.Name = "graph"
633
607
  self.output.Name = "output"
634
608
  self.histogram.Name = "histogram"
@@ -763,11 +737,14 @@ class Frame(mwx.Frame):
763
737
  ]
764
738
  self.menubar.reset()
765
739
 
740
+ def show_graph(frame):
741
+ wx.CallAfter(self.show_pane, frame.parent) # Show graph / output
742
+
766
743
  self.graph.handler.append({ # DNA<Graph:Frame>
767
744
  None : {
768
745
  'frame_shown' : [ None, self.set_title ],
769
- 'frame_loaded' : [ None, lambda v: self.show_pane("graph") ],
770
- 'frame_modified' : [ None, lambda v: self.show_pane("graph") ],
746
+ 'frame_loaded' : [ None, show_graph ],
747
+ 'frame_modified' : [ None, show_graph ],
771
748
  'frame_selected' : [ None, self.set_title ],
772
749
  'canvas_draw' : [ None, lambda v: self.sync(self.graph, self.output) ],
773
750
  },
@@ -775,8 +752,8 @@ class Frame(mwx.Frame):
775
752
  self.output.handler.append({ # DNA<Graph:Frame>
776
753
  None : {
777
754
  'frame_shown' : [ None, self.set_title ],
778
- 'frame_loaded' : [ None, lambda v: self.show_pane("output") ],
779
- 'frame_modified' : [ None, lambda v: self.show_pane("output") ],
755
+ 'frame_loaded' : [ None, show_graph ],
756
+ 'frame_modified' : [ None, show_graph ],
780
757
  'frame_selected' : [ None, self.set_title ],
781
758
  'canvas_draw' : [ None, lambda v: self.sync(self.output, self.graph) ],
782
759
  },
@@ -859,7 +836,11 @@ class Frame(mwx.Frame):
859
836
  ## --------------------------------
860
837
 
861
838
  def get_pane(self, name):
862
- """Get named pane or notebook pane."""
839
+ """Get the named pane or notebook pane.
840
+
841
+ Args:
842
+ name : str or plug object.
843
+ """
863
844
  if name in self.plugins:
864
845
  plug = self.plugins[name].__plug__
865
846
  name = plug.category or name
@@ -907,12 +888,14 @@ class Frame(mwx.Frame):
907
888
  nb = plug.__notebook # given when load_plug
908
889
  if nb and show:
909
890
  nb.SetSelection(nb.GetPageIndex(plug))
910
- if show:
911
- if not pane.IsShown():
912
- plug.handler('page_shown', plug)
913
- else:
914
- if pane.IsShown():
915
- plug.handler('page_closed', plug)
891
+ else:
892
+ plug = pane.window
893
+ if show:
894
+ if not pane.IsShown():
895
+ plug.handler('page_shown', plug)
896
+ else:
897
+ if pane.IsShown():
898
+ plug.handler('page_closed', plug)
916
899
 
917
900
  ## Modify the floating position of the pane when displayed.
918
901
  ## Note: This is a known bug in wxWidgets 3.17 -- 3.20,
@@ -960,12 +943,13 @@ class Frame(mwx.Frame):
960
943
  pane = evt.GetPane()
961
944
  win = pane.window
962
945
  if isinstance(win, aui.AuiNotebook):
963
- for j in range(win.PageCount):
964
- plug = win.GetPage(j)
946
+ for plug in win.all_pages:
965
947
  plug.handler('page_closed', plug)
966
948
  else:
967
949
  win.handler('page_closed', win)
968
- ## evt.Skip() # cause the same event call twice?
950
+ pane.Show(0)
951
+ self._mgr.Update()
952
+ evt.Veto() # Don't skip. Just hide it.
969
953
 
970
954
  ## --------------------------------
971
955
  ## Plugin (Layer) interface
@@ -987,7 +971,11 @@ class Frame(mwx.Frame):
987
971
  return plug
988
972
 
989
973
  def get_plug(self, name):
990
- """Find named plug window in registered plugins."""
974
+ """Find the named plug window in registered plugins.
975
+
976
+ Args:
977
+ name : str or plug object.
978
+ """
991
979
  if isinstance(name, str):
992
980
  if name.endswith(".py") or name.endswith(".pyc"):
993
981
  name,_ = os.path.splitext(os.path.basename(name))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mwxlib
3
- Version: 0.84.2
3
+ Version: 0.84.4
4
4
  Summary: A wrapper of matplotlib and wxPython (phoenix)
5
5
  Home-page: https://github.com/komoto48g/mwxlib
6
6
  Author: Kazuya O'moto <komoto@jeol.co.jp>
@@ -1,7 +1,7 @@
1
1
  mwx/__init__.py,sha256=bSRdncjfSCKycMFQVnagOi9R2vUCC5snGkjea7jqPgU,2520
2
2
  mwx/controls.py,sha256=pD1IjgkwdvD-ebntnAH-6Jo7KY5hDq30Ne6rTE_i9fE,43499
3
- mwx/framework.py,sha256=jEbi33rN4VmtGvTqeXBGT6avlh3foAJf3lDl_2I0Jog,73753
4
- mwx/graphman.py,sha256=dJoVzwRdcXRTh-oORs0db3icxcrTgQ8zCkTGAk9PxJw,69662
3
+ mwx/framework.py,sha256=Xm27Si5D5a-4h8nDby3fbtZt8IJNYUF6BcX3webPX-A,73816
4
+ mwx/graphman.py,sha256=tjWMoLunwxbj53f-AppCRlisa89mFIIHozXjAysCQpA,68639
5
5
  mwx/images.py,sha256=9e8X7OpJ6Z3fF3ez17P_qk2D1NMO10-lN8TCtulAqT0,46248
6
6
  mwx/matplot2.py,sha256=W_FpY0S33crCAh7N9YTXo-jgYzj8uL9gqXkekfQo7Pk,36017
7
7
  mwx/matplot2g.py,sha256=cBuLMnQt3XSKQL9io0XJb_v8Lv0pO9hm0IMjVIERtu4,68253
@@ -15,8 +15,8 @@ mwx/wxwil.py,sha256=DPXXx4OdEzvHr-_jxz9J29Ozufmb6Vr7rXVkG_LKQd0,5254
15
15
  mwx/wxwit.py,sha256=UG361QTUheO_hlSIRgkprrGUYh0IzHB8ZqOoJeeMzUs,7424
16
16
  mwx/py/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  mwx/py/filling.py,sha256=f6KMBcBv7gwrl6qmJYLTL-O0Z47bWNAdTCZtUZIo8vM,16794
18
- mwxlib-0.84.2.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
19
- mwxlib-0.84.2.dist-info/METADATA,sha256=N3-3F8X4LSbgWKM7bLD2fBwbh0BJk5k-mDalmt9rKZw,1893
20
- mwxlib-0.84.2.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
21
- mwxlib-0.84.2.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
22
- mwxlib-0.84.2.dist-info/RECORD,,
18
+ mwxlib-0.84.4.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
19
+ mwxlib-0.84.4.dist-info/METADATA,sha256=wRo5HYos8tkqBTv0xfvqH1GqN-fjMkVJK3h_Wpig8vk,1893
20
+ mwxlib-0.84.4.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
21
+ mwxlib-0.84.4.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
22
+ mwxlib-0.84.4.dist-info/RECORD,,