mwxlib 0.94.5__py3-none-any.whl → 0.94.7__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 CHANGED
@@ -741,7 +741,7 @@ class ControlPanel(scrolled.ScrolledPanel):
741
741
  except AttributeError:
742
742
  p.value = v
743
743
  except Exception as e: # failed to eval
744
- print("- Failed to reset {!r}: {}".format(p, e))
744
+ print(f"- Failed to reset {p!r}:", e)
745
745
  pass
746
746
 
747
747
  reset_params = set_params #: for backward compatibility
mwx/framework.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #! python3
2
2
  """mwxlib framework.
3
3
  """
4
- __version__ = "0.94.5"
4
+ __version__ = "0.94.7"
5
5
  __author__ = "Kazuya O'moto <komoto@jeol.co.jp>"
6
6
 
7
7
  from functools import wraps, partial
@@ -294,12 +294,14 @@ class KeyCtrlInterfaceMixin:
294
294
  key += ' pressed'
295
295
 
296
296
  if map not in self.handler:
297
- warnings.warn(f"New map to define_key {keymap!r} in {self}.", stacklevel=2)
297
+ warnings.warn(f"New map to define_key {keymap!r} in {self}.",
298
+ stacklevel=2)
298
299
  self.make_keymap(map) # make new keymap
299
300
 
300
301
  transaction = self.handler[map].get(key, [state])
301
302
  if len(transaction) > 1:
302
- warnings.warn(f"Duplicate define_key {keymap!r} in {self}.", stacklevel=2)
303
+ warnings.warn(f"Duplicate define_key {keymap!r} in {self}.",
304
+ stacklevel=2)
303
305
 
304
306
  if action is None:
305
307
  self.handler[map].pop(key, None) # cf. undefine_key
@@ -325,7 +327,8 @@ class CtrlInterface(KeyCtrlInterfaceMixin):
325
327
 
326
328
  def __init__(self):
327
329
  if hasattr(self, 'handler'):
328
- warnings.warn(f"Duplicate iniheritance of CtrlInterface by {self}.", stacklevel=2)
330
+ warnings.warn(f"Duplicate iniheritance of CtrlInterface by {self}.",
331
+ stacklevel=2)
329
332
  return
330
333
  self.__key = ''
331
334
  self.__button = ''
@@ -630,7 +633,8 @@ class MenuBar(wx.MenuBar, TreeList):
630
633
  Call when the menulist is changed.
631
634
  """
632
635
  if not self.Parent:
633
- warnings.warn(f"No parents bound to {self}.", stacklevel=2)
636
+ warnings.warn(f"No parents bound to {self}.",
637
+ stacklevel=2)
634
638
  return
635
639
 
636
640
  menu = self.getmenu(key)
@@ -657,7 +661,8 @@ class MenuBar(wx.MenuBar, TreeList):
657
661
  Call when the menulist is changed.
658
662
  """
659
663
  if not self.Parent:
660
- warnings.warn(f"No parents bound to {self}.", stacklevel=2)
664
+ warnings.warn(f"No parents bound to {self}.",
665
+ stacklevel=2)
661
666
  return
662
667
 
663
668
  for j in range(self.GetMenuCount()): # remove and del all top-level menu
@@ -1173,15 +1178,18 @@ class ShellFrame(MiniFrame):
1173
1178
  self._mgr.SetDockSizeConstraint(0.5, 0.5) # (w, h)/N
1174
1179
 
1175
1180
  self._mgr.AddPane(self.console,
1176
- aui.AuiPaneInfo().Name("console").CenterPane().Show(1))
1181
+ aui.AuiPaneInfo().Name("console").CenterPane()
1182
+ .MaximizeButton().Show(1))
1177
1183
 
1178
1184
  self._mgr.AddPane(self.ghost,
1179
1185
  aui.AuiPaneInfo().Name("ghost")
1180
- .Caption("Ghost in the Shell").Right().Show(0))
1186
+ .Caption("Ghost in the Shell").Right()
1187
+ .MaximizeButton().Show(0))
1181
1188
 
1182
1189
  self._mgr.AddPane(self.watcher,
1183
1190
  aui.AuiPaneInfo().Name("watcher")
1184
- .Caption("Watchdog in the Shell").Right().Position(1).Show(0))
1191
+ .Caption("Watchdog in the Shell").Right().Position(1)
1192
+ .MaximizeButton().Show(0))
1185
1193
 
