mwxlib 0.92.2__py3-none-any.whl → 0.92.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
@@ -1,7 +1,7 @@
1
1
  #! python3
2
2
  """mwxlib framework.
3
3
  """
4
- __version__ = "0.92.2"
4
+ __version__ = "0.92.4"
5
5
  __author__ = "Kazuya O'moto <komoto@jeol.co.jp>"
6
6
 
7
7
  from functools import wraps, partial
@@ -1108,8 +1108,8 @@ class ShellFrame(MiniFrame):
1108
1108
 
1109
1109
  self.ghost = AuiNotebook(self, size=(600,400))
1110
1110
  self.ghost.AddPage(self.Scratch, "Scratch")
1111
- self.ghost.AddPage(self.Log, "Log")
1112
- self.ghost.AddPage(self.Help, "Help")
1111
+ self.ghost.AddPage(self.Log, "Log")
1112
+ self.ghost.AddPage(self.Help, "Help")
1113
1113
  self.ghost.Name = "ghost"
1114
1114
 
1115
1115
  self.Bookshelf = EditorTreeCtrl(self, name="Bookshelf",
@@ -1249,12 +1249,9 @@ class ShellFrame(MiniFrame):
1249
1249
  self.Log.set_attributes(ReadOnly=True)
1250
1250
  self.Help.set_attributes(ReadOnly=True)
1251
1251
 
1252
- msg = "#! Opened: <{}>\r\n".format(datetime.datetime.now())
1253
- self.add_log(msg)
1254
-
1255
1252
  self.load_session(
1256
1253
  os.path.abspath(debrc) if debrc else self.SESSION_FILE)
1257
-
1254
+
1258
1255
  SESSION_FILE = get_rootpath(".debrc")
1259
1256
  SCRATCH_FILE = get_rootpath("scratch.py")
1260
1257
  LOGGING_FILE = get_rootpath("deb-logging.log")
@@ -1272,7 +1269,10 @@ class ShellFrame(MiniFrame):
1272
1269
 
1273
1270
  if flush:
1274
1271
  for book in self.all_books:
1275
- book.delete_all_buffers()
1272
+ book.delete_all_buffers() # Note: *log* is also flushed.
1273
+
1274
+ msg = "#! Opened: <{}>\r\n".format(datetime.datetime.now())
1275
+ self.add_log(msg)
1276
1276
 
1277
1277
  def _fload(editor, filename):
1278
1278
  try:
@@ -1318,7 +1318,7 @@ class ShellFrame(MiniFrame):
1318
1318
  pass
1319
1319
 
1320
1320
  _fsave(self.Scratch, self.SCRATCH_FILE) # save scratch
1321
- _fsave(self.Log, self.LOGGING_FILE)
1321
+ _fsave(self.Log, self.LOGGING_FILE) # save log
1322
1322
 
1323
1323
  with open(self.SESSION_FILE, 'w', encoding='utf-8', newline='') as o:
1324
1324
  o.write("#! Session file (This file is generated automatically)\n")
@@ -1687,7 +1687,6 @@ class ShellFrame(MiniFrame):
1687
1687
  def debug(self, obj, *args, **kwargs):
1688
1688
  shell = self.debugger.interactive_shell
1689
1689
  self.debugger.interactive_shell = self.current_shell
1690
- self.debugger.editor = self.Log # set default logger
1691
1690
  try:
1692
1691
  if isinstance(obj, type(print)):
1693
1692
  wx.MessageBox("Unable to debug builtin functions.\n\n"
@@ -1697,7 +1696,8 @@ class ShellFrame(MiniFrame):
1697
1696
  self.debugger.debug(obj, *args, **kwargs)
1698
1697
  elif isinstance(obj, str):
1699
1698
  filename = "<string>"
1700
- buf = self.Log.find_buffer(filename) or self.Log.create_buffer(filename)
1699
+ buf = self.Scratch.find_buffer(filename)\
1700
+ or self.Scratch.create_buffer(filename)
1701
1701
  with buf.off_readonly():
1702
1702
  buf.Text = obj
1703
1703
  self.debugger.run(obj, filename)
@@ -1712,6 +1712,8 @@ class ShellFrame(MiniFrame):
1712
1712
 
1713
1713
  def on_debug_begin(self, frame):
1714
1714
  """Called before set_trace."""
1715
+ if not self:
1716
+ return
1715
1717
  shell = self.debugger.interactive_shell
1716
1718
  shell.write("#<-- Enter [n]ext to continue.\n", -1)
1717
1719
  shell.prompt()
@@ -1724,6 +1726,8 @@ class ShellFrame(MiniFrame):
1724
1726
 
1725
1727
  def on_debug_next(self, frame):
1726
1728
  """Called from cmdloop."""
1729
+ if not self:
1730
+ return
1727
1731
  shell = self.debugger.interactive_shell
1728
1732
  shell.globals = gs = frame.f_globals
1729
1733
  shell.locals = ls = frame.f_locals
@@ -1743,6 +1747,8 @@ class ShellFrame(MiniFrame):
1743
1747
 
1744
1748
  def on_debug_end(self, frame):
1745
1749
  """Called after set_quit."""
1750
+ if not self:
1751
+ return
1746
1752
  shell = self.debugger.interactive_shell
1747
1753
  shell.write("#--> Debugger closed successfully.\n", -1)
1748
1754
  shell.prompt()
@@ -1825,9 +1831,10 @@ class ShellFrame(MiniFrame):
1825
1831
  ## Set a marker on the current line.
1826
1832
  buf.add_marker(buf.cline, 1 if noerr else 2) # 1:white 2:red-arrow
1827
1833
  return
1834
+
1828
1835
  ## Logging text every step in case of crash.
1829
- with open(self.LOGGING_FILE, 'a', encoding='utf-8', newline='') as o:
1830
- o.write(text)
1836
+ ## with open(self.LOGGING_FILE, 'a', encoding='utf-8', newline='') as o:
1837
+ ## o.write(text)
1831
1838
 
1832
1839
  def add_help(self, text):
1833
1840
  """Add text to the help buffer."""
@@ -1836,7 +1843,6 @@ class ShellFrame(MiniFrame):
1836
1843
  buf.SetText(text)
1837
1844
  ## Overwrite text and popup the window.
1838
1845
  self.popup_window(self.Help, focus=0)
1839
- self.Help.swap_page(buf)
1840
1846
 
1841
1847
  def clone_shell(self, target):
1842
1848
  if not hasattr(target, '__dict__'):
@@ -1855,6 +1861,10 @@ class ShellFrame(MiniFrame):
1855
1861
  if shell is self.rootshell:
1856
1862
  ## self.message("- Don't close the root shell.")
1857
1863
  return
1864
+ if self.debugger.busy and shell is self.debugger.interactive_shell:
1865
+ wx.MessageBox("The debugger is running.\n\n"
1866
+ "Enter [q]uit to exit before closing.")
1867
+ return
1858
1868
  j = self.console.GetPageIndex(shell)
1859
1869
  if j != -1:
1860
1870
  self.console.DeletePage(j) # Destroy the window
mwx/nutshell.py CHANGED
@@ -287,6 +287,7 @@ class EditorInterface(CtrlInterface):
287
287
  self.IndentationGuides = stc.STC_IV_LOOKFORWARD
288
288
 
289
289
  self.__mark = -1
290
+ self.__stylus = {}
290
291
 
291
292
  ## Custom constants embedded in stc
292
293
  stc.STC_P_WORD3 = 20
@@ -772,12 +773,17 @@ class EditorInterface(CtrlInterface):
772
773
  ## Preferences / Appearance
773
774
  ## --------------------------------
774
775
 
775
- def set_style(self, spec=None, **kwargs):
776
+ def get_stylus(self):
777
+ return self.__stylus
778
+
779
+ def set_stylus(self, spec=None, **kwargs):
776
780
  spec = spec and spec.copy() or {}
777
781
  spec.update(kwargs)
778
782
  if not spec:
779
783
  return
780
784
 
785
+ self.__stylus.update(spec)
786
+
781
787
  def _map(sc):
782
788
  return dict(kv.partition(':')[::2] for kv in sc.split(',') if kv)
783
789
 
@@ -1182,6 +1188,7 @@ class EditorInterface(CtrlInterface):
1182
1188
 
1183
1189
  @contextmanager
1184
1190
  def save_excursion(self):
1191
+ """Save buffer excursion."""
1185
1192
  try:
1186
1193
  p = self.cpos
1187
1194
  q = self.anchor
@@ -1196,6 +1203,7 @@ class EditorInterface(CtrlInterface):
1196
1203
 
1197
1204
  @contextmanager
1198
1205
  def pre_selection(self):
1206
+ """Save buffer cpos and anchor."""
1199
1207
  try:
1200
1208
  p = self.cpos
1201
1209
  q = self.anchor
@@ -1208,13 +1216,26 @@ class EditorInterface(CtrlInterface):
1208
1216
 
1209
1217
  @contextmanager
1210
1218
  def off_readonly(self):
1219
+ """Set buffer to be writable (ReadOnly=False) temporarily."""
1220
+ r = self.ReadOnly
1211
1221
  try:
1212
- r = self.ReadOnly
1213
1222
  self.ReadOnly = 0
1214
- yield self
1223
+ yield
1215
1224
  finally:
1216
1225
  self.ReadOnly = r
1217
1226
 
1227
+ @contextmanager
1228
+ def save_attributes(self, **kwargs):
1229
+ """Save buffer attributes (e.g. ReadOnly=False)."""
1230
+ for k, v in kwargs.items():
1231
+ kwargs[k] = getattr(self, k)
1232
+ setattr(self, k, v)
1233
+ try:
1234
+ yield
1235
+ finally:
1236
+ for k, v in kwargs.items():
1237
+ setattr(self, k, v)
1238
+
1218
1239
  ## --------------------------------
1219
1240
  ## Edit: comment / insert / kill
1220
1241
  ## --------------------------------
@@ -1504,7 +1525,7 @@ class Buffer(EditWindow, EditorInterface):
1504
1525
  })
