mwxlib 0.99.3__py3-none-any.whl → 0.99.5__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/__init__.py CHANGED
@@ -2,7 +2,7 @@
2
2
  """mwxlib framework (based on matplotlib/wx)
3
3
  """
4
4
  from .framework import __version__, __author__
5
- from .framework import FSM
5
+ from .framework import FSM, TreeList
6
6
  from .framework import Menu, MenuBar, StatusBar
7
7
  from .framework import Frame, MiniFrame, ShellFrame, deb
8
8
 
mwx/framework.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #! python3
2
2
  """mwxlib framework.
3
3
  """
4
- __version__ = "0.99.3"
4
+ __version__ = "0.99.5"
5
5
  __author__ = "Kazuya O'moto <komoto@jeol.co.jp>"
6
6
 
7
7
  from contextlib import contextmanager
@@ -24,17 +24,18 @@ from .utilus import get_rootpath, ignore, warn
24
24
  from .utilus import FSM, TreeList, apropos, typename, where, mro, pp
25
25
 
26
26
 
27
- def deb(target=None, loop=True, locals=None, **kwargs):
27
+ def deb(target=None, loop=True, locals=None, debrc=None, **kwargs):
28
28
  """Dive into the process.
29
29
 
30
30
  Args:
31
31
  target : Object or module (default None).
32
32
  If None, the target is set to `__main__`.
33
33
  loop : If True, the app and the mainloop will be created.
34
- Otherwise, neither the app nor the mainloop will be created.
35
34
  locals : Additional context of the shell
35
+ debrc : file name of the session.
36
+ If None, the session will not be saved.
36
37
 
37
- **kwargs: Nautilus arguments
38
+ **kwargs: Nautilus ShellFrame arguments
38
39
 
39
40
  - introText : introductory of the shell
40
41
  - startupScript : startup script file (default None)
@@ -45,25 +46,19 @@ def deb(target=None, loop=True, locals=None, **kwargs):
45
46
  Note:
46
47
  This will execute the startup script $(PYTHONSTARTUP).
47
48
  """
48
- quote_unqoute = """
49
- Anything one man can imagine, other man can make real.
50
- --- Jules Verne (1828--1905)
51
- """
52
- kwargs.setdefault("introText",
53
- "mwx {}".format(__version__) + quote_unqoute)
49
+ kwargs.setdefault("introText", f"mwx {__version__}\n")
54
50
  kwargs.setdefault("execStartupScript", True)
55
51
  kwargs.setdefault("ensureClose", True)
56
-
52
+
57
53
  app = wx.GetApp() or wx.App()
58
- frame = ShellFrame(None, target, **kwargs)
54
+ frame = ShellFrame(None, target, session=debrc, **kwargs)
59
55
  frame.Show()
60
56
  frame.rootshell.SetFocus()
61
57
  if locals:
62
58
  frame.rootshell.locals.update(locals)
63
- if not loop:
64
- return frame
65
- if not app.GetMainLoop():
66
- return app.MainLoop()
59
+ if loop and not app.GetMainLoop():
60
+ app.MainLoop()
61
+ return frame
67
62
 
68
63
 
69
64
  def postcall(f):
@@ -741,7 +736,7 @@ class Frame(wx.Frame, KeyCtrlInterfaceMixin):
741
736
  def __init__(self, *args, **kwargs):
742
737
  wx.Frame.__init__(self, *args, **kwargs)
743
738
 
744
- self.shellframe = ShellFrame(None, target=self)
739
+ self.shellframe = ShellFrame(None, target=self, session='')
745
740
 
746
741
  self.menubar = MenuBar()