1186
1194
  self._mgr.Update()
1187
1195
 
@@ -1261,35 +1269,30 @@ class ShellFrame(MiniFrame):
1261
1269
  },
1262
1270
  })
1263
1271
 
1264
- ## py-mode
1265
1272
  self.Scratch.set_attributes(Style=Nautilus.STYLE)
1273
+ self.Log.set_attributes(ReadOnly=True)
1274
+ self.Help.set_attributes(ReadOnly=True)
1266
1275
 
1267
1276
  self.set_hookable(self.Scratch)
1277
+ self.set_hookable(self.Log)
1268
1278
 
1269
1279
  @self.Scratch.define_key('C-j')
1270
- @postcall
1271
1280
  def eval_line():
1272
1281
  shell = self.current_shell
1273
1282
  self.Scratch.buffer.py_eval_line(shell.globals, shell.locals)
1274
1283
 
1275
1284
  @self.Scratch.define_key('C-S-j')
1276
- @postcall
1277
1285
  def eval_buffer():
1278
1286
  shell = self.current_shell
1279
1287
  self.Scratch.buffer.py_exec_region(shell.globals, shell.locals)
1280
1288
 
1281
- ## text-mode
1282
- self.set_hookable(self.Log)
1283
-
1284
- self.Log.set_attributes(ReadOnly=True)
1285
- self.Help.set_attributes(ReadOnly=True)
1289
+ ## Session
1290
+ self.SESSION_FILE = get_rootpath(".debrc")
1291
+ self.SCRATCH_FILE = get_rootpath("scratch.py")
1292
+ self.LOGGING_FILE = get_rootpath("deb-logging.log")
1286
1293
 
1287
1294
  self.load_session(
1288
1295
  os.path.abspath(debrc) if debrc else self.SESSION_FILE)
1289
-
1290
- SESSION_FILE = get_rootpath(".debrc")
1291
- SCRATCH_FILE = get_rootpath("scratch.py")
1292
- LOGGING_FILE = get_rootpath("deb-logging.log")
1293
1296
 
1294
1297
  def load_session(self, filename):
1295
1298
  """Load session from file."""
@@ -1301,14 +1304,11 @@ class ShellFrame(MiniFrame):
1301
1304
  except Exception:
1302
1305
  pass
1303
1306
 
1304
- for book in self.all_editors:
1305
- book.delete_all_buffers() # Note: *log* is also flushed.
1307
+ _fload(self.Scratch, self.SCRATCH_FILE) # restore scratch
1306
1308
 
1307
1309
  ## Re-open the *log* file.
1308
1310
  self.add_log("#! Opened: <{}>\r\n".format(datetime.datetime.now()))
1309
1311
 
1310
- _fload(self.Scratch, self.SCRATCH_FILE) # restore scratch
1311
-
1312
1312
  fn = os.path.abspath(filename)
1313
1313
  try:
1314
1314
  with open(fn, encoding='utf-8', newline='') as i:
@@ -1544,17 +1544,12 @@ class ShellFrame(MiniFrame):
1544
1544
  ))
1545
1545
  )
1546
1546
 
1547
- def toggle_window(self, win, focus=False):
1548
- self.popup_window(win, show=None, focus=focus)
1547
+ def toggle_window(self, win):
1548
+ pane = self._mgr.GetPane(win)
1549
+ self.popup_window(win, not pane.IsShown())
1549
1550
 
1550
- def popup_window(self, win, show=True, focus=True):
1551
- """Show the notebook page and move the focus.
1552
-
1553
- Args:
1554
- win : window to popup
1555
- show : True, False, otherwise None:toggle
1556
- The pane window will be hidden if no show.
1557
- """
1551
+ def popup_window(self, win, show=True):
1552
+ """Show the notebook page and keep the focus."""
1558
1553
  wnd = wx.Window.FindFocus() # original focus
1559
1554
 
1560
1555
  for pane in self._mgr.GetAllPanes():
@@ -1569,12 +1564,7 @@ class ShellFrame(MiniFrame):
1569
1564
  else:
1570
1565
  return # no such pane.window
1571
1566
 
1572
- if show is None:
1573
- show = not pane.IsShown() # toggle show
1574
-
1575
- if focus and win.IsShown():
1576
- win.SetFocus() # move focus
1577
- elif wnd:
1567
+ if wnd:
1578
1568
  wnd.SetFocus() # restore focus
1579
1569
 