1505
1526
 
1506
1527
  self.show_folder()
1507
- self.set_style(self.STYLE)
1528
+ self.set_stylus(self.STYLE)
1508
1529
 
1509
1530
  def __contains__(self, code):
1510
1531
  if inspect.iscode(code) and self.code:
@@ -1795,7 +1816,7 @@ class EditorBook(AuiNotebook, CtrlInterface):
1795
1816
  buf : a buffer to apply (if None, applies to all buffers).
1796
1817
  **kwargs : default style.
1797
1818
 
1798
- Style = Buffer.STYLE => set_style
1819
+ Style = Buffer.STYLE
1799
1820
  ReadOnly = False
1800
1821
  UseTabs = False
1801
1822
  ViewEOL = False
@@ -1809,7 +1830,7 @@ class EditorBook(AuiNotebook, CtrlInterface):
1809
1830
  def _setattribute(buf, attr):
1810
1831
  for k, v in attr.items():
1811
1832
  if k == 'Style':
1812
- buf.set_style(v)
1833
+ buf.set_stylus(v)
1813
1834
  setattr(buf, k, v)
1814
1835
  if buf:
1815
1836
  _setattribute(buf, kwargs)
@@ -2619,7 +2640,7 @@ class Nautilus(Shell, EditorInterface):
2619
2640
 