747
742
  self.menubar["File"] = [
@@ -1065,10 +1060,8 @@ class ShellFrame(MiniFrame):
1065
1060
 
1066
1061
  Args:
1067
1062
  target : target object of the rootshell.
1068
- If None, it will be `__main__`.
1069
- debrc : session file for deb run command.
1070
- SESSION_FILE will be overwritten.
1071
- ensureClose : A flag for the shell standalone.
1063
+ If None, it will be __main__.
1064
+ ensureClose : flag for the shell standalone.
1072
1065
  If True, EVT_CLOSE will close the window.
1073
1066
  Otherwise it will be only hidden.
1074
1067
  **kwargs : Nautilus arguments
@@ -1104,18 +1097,14 @@ class ShellFrame(MiniFrame):
1104
1097
  """
1105
1098
  rootshell = property(lambda self: self.__shell) #: the root shell
1106
1099
 
1107
- def __init__(self, parent, target=None, debrc=None, ensureClose=False,
1108
- title=None, size=(1280,720), style=wx.DEFAULT_FRAME_STYLE,
1109
- **kwargs):
1110
- MiniFrame.__init__(self, parent, size=size, style=style)
1100
+ def __init__(self, parent, target=None, session=None, ensureClose=False, **kwargs):
1101
+ MiniFrame.__init__(self, parent, size=(1280,720), style=wx.DEFAULT_FRAME_STYLE)
1111
1102
 
1112
1103
  self.statusbar.resize((-1,120))
1113
1104
  self.statusbar.Show(1)
1114
1105
 
1115
1106
  self.__standalone = bool(ensureClose)
1116
1107
 
1117
- ## Initialize self-specific builtins.
1118
- ## Note: This should be called before creating root shell.
1119
1108
  self.Init()
1120
1109
 
1121
1110
  from .nutshell import Nautilus, EditorBook
@@ -1276,31 +1265,17 @@ class ShellFrame(MiniFrame):
1276
1265
  },
1277
1266
  })
1278
1267
 
1279
- self.Scratch.set_attributes(Style=self.rootshell.get_stylus())
1280
-
1281
- self.Log.set_attributes(ReadOnly=True)
1282
- self.Help.set_attributes(ReadOnly=False)
1283
-
1284
- self.set_hookable(self.Scratch)
1285
- self.set_hookable(self.Log)
1286
-
1287
- @self.Scratch.define_key('C-j')
1288
- def eval_line(evt):
1289
- self.Scratch.buffer.eval_line()
1290
- evt.Skip(False) # Don't skip explicitly.
1291
-
1292
- @self.Scratch.define_key('M-j')
1293
- def eval_buffer(evt):
1294
- self.Scratch.buffer.exec_region()
1295
- evt.Skip(False) # Don't skip explicitly.
1296
-
1297
- ## Session
1268
+ ## Session files
1298
1269
  self.SESSION_FILE = get_rootpath(".debrc")
1299
1270
  self.SCRATCH_FILE = get_rootpath("scratch.py")
1300
1271
  self.LOGGING_FILE = get_rootpath("deb-logging.log")
1301
1272
 
1302
- self.load_session(
1303
- os.path.abspath(debrc) if debrc else self.SESSION_FILE)
1273
+ if session is not None:
1274
+ self.load_session(session or self.SESSION_FILE)
1275
+ else:
1276
+ self.SESSION_FILE = None
1277
+
1278
+ self.postInit()
1304
1279
 
1305
1280
  def load_session(self, filename):
1306
1281
  """Load session from file.
@@ -1319,13 +1294,13 @@ class ShellFrame(MiniFrame):
1319
1294
  ## Re-open the *log* file.
1320
1295
  self.add_log("#! Opened: <{}>\r\n".format(datetime.datetime.now()))
1321
1296
 
1322
- fn = os.path.abspath(filename)
1297
+ session = os.path.abspath(filename)
1323
1298
  try:
1324
- with open(fn, encoding='utf-8', newline='') as i:
1299
+ with open(session) as i:
1325
1300
  exec(i.read())
1326
1301
  except FileNotFoundError:
1327
1302
  pass
1328
- self.SESSION_FILE = fn
1303
+ self.SESSION_FILE = session
1329
1304
 
1330
1305
  ## Reposition the window if it is not on the desktop.
1331
1306
  if wx.Display.GetFromWindow(self) == -1:
@@ -1346,6 +1321,9 @@ class ShellFrame(MiniFrame):
1346
1321
  _fsave(self.Scratch, self.SCRATCH_FILE) # save scratch
1347
1322
  _fsave(self.Log, self.LOGGING_FILE) # save log
1348
1323
 
1324
+ if not self.SESSION_FILE:
1325
+ return
1326
+
1349
1327
  with open(self.SESSION_FILE, 'w') as o:
1350
1328
  o.write("#! Session file (This file is generated automatically)\n")
1351
1329
  o.write("self.SetSize({})\n".format(self.Size))
@@ -1365,7 +1343,39 @@ class ShellFrame(MiniFrame):
1365
1343
  "self._mgr.Update()\n",
1366
1344
  )))
1367
1345
 