1580
1570
  ## Modify the floating position of the pane when displayed.
@@ -1605,14 +1595,14 @@ class ShellFrame(MiniFrame):
1605
1595
  self.indicator.Value = 1
1606
1596
  self.message("Quit")
1607
1597
 
1608
- def _load(self, filename, lineno, editor, verbose=False):
1598
+ def _load(self, filename, lineno, editor):
1609
1599
  """Load file in the session (internal use only)."""
1610
1600
  if isinstance(editor, str):
1611
1601
  editor = getattr(self, editor, None)
1612
1602
  if editor:
1613
- return editor.load_file(filename, lineno, verbose)
1603
+ return editor.load_file(filename, lineno, verbose=0)
1614
1604
 
1615
- def load(self, filename, lineno=0, show=True, focus=False):
1605
+ def load(self, filename, lineno=0, show=True):
1616
1606
  """Load file @where the object is defined.
1617
1607
 
1618
1608
  Args:
@@ -1620,7 +1610,6 @@ class ShellFrame(MiniFrame):
1620
1610
  It also supports <'filename:lineno'> format.
1621
1611
  lineno : Set mark to lineno on load.
1622
1612
  show : Show the page.
1623
- focus : Focus the window if visible.
1624
1613
  """
1625
1614
  if not isinstance(filename, str):
1626
1615
  filename = where(filename)
@@ -1634,7 +1623,7 @@ class ShellFrame(MiniFrame):
1634
1623
  editor = self.find_editor(filename) or self.Log
1635
1624
  ret = editor.load_file(filename, lineno, verbose=1)
1636
1625
  if ret:
1637
- self.popup_window(editor, show, focus)
1626
+ self.popup_window(editor, show)
1638
1627
  return ret
1639
1628
 
1640
1629
  def info(self, obj):
@@ -1646,11 +1635,11 @@ class ShellFrame(MiniFrame):
1646
1635
  def watch(self, obj):
1647
1636
  if isinstance(obj, wx.Object):
1648
1637
  self.monitor.watch(obj)
1649
- self.popup_window(self.monitor, focus=0)
1638
+ self.popup_window(self.monitor)
1650
1639
  elif hasattr(obj, '__dict__'):
1651
1640
  self.linfo.watch(obj.__dict__)
1652
1641
  self.ginfo.watch({})
1653
- self.popup_window(self.linfo, focus=0)
1642
+ self.popup_window(self.linfo)
1654
1643
 
1655
1644
  def highlight(self, obj, *args, **kwargs):
1656
1645
  self.inspector.highlight(obj, *args, **kwargs)
@@ -1732,8 +1721,8 @@ class ShellFrame(MiniFrame):
1732
1721
  shell.prompt()
1733
1722
  shell.SetFocus()
1734
1723
  self.Show()
1735
- self.popup_window(self.ghost, focus=0)
1736
- self.popup_window(self.linfo, focus=0)
1724
+ self.popup_window(self.ghost)
1725
+ self.popup_window(self.linfo)
1737
1726
  self.add_log("<-- Beginning of debugger\r\n")
1738
1727
  self.indicator.Value = 2
1739
1728
 
@@ -1749,7 +1738,7 @@ class ShellFrame(MiniFrame):
1749
1738
  if self.linfo.target is not ls:
1750
1739
  self.linfo.watch(ls)
1751
1740
  self.on_title_window(frame)
1752
- self.popup_window(self.debugger.editor, focus=0)
1741
+ self.popup_window(self.debugger.editor)
1753
1742
  dispatcher.send(signal='Interpreter.push',
1754
1743
  sender=shell, command=None, more=False)
1755
1744
  command = shell.cmdline
@@ -1855,7 +1844,7 @@ class ShellFrame(MiniFrame):
1855
1844
  with buf.off_readonly():
1856
1845
  buf.SetText(text)
1857
1846
  ## Overwrite text and popup the window.
1858
- self.popup_window(self.Help, focus=0)
1847
+ self.popup_window(self.Help)
1859
1848
 
1860
1849
  def clone_shell(self, target):
1861
1850
  if not hasattr(target, '__dict__'):
@@ -1865,8 +1854,8 @@ class ShellFrame(MiniFrame):
1865
1854
  style=wx.CLIP_CHILDREN|wx.BORDER_NONE)
1866
1855
  self.handler('shell_new', shell)
1867
1856
  self.console.AddPage(shell, typename(shell.target))