2620
2641
  self.wrap(0)
2621
2642
  self.show_folder()
2622
- self.set_style(self.STYLE)
2643
+ self.set_stylus(self.STYLE)
2623
2644
 
2624
2645
  ## delete unnecessary arrows at startup
2625
2646
  del self.white_arrow
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mwxlib
3
- Version: 0.92.2
3
+ Version: 0.92.4
4
4
  Summary: A wrapper of matplotlib and wxPython (phoenix)
5
5
  Home-page: https://github.com/komoto48g/mwxlib
6
- Author: Kazuya O'moto <komoto@jeol.co.jp>
6
+ Author: Kazuya O'moto
7
7
  Author-email: komoto@jeol.co.jp
8
8
  License: MIT
9
9
  Classifier: License :: OSI Approved :: MIT License
@@ -1,14 +1,14 @@
1
1
  mwx/__init__.py,sha256=5B4YSOuijG1Uo5-FLtLHGB52Cp_F4vnN--4wGPBx7do,2398
2
2
  mwx/bookshelf.py,sha256=FrissUYdGXLABOzJmMaQU6GXvu6n_9DVW3d5wGwQzjM,6613
3
3
  mwx/controls.py,sha256=toNAFJrPFDO7gb0aBU_IlW4AEIEvQJcwBxR-6e04IAc,46700
4
- mwx/framework.py,sha256=VTczaSaxlNF8hCQWGK_S7CQ-Kn4RB0BiQVDiTBglcYA,74560
4
+ mwx/framework.py,sha256=8r98-kYiW2JTk2gfDLLXbB7Qq9hkecRsNEDtauyj9qc,74895
5
5
  mwx/graphman.py,sha256=PBocTQpWa-f8P5-UV2Ugd01qKCGwFe-rZiginNKu_sI,69738
6
6
  mwx/images.py,sha256=mrnUYH12I3XLVSZcEXlpVltX0XMxufbl2yRvDIQJZqc,49957
7
7
  mwx/matplot2.py,sha256=TM8V5Ggc5iL9lYyM6V4clqH_vIsgS0GsND2ay9zuT0c,32825
8
8
  mwx/matplot2g.py,sha256=owNKt2EcSkf15hYqx9lnpF9qT-WqdSkXSRsH82sYMTs,65571
9
9
  mwx/matplot2lg.py,sha256=IHURrul9JzcLO8Lyll1bW1G215pxgvutDmbQgayG70A,26341
10
10
  mwx/mgplt.py,sha256=ITzxA97yDwr_35BUk5OqnyskSuKVDbpf2AQCKY1jHTI,5671
11
- mwx/nutshell.py,sha256=lzRxbcpXdLHxi2jGrdOLl7DtFzndU4bVq_7AFEzPf5s,135472
11
+ mwx/nutshell.py,sha256=deb8JHotpLwTIP8715ux5mzOx-cnefteweUAZh0s-fU,136115
12
12
  mwx/utilus.py,sha256=fqxJysHXdLt9OOSKDZnBOwmbHvHJPy1qH3R6dI3NLSw,36947
13
13
  mwx/wxmon.py,sha256=Qk86VbuuW2rR46pqEYLur13G_aloWz5SVv6sib30YY0,12717
14
14
  mwx/wxpdb.py,sha256=rx_h4EiLEnHbVu2S6VfhWow7NwLAiTAXKiItY4N2qsk,19464
@@ -16,8 +16,8 @@ mwx/wxwil.py,sha256=KdNaHV-5-fYSFN4h3VxXxdgpB6s5PCpuxkSbytg85eE,5586
16
16
  mwx/wxwit.py,sha256=2gFHi-8nwWRh26RdvZ_AUP--8PDjJB8TUU72y2fBUWM,7557
17
17
  mwx/py/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  mwx/py/filling.py,sha256=KaHooM32hrGGgqw75Cbt8lAvACwC6RXadob9LGgNnEc,16806
19
- mwxlib-0.92.2.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
20
- mwxlib-0.92.2.dist-info/METADATA,sha256=W66d4Chg_oPsESXUVTxrjNoxI1tfUDhEzryJEmNpLWA,1945
21
- mwxlib-0.92.2.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
22
- mwxlib-0.92.2.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
23
- mwxlib-0.92.2.dist-info/RECORD,,
19
+ mwxlib-0.92.4.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
20
+ mwxlib-0.92.4.dist-info/METADATA,sha256=vt9uGOpka_Xhh-1QCZ3JPEMBPcV7B1QvBnKXdPv3_Sk,1925
21
+ mwxlib-0.92.4.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
22
+ mwxlib-0.92.4.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
23
+ mwxlib-0.92.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.3)
2
+ Generator: bdist_wheel (0.42.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5