1346
+ def postInit(self):
1347
+ """Set shell and editor styles.
1348
+ Note:
1349
+ This is called after loading session.
1350
+ """
1351
+ from .nutshell import Stylus
1352
+
1353
+ self.Scratch.set_attributes(Style=Stylus.py_shell_mode)
1354
+
1355
+ self.Log.set_attributes(ReadOnly=True,
1356
+ Style=Stylus.py_log_mode)
1357
+
1358
+ self.Help.set_attributes(ReadOnly=False,
1359
+ Style=Stylus.py_text_mode)
1360
+
1361
+ self.set_hookable(self.Scratch)
1362
+ self.set_hookable(self.Log)
1363
+
1364
+ @self.Scratch.define_key('C-j')
1365
+ def eval_line(evt):
1366
+ self.Scratch.buffer.eval_line()
1367
+ evt.Skip(False) # Don't skip explicitly.
1368
+
1369
+ @self.Scratch.define_key('M-j')
1370
+ def eval_buffer(evt):
1371
+ self.Scratch.buffer.exec_region()
1372
+ evt.Skip(False) # Don't skip explicitly.
1373
+
1368
1374
  def Init(self):
1375
+ """Initialize self-specific builtins.
1376
+ Note:
1377
+ This should be called before creating root shell.
1378
+ """
1369
1379
  try:
1370
1380
  builtins.dive
1371
1381
  except AttributeError:
mwx/graphman.py CHANGED
@@ -625,8 +625,8 @@ class Frame(mwx.Frame):
625
625
 
626
626
  self.__plugins = {} # modules in the order of load/save
627
627
 
628
- self.__graph = Graph(self, log=self.message, margin=None, size=(600,600))
629
- self.__output = Graph(self, log=self.message, margin=None, size=(600,600))
628
+ self.__graph = Graph(self, log=self.message, margin=None)
629
+ self.__output = Graph(self, log=self.message, margin=None)
630
630
 
631
631
  self.__histgrm = Histogram(self, log=self.message, margin=None, size=(130,65))
632
632
  self.__histgrm.attach(self.graph)
@@ -822,14 +822,14 @@ class Frame(mwx.Frame):
822
822
  ## Accepts DnD
823
823
  self.SetDropTarget(MyFileDropLoader(self.graph, self))
824
824
 
825
- ## Script editor for plugins (external call)
826
- self.Editor = "notepad"
825
+ ## Script editor for plugins (external call)
826
+ EDITOR = "notepad"
827
827
 
828
- sync_switch = True
828
+ SYNC_SWITCH = True
829
829
 
830
830
  def sync(self, a, b):
831
831
  """Synchronize b to a."""