1868
- self.Show()
1869
- self.popup_window(shell, focus=1)
1857
+ self.popup_window(shell)
1858
+ shell.SetFocus()
1870
1859
  return shell
1871
1860
 
1872
1861
  def delete_shell(self, shell):
mwx/graphman.py CHANGED
@@ -473,7 +473,7 @@ class LayerInterface(CtrlInterface):
473
473
  if canvas:
474
474
  canvas.draw_idle()
475
475
  except Exception as e:
476
- print("- Failed to draw Arts of {}: {}".format(self.__module__, e))
476
+ print(f"- Failed to draw Arts of {self.__module__}:", e)
477
477
  del self.Arts
478
478
 
479
479
 
@@ -1055,7 +1055,8 @@ class Frame(mwx.Frame):
1055
1055
 
1056
1056
  if issubclass(cls, LayerInterface):
1057
1057
  cls.__module__ = module.__name__ # __main__ to module
1058
- warnings.warn(f"Duplicate iniheritance of LayerInterface by {cls}.", stacklevel=2)
1058
+ warnings.warn(f"Duplicate iniheritance of LayerInterface by {cls}.",
1059
+ stacklevel=2)
1059
1060
  module.Plugin = cls
1060
1061
  return cls
1061
1062
 
@@ -1099,13 +1100,14 @@ class Frame(mwx.Frame):
1099
1100
  else:
1100
1101
  module = import_module(name)
1101
1102
  except Exception as e:
1102
- print("- Unable to load {!r}: {}".format(root, e))
1103
+ print(f"- Unable to load {root!r}:", e)
1103
1104
  return False
1104
1105
 
1105
1106
  ## the module must have a class `Plugin`.
1106
1107
  if not hasattr(module, 'Plugin'):
1107
1108
  if isinstance(root, type):
1108
- warnings.warn(f"Use dummy plug for debugging {name!r}.", stacklevel=3)
1109
+ warnings.warn(f"Use dummy plug for debugging {name!r}.",
1110
+ stacklevel=3)
1109
1111
  module.__dummy_plug__ = root
1110
1112
  self.register(root, module)
1111
1113
  else:
mwx/nutshell.py CHANGED
@@ -1590,15 +1590,15 @@ class Buffer(EditWindow, EditorInterface):
1590
1590
  self.Text = text
1591
1591
  self.EmptyUndoBuffer()
1592
1592
  self.SetSavePoint()
1593
- self.filename = filename
1594
- self.handler('buffer_loaded', self)
1593
+ self.filename = filename
1594
+ self.handler('buffer_loaded', self)
1595
1595
 
1596
1596
  def _load_file(self, filename):
1597
1597
  """Wrapped method of LoadFile."""
1598
1598
  if self.LoadFile(filename):
1599
- self.filename = filename
1600
1599
  self.EmptyUndoBuffer()
1601
1600
  self.SetSavePoint()
1601
+ self.filename = filename
1602
1602
  self.handler('buffer_loaded', self)
1603
1603
  return True
1604
1604
  return False
@@ -1606,8 +1606,8 @@ class Buffer(EditWindow, EditorInterface):
1606
1606
  def _save_file(self, filename):
1607
1607
  """Wrapped method of SaveFile."""
1608
1608
  if self.SaveFile(filename):
1609
- self.filename = filename
1610
1609
  self.SetSavePoint()
1610
+ self.filename = filename
1611
1611
  self.handler('buffer_saved', self)
1612
1612
  return True
1613
1613
  return False
@@ -1995,7 +1995,7 @@ class EditorBook(AuiNotebook, CtrlInterface):
1995
1995
  return True
1996
1996
  return False
1997
1997
  except Exception as e:
1998
- self.post_message("Failed to load {!r}: {}".format(buf.name, e))
1998
+ self.post_message(f"Failed to load {filename!r}:", e)
1999
1999
  self.delete_buffer(buf)
2000
2000
  if org:
2001
2001
  self.swap_buffer(org)
@@ -2031,7 +2031,7 @@ class EditorBook(AuiNotebook, CtrlInterface):
2031
2031
  return True
2032
2032
  return False
2033
2033
  except Exception as e:
2034
- self.post_message("Failed to save {!r}: {}".format(buf.name, e))
2034
+ self.post_message(f"Failed to save {filename!r}:", e)
2035
2035
  return False
2036
2036
 
2037
2037
  def load_buffer(self, buf=None):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mwxlib
3
- Version: 0.94.5
3
+ Version: 0.94.7
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
@@ -1,14 +1,14 @@
1
1
  mwx/__init__.py,sha256=zLsXDgqyC5NsPCjRxjS2huvZ3uDyeOJ1vapotqe2ULM,834
2
2
  mwx/bookshelf.py,sha256=UVVIwHaGO4aEHwZ8x5SKjpL-3MmQ1s6kkyuyRZqKWvU,5070
3
- mwx/controls.py,sha256=1eguX5eofsA6hmS2y7R4hvlFjFikVoZ8v2S1ES7rjEU,47196
4
- mwx/framework.py,sha256=Hi16j2sajupXq2_m37VMfxumj6eXwfaGq8Le26IMfFc,75494
5
- mwx/graphman.py,sha256=kntmZcVxIubUtH7mLiDyDr2rXw_2iEvtV9DkFDYtt8s,69991
3
+ mwx/controls.py,sha256=prp1NhZqv1XANhi2PPxW9jtrgwj_02XMOOyyzZ48klM,47185
4
+ mwx/framework.py,sha256=9mvG3E0sx1gTuEcuz4RK4e3bhd4il_rduRrHkgJ9U4c,75109
5
+ mwx/graphman.py,sha256=9MG0BzQh5lDDadyPPXps2M0hf6mPN3G0MQbBGdplY_I,70027
6
6
  mwx/images.py,sha256=mrnUYH12I3XLVSZcEXlpVltX0XMxufbl2yRvDIQJZqc,49957
7
7
  mwx/matplot2.py,sha256=qaF_gvLoLn-TimLbRR59KUavNr1ZpZQdSMqjzJk47rk,32682
8
8
  mwx/matplot2g.py,sha256=mDaD367wjq6xsyIDX9ot8jLwYYGayoavWMhqsQVBHac,65442
9
9
  mwx/matplot2lg.py,sha256=tg8u7w4DxiJdPN-E197NOmbQpc_1gZkgDHYv_xUhbFA,27224
10
10
  mwx/mgplt.py,sha256=ITzxA97yDwr_35BUk5OqnyskSuKVDbpf2AQCKY1jHTI,5671
11
- mwx/nutshell.py,sha256=VcUDTzqdBdHztVGfkjqEL9DUO6cKaGYvYCAME0Jl0qk,135647
11
+ mwx/nutshell.py,sha256=c7VYeOmDSr1WcIzAjAIVmjTXBJqtxKzAz6EhZ9YmnAw,135633
12
12
  mwx/utilus.py,sha256=FTJhVFmx6TAE5rvZ_nfxZgyyaW4zMpXEz74v72X6m7Y,37399
13
13
  mwx/wxmon.py,sha256=Qk86VbuuW2rR46pqEYLur13G_aloWz5SVv6sib30YY0,12717
14
14
  mwx/wxpdb.py,sha256=2z3ZD9Oo1H-ONBHlaprkB9hrTmAI7o03sqO46ppEFE4,19129
@@ -21,8 +21,8 @@ mwx/plugins/frame_listview.py,sha256=T-2xSv_D2bk9fJ64aiSEe1rJRTeqaIpLVAYEUXW5vz8
21
21
  mwx/plugins/line_profile.py,sha256=WJB5z7F53yg4dII2R36IFZvtkSOGWT669b1HmAAXSnQ,816
22
22
  mwx/py/__init__.py,sha256=xykgfOytOwNuvXsfkLoumFZSTN-iBsHOjczYXngjmUE,12
23
23
  mwx/py/filling.py,sha256=KaHooM32hrGGgqw75Cbt8lAvACwC6RXadob9LGgNnEc,16806
24
- mwxlib-0.94.5.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
25
- mwxlib-0.94.5.dist-info/METADATA,sha256=tMDN9Giu-NWqUZx5Pzf0OzlAtx_P6HSMW8EVWd0scMw,1925
26
- mwxlib-0.94.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
27
- mwxlib-0.94.5.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
28
- mwxlib-0.94.5.dist-info/RECORD,,
24
+ mwxlib-0.94.7.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
25
+ mwxlib-0.94.7.dist-info/METADATA,sha256=_il1CbhksQkqZv4Gbmb_tr6DuQf8usLLIoGqXm1U6Ic,1925
26
+ mwxlib-0.94.7.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
27
+ mwxlib-0.94.7.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
28
+ mwxlib-0.94.7.dist-info/RECORD,,