mwxlib 0.99.3__py3-none-any.whl → 0.99.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/__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.6"
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; defaults to None.
36
+ If None, no session will be created or 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"] = [
@@ -1028,7 +1023,7 @@ class FileDropLoader(wx.DropTarget):
1028
1023
  def __init__(self, target):
1029
1024
  wx.DropTarget.__init__(self)
1030
1025
 
1031
- self.editor = target
1026
+ self.target = target
1032
1027
  self.textdo = wx.TextDataObject()
1033
1028
  self.filedo = wx.FileDataObject()
1034
1029
  self.DataObject = wx.DataObjectComposite()
@@ -1036,7 +1031,7 @@ class FileDropLoader(wx.DropTarget):
1036
1031
  self.DataObject.Add(self.filedo, True)
1037
1032
 
1038
1033
  def OnData(self, x, y, result):
1039
- editor = self.editor
1034
+ editor = self.target.current_editor
1040
1035
  self.GetData()
1041
1036
  if self.textdo.TextLength > 1:
1042
1037
  f = self.textdo.Text.strip()
@@ -1065,12 +1060,12 @@ 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
+ session : file name of the session; defaults to None.
1065
+ If None, no session will be created or saved.
1066
+ ensureClose : flag for the shell standalone.
1072
1067
  If True, EVT_CLOSE will close the window.
1073
- Otherwise it will be only hidden.
1068
+ Otherwise the window will be only hidden.
1074
1069
  **kwargs : Nautilus arguments
1075
1070
 
1076
1071
  Attributes:
@@ -1104,18 +1099,14 @@ class ShellFrame(MiniFrame):
1104
1099
  """
1105
1100
  rootshell = property(lambda self: self.__shell) #: the root shell
1106
1101
 
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)
1102
+ def __init__(self, parent, target=None, session=None, ensureClose=False, **kwargs):
1103
+ MiniFrame.__init__(self, parent, size=(1280,720), style=wx.DEFAULT_FRAME_STYLE)
1111
1104
 
1112
1105
  self.statusbar.resize((-1,120))
1113
1106
  self.statusbar.Show(1)
1114
1107
 
1115
1108
  self.__standalone = bool(ensureClose)
1116
1109
 
1117
- ## Initialize self-specific builtins.
1118
- ## Note: This should be called before creating root shell.
1119
1110
  self.Init()
1120
1111
 
1121
1112
  from .nutshell import Nautilus, EditorBook
@@ -1170,7 +1161,7 @@ class ShellFrame(MiniFrame):
1170
1161
 
1171
1162
  self.ghost.AddPage(self.Bookshelf, "Bookshelf", bitmap=Icon('book'))
1172
1163
 
1173
- self.ghost.SetDropTarget(FileDropLoader(self.Scratch))
1164
+ self.ghost.SetDropTarget(FileDropLoader(self))
1174
1165
 
1175
1166
  self.watcher = AuiNotebook(self, size=(600,400), name="watcher")
1176
1167
  self.watcher.AddPage(self.ginfo, "globals")
@@ -1276,31 +1267,17 @@ class ShellFrame(MiniFrame):
1276
1267
  },
1277
1268
  })
1278
1269
 
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
1270
+ ## Session files
1298
1271
  self.SESSION_FILE = get_rootpath(".debrc")
1299
1272
  self.SCRATCH_FILE = get_rootpath("scratch.py")
1300
1273
  self.LOGGING_FILE = get_rootpath("deb-logging.log")
1301
1274
 
1302
- self.load_session(
1303
- os.path.abspath(debrc) if debrc else self.SESSION_FILE)
1275
+ if session is not None:
1276
+ self.load_session(session or self.SESSION_FILE)
1277
+ else:
1278
+ self.SESSION_FILE = None
1279
+
1280
+ self.postInit()
1304
1281
 
1305
1282
  def load_session(self, filename):
1306
1283
  """Load session from file.
@@ -1319,13 +1296,13 @@ class ShellFrame(MiniFrame):
1319
1296
  ## Re-open the *log* file.
1320
1297
  self.add_log("#! Opened: <{}>\r\n".format(datetime.datetime.now()))
1321
1298
 
1322
- fn = os.path.abspath(filename)
1299
+ session = os.path.abspath(filename)
1323
1300
  try:
1324
- with open(fn, encoding='utf-8', newline='') as i:
1301
+ with open(session) as i:
1325
1302
  exec(i.read())
1326
1303
  except FileNotFoundError:
1327
1304
  pass
1328
- self.SESSION_FILE = fn
1305
+ self.SESSION_FILE = session
1329
1306
 
1330
1307
  ## Reposition the window if it is not on the desktop.
1331
1308
  if wx.Display.GetFromWindow(self) == -1:
@@ -1346,6 +1323,9 @@ class ShellFrame(MiniFrame):
1346
1323
  _fsave(self.Scratch, self.SCRATCH_FILE) # save scratch
1347
1324
  _fsave(self.Log, self.LOGGING_FILE) # save log
1348
1325
 
1326
+ if not self.SESSION_FILE:
1327
+ return
1328
+
1349
1329
  with open(self.SESSION_FILE, 'w') as o:
1350
1330
  o.write("#! Session file (This file is generated automatically)\n")
1351
1331
  o.write("self.SetSize({})\n".format(self.Size))
@@ -1365,7 +1345,39 @@ class ShellFrame(MiniFrame):
1365
1345
  "self._mgr.Update()\n",
1366
1346
  )))
1367
1347
 
1348
+ def postInit(self):
1349
+ """Set shell and editor styles.
1350
+ Note:
1351
+ This is called after loading session.
1352
+ """
1353
+ from .nutshell import Stylus
1354
+
1355
+ self.Scratch.set_attributes(Style=Stylus.py_shell_mode)
1356
+
1357
+ self.Log.set_attributes(ReadOnly=True,
1358
+ Style=Stylus.py_log_mode)
1359
+
1360
+ self.Help.set_attributes(ReadOnly=False,
1361
+ Style=Stylus.py_text_mode)
1362
+
1363
+ self.set_hookable(self.Scratch)
1364
+ self.set_hookable(self.Log)
1365
+
1366
+ @self.Scratch.define_key('C-j')
1367
+ def eval_line(evt):
1368
+ self.Scratch.buffer.eval_line()
1369
+ evt.Skip(False) # Don't skip explicitly.
1370
+
1371
+ @self.Scratch.define_key('M-j')
1372
+ def eval_buffer(evt):
1373
+ self.Scratch.buffer.exec_region()
1374
+ evt.Skip(False) # Don't skip explicitly.
1375
+
1368
1376
  def Init(self):
1377
+ """Initialize self-specific builtins.
1378
+ Note:
1379
+ This should be called before creating root shell.
1380
+ """
1369
1381
  try:
1370
1382
  builtins.dive
1371
1383
  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/mgplt.py CHANGED
@@ -129,7 +129,7 @@ class GnuplotFrame(mwx.Frame):
129
129
  mwx.Frame.__init__(self, *args, **kwargs)
130
130
 
131
131
  self.gnuplot = Gnuplot()
132
- self.panel = GnuplotPanel(self)
132
+ self.panel = ControlPanel(self)
133
133
 
134
134
  self.menubar["Edit"] = [
135
135
  (wx.ID_COPY, "&Copy params\tCtrl-c", "Copy params to clipboard",
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.6
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=jsOZNCo0Sjea8XWBGSEghENyNTVGVAvZxkDQYi_6BUA,75632
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
- mwx/mgplt.py,sha256=0WJ1RN_Y0a4Y3rz1C_Lx-WhumtOMdb1N49guX9aZZ_o,5602
11
- mwx/nutshell.py,sha256=1lHjyrCY4J_wtRlMnJuLq6xn22ofWw6TrZPtGthXZyc,142080
10
+ mwx/mgplt.py,sha256=M5rt-H7Uq1OHnlFvMA4a3945UBvppbR9L_mw8NL_YZ0,5602
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.6.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
25
+ mwxlib-0.99.6.dist-info/METADATA,sha256=oJA02gAxSPxjaJwcQ9DEyrxQHoRuR-1kAD7ZSq1JLMs,7411
26
+ mwxlib-0.99.6.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
27
+ mwxlib-0.99.6.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
28
+ mwxlib-0.99.6.dist-info/RECORD,,