832
- if (self.sync_switch
832
+ if (self.SYNC_SWITCH
833
833
  and a.frame and b.frame
834
834
  and a.frame.unit == b.frame.unit
835
835
  and a.buffer.shape == b.buffer.shape):
@@ -1336,8 +1336,7 @@ class Frame(mwx.Frame):
1336
1336
  if not plug:
1337
1337
  return
1338
1338
 
1339
- Popen([self.Editor,
1340
- inspect.getmodule(plug).__file__])
1339
+ Popen([self.EDITOR, inspect.getmodule(plug).__file__])
1341
1340
 
1342
1341
  def inspect_plug(self, name):
1343
1342
  """Dive into the process to inspect plugs in the shell.
mwx/nutshell.py CHANGED
@@ -17,7 +17,8 @@ import sys
17
17
  import os
18
18
  import re
19
19
  import wx
20
- from wx import stc, aui
20
+ from wx import aui
21
+ from wx import stc
21
22
  from wx.py import dispatcher
22
23
  from wx.py import introspect
23
24
  from wx.py import interpreter
@@ -53,7 +54,7 @@ stc.STC_STYLE_CARETLINE = 40
53
54
  stc.STC_STYLE_ANNOTATION = 41
54
55
 
55
56
  class Stylus:
56
- py_buffer_mode = {
57
+ py_log_mode = {
57
58
  stc.STC_STYLE_DEFAULT : "fore:#7f7f7f,back:#ffffb8,size:9,face:MS Gothic",
58
59
  stc.STC_STYLE_LINENUMBER : "fore:#000000,back:#ffffb8,size:9",
59
60
  stc.STC_STYLE_BRACELIGHT : "fore:#000000,back:#ffffb8,bold",
@@ -1930,7 +1931,7 @@ class Buffer(EditorInterface, EditWindow):
1930
1931
  })
1931
1932
 
1932
1933
  self.show_folder()
1933
- self.set_stylus(Stylus.py_buffer_mode)
1934
+ self.set_stylus(Stylus.py_text_mode)
1934
1935
 
1935
1936
  def __contains__(self, code):
1936
1937
  if inspect.iscode(code) and self.code:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mwxlib
3
- Version: 0.99.3
3
+ Version: 0.99.5
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
- mwx/__init__.py,sha256=nN62CGTWjME7Zz2h-jIRB8MxwuErIkHPGrlBzydkF0o,643
1
+ mwx/__init__.py,sha256=U7n9X8JAWdzOavKvVqecHdE4ooiXcCB5DSPCKWxfTnY,653
2
2
  mwx/bookshelf.py,sha256=so-xSLq08sMlJBErTxOaDoKUAMa_g1CkIP2pNnff68c,5607
3
3
  mwx/controls.py,sha256=0UkLeyIsQU0uj--v1NYctx-GzqO36Z5rdeNpCsfIN10,47657
4
- mwx/framework.py,sha256=YG3NHz8Jc0llVmlU22W9KOALESPJnjTc0zL5PQmwbQA,75304
5
- mwx/graphman.py,sha256=s0qlaDIPFFvJaY7MeFNcEg4kxbF27jsyu-dJFgulo_U,70327
4
+ mwx/framework.py,sha256=ROCF9XJ5nQMmwaDJFoOs3r2qsV7hM7bfBkR1MaGQSMg,75465
5
+ mwx/graphman.py,sha256=EZiRUKhPb6V-S1BcgFhsOQoaZvp4yw6F4SF45uUjla4,70266
6
6
  mwx/images.py,sha256=_-Eh3xF7Khu42ivkYp97NXIzSNGbjcidqtWjZQFGtqE,47827
7
7
  mwx/matplot2.py,sha256=xCJ_ZzdDEWmzctpPaOrzTnwXyHINP4nfFHweoTZa6ug,32899
8
8
  mwx/matplot2g.py,sha256=gCXa8X1MEMP7n_mG73h3SkWKuNZOfjVKUTWNRXXK11c,64310
9
9
  mwx/matplot2lg.py,sha256=JRWjWnLJUytbSq6wxs4P0gbVUr3xoLSF6Wwqd5V_pJI,27404
10
10
  mwx/mgplt.py,sha256=0WJ1RN_Y0a4Y3rz1C_Lx-WhumtOMdb1N49guX9aZZ_o,5602
11
- mwx/nutshell.py,sha256=1lHjyrCY4J_wtRlMnJuLq6xn22ofWw6TrZPtGthXZyc,142080
11
+ mwx/nutshell.py,sha256=etvpwPctuf9KhvIB1WZwTAaljYQ2ciMRfUWzmXW6NUo,142090
12
12
  mwx/utilus.py,sha256=iizdVrbwL1lX7eTfsMmltFz4IfHqTXVM37wwlPQ3A3Y,37346
13
13
  mwx/wxmon.py,sha256=Pq8XXigM_isJd80yiqG18iRVdArJpsePpxfnZOkk-Uw,12573
14
14
  mwx/wxpdb.py,sha256=lLowkkAgMhPFHAfklD7wZHq0qbSMjRxnBFtSajmVgME,19133
@@ -21,8 +21,8 @@ mwx/plugins/frame_listview.py,sha256=yEYPCdLHLSMTJwTv6iYAh3Lo4lJvYfp5BxTLP3FhW9Y
21
21
  mwx/plugins/line_profile.py,sha256=--9NIc3x5EfRB3L59JvD7rzENQHyiYfu7wWJo6AuMkA,820
22
22
  mwx/py/__init__.py,sha256=xykgfOytOwNuvXsfkLoumFZSTN-iBsHOjczYXngjmUE,12
23
23
  mwx/py/filling.py,sha256=fumUG1F5M9TL-Dfqni4G85uk7TmvnUunTbdcPDV0vfo,16857
24
- mwxlib-0.99.3.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
25
- mwxlib-0.99.3.dist-info/METADATA,sha256=W98i-ZcPeMT7ctVJ055GvGZ_wKDf7LG0dWC9l_Wu13c,7411
26
- mwxlib-0.99.3.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
27
- mwxlib-0.99.3.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
28
- mwxlib-0.99.3.dist-info/RECORD,,
24
+ mwxlib-0.99.5.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
25
+ mwxlib-0.99.5.dist-info/METADATA,sha256=96mrQkWQoHslFbVsH5M7bEfVkEdsoQ7ke3Dn7kBJPe0,7411
26
+ mwxlib-0.99.5.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
27
+ mwxlib-0.99.5.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
28
+ mwxlib-0.99.5.dist-info/RECORD,,