mwxlib 0.98.6__py3-none-any.whl → 0.98.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/bookshelf.py CHANGED
@@ -2,7 +2,6 @@
2
2
  import re
3
3
  import wx
4
4
 
5
- from .utilus import funcall as _F
6
5
  from .framework import CtrlInterface, postcall
7
6
 
8
7
 
@@ -18,31 +17,11 @@ class EditorTreeCtrl(wx.TreeCtrl, CtrlInterface):
18
17
  self.Font = wx.Font(9, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
19
18
 
20
19
  self.parent = parent
21
- self.target = None
22
-
23
- self.context = { # DNA<EditorBook>
24
- None : {
25
- 'buffer_new' : [ None, self.on_buffer_new ],
26
- 'buffer_saved' : [ None, ],
27
- 'buffer_loaded' : [ None, ],
28
- 'buffer_deleted' : [ None, self.on_buffer_deleted ],
29
- 'buffer_activated' : [ None, self.on_buffer_selected ],
30
- 'buffer_inactivated' : [ None, ],
31
- 'buffer_caption_updated' : [ None, self.on_buffer_filename ],
32
- },
33
- }
34
- wx.CallAfter(self.attach, target=parent)
35
20
 
36
21
  ## self.Bind(wx.EVT_TREE_ITEM_GETTOOLTIP, self.OnItemTooltip)
37
22
  self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged)
38
23
  self.Bind(wx.EVT_WINDOW_DESTROY, self.OnDestroy)
39
24
 
40
- def delete_item():
41
- data = self.GetItemData(self.Selection)
42
- if data:
43
- data.parent.kill_buffer(data) # the focus moves
44
- wx.CallAfter(self.SetFocus)
45
-
46
25
  def dispatch(evt):
47
26
  """Fork events to the parent."""
48
27
  self.parent.handler(self.handler.current_event, evt)
@@ -54,33 +33,57 @@ class EditorTreeCtrl(wx.TreeCtrl, CtrlInterface):
54
33
  '*button* released' : [ None, dispatch ],
55
34
  },
56
35
  0 : {
57
- 'delete pressed' : (0, _F(delete_item)),
58
- 'f5 pressed' : (0, _F(self.build_tree, clear=0)),
59
- 'S-f5 pressed' : (0, _F(self.build_tree, clear=1)),
36
+ 'delete pressed' : (0, self._delete),
37
+ 'f5 pressed' : (0, self._refresh),
60
38
  },
61
39
  })
40
+ self.context = { # DNA<EditorBook>
41
+ None : {
42
+ 'buffer_new' : [ None, self.on_buffer_new ],
43
+ 'buffer_saved' : [ None, ],
44
+ 'buffer_loaded' : [ None, ],
45
+ 'buffer_deleted' : [ None, self.on_buffer_deleted ],
46
+ 'buffer_activated' : [ None, self.on_buffer_selected ],
47
+ 'buffer_inactivated' : [ None, ],
48
+ 'buffer_caption_updated' : [ None, self.on_buffer_filename ],
49
+ },
50
+ }
51
+ def _attach():
52
+ if self and self.parent:
53
+ for editor in self.parent.all_editors:
54
+ editor.handler.append(self.context)
55
+ self.build_tree()
56
+ wx.CallAfter(_attach)
62
57
 
63
58
  def OnDestroy(self, evt):
64
- if evt.EventObject is self:
65
- self.detach()
59
+ if self and self.parent:
60
+ for editor in self.parent.all_editors:
61
+ editor.handler.remove(self.context)
66
62
  evt.Skip()
67
63
 
68
- def attach(self, target):
69
- if not self:
70
- return
71
- self.detach()
72
- self.target = target
73
- for editor in self.target.all_editors:
74
- editor.handler.append(self.context)
64
+ def _refresh(self, evt):
65
+ def _item(editor):
66
+ return self._get_item(self.RootItem, editor.Name)
67
+ ls = []
68
+ for editor in self.parent.all_editors:
69
+ if self.IsExpanded(_item(editor)):
70
+ ls.append(editor)
71
+ data = None
72
+ if self.Selection.IsOk():
73
+ data = self.GetItemData(self.Selection)
74
+ if data:
75
+ wx.CallAfter(data.SetFocus)
76
+ wx.CallAfter(self.SetFocus)
75
77
  self.build_tree()
78
+ for editor in ls:
79
+ self.Expand(_item(editor))
76
80
 
77
- def detach(self):
78
- if not self or not self.target:
79
- return
80
- for editor in self.target.all_editors:
81
- editor.handler.remove(self.context)
82
- self.target = None
83
- self.build_tree()
81
+ def _delete(self, evt):
82
+ if self.Selection.IsOk():
83
+ data = self.GetItemData(self.Selection)
84
+ if data:
85
+ data.parent.kill_buffer(data) # the focus moves
86
+ wx.CallAfter(self.SetFocus)
84
87
 
85
88
  ## --------------------------------
86
89
  ## TreeList/Ctrl wrapper interface
@@ -93,33 +96,39 @@ class EditorTreeCtrl(wx.TreeCtrl, CtrlInterface):
93
96
  if clear:
94
97
  self.DeleteAllItems()
95
98
  self.AddRoot(self.Name)
96
- if self.target:
97
- for editor in self.target.all_editors:
98
- self._set_item(self.RootItem, editor.Name, editor.all_buffers)
99
+ for editor in self.parent.all_editors:
100
+ self._set_item(self.RootItem, editor.Name, editor.all_buffers)
99
101
  self.Refresh()
100
102
 
101
- def _get_item(self, root, key):
102
- """Returns the first item [root/key] found.
103
- Note: Items with the same name are not supported.
104
- """
103
+ def _gen_item(self, root, key):
104
+ """Generates the [root/key] items."""
105
105
  item, cookie = self.GetFirstChild(root)
106
106
  while item:
107
107
  caption = self.GetItemText(item)
108
108
  if key == re.sub(r"^\W+\s+(.*)", r"\1", caption):
109
- return item
109
+ yield item
110
110
  item, cookie = self.GetNextChild(root, cookie)
111
111
 
112
+ def _get_item(self, root, key):
113
+ """Get the first [root/key] item found."""
114
+ return next(self._gen_item(root, key), None)
115
+
112
116
  def _set_item(self, root, key, data):
113
- """Set the item [root/key] with data recursively.
114
- """
115
- item = self._get_item(root, key) or self.AppendItem(root, key)
116
- if isinstance(data, list):
117
+ """Set the [root/key] item with data recursively."""
118
+ for item in self._gen_item(root, key):
119
+ buf = self.GetItemData(item)
120
+ if not buf or buf is data:
121
+ break
122
+ else:
123
+ item = self.AppendItem(root, key)
124
+ try:
117
125
  for buf in data:
118
126
  self._set_item(item, buf.name, buf)
119
- else:
127
+ except Exception:
120
128
  data.__itemId = item
121
129
  self.SetItemData(item, data)
122
130
  self.SetItemText(item, data.caption_prefix + data.name)
131
+ return item
123
132
 
124
133
  ## --------------------------------
125
134
  ## Actions for bookshelf interfaces
@@ -135,10 +144,12 @@ class EditorTreeCtrl(wx.TreeCtrl, CtrlInterface):
135
144
  ## buf.__itemId がない場合がある (delete_buffer 直後など)
136
145
  @postcall
137
146
  def on_buffer_selected(self, buf):
138
- self.SelectItem(buf.__itemId)
147
+ if self and buf:
148
+ self.SelectItem(buf.__itemId)
139
149
 
140
150
  def on_buffer_filename(self, buf):
141
- self.SetItemText(buf.__itemId, buf.caption_prefix + buf.name)
151
+ if self and buf:
152
+ self.SetItemText(buf.__itemId, buf.caption_prefix + buf.name)
142
153
 
143
154
  def OnSelChanged(self, evt):
144
155
  if self and self.HasFocus():
mwx/controls.py CHANGED
@@ -7,7 +7,7 @@ import wx.lib.platebtn as pb
7
7
  import wx.lib.scrolledpanel as scrolled
8
8
 
9
9
  from . import images
10
- from .utilus import SSM
10
+ from .utilus import SSM, warn
11
11
  from .utilus import funcall as _F
12
12
  from .framework import pack, Menu, postcall
13
13
 
@@ -84,6 +84,14 @@ class Param:
84
84
  def __len__(self):
85
85
  return len(self.range)
86
86
 
87
+ def bind(self, action=None, target='control'):
88
+ warn("Use `Param.callback.bind('control')` instead.", DeprecationWarning)
89
+ return self.callback.bind(target, action)
90
+
91
+ def unbind(self, action=None, target='control'):
92
+ warn("Use `Param.callback.unbind('control')` instead.", DeprecationWarning)
93
+ return self.callback.unbind(target, action)
94
+
87
95
  def reset(self, v=None, internal_callback=True):
88
96
  """Reset value when indexed (by knobs) with callback."""
89
97
  if v is None:
mwx/framework.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #! python3
2
2
  """mwxlib framework.
3
3
  """
4
- __version__ = "0.98.6"
4
+ __version__ = "0.98.7"
5
5
  __author__ = "Kazuya O'moto <komoto@jeol.co.jp>"
6
6
 
7
7
  from contextlib import contextmanager
@@ -1135,8 +1135,8 @@ class ShellFrame(MiniFrame):
1135
1135
  skip=[Debugger.__module__, # Don't enter debugger
1136
1136
  EventMonitor.__module__, # Don't enter event-hook
1137
1137
  FSM.__module__,
1138
- 'fnmatch', 'warnings', 'bdb', 'pdb',
1139
1138
  'wx.core', 'wx.lib.eventwatcher',
1139
+ 'fnmatch', 'warnings', 'bdb', 'pdb', #'contextlib',
1140
1140
  ],
1141
1141
  )
1142
1142
  self.inspector = Inspector(self, name="Inspector")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mwxlib
3
- Version: 0.98.6
3
+ Version: 0.98.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,7 +1,7 @@
1
1
  mwx/__init__.py,sha256=nN62CGTWjME7Zz2h-jIRB8MxwuErIkHPGrlBzydkF0o,643
2
- mwx/bookshelf.py,sha256=Y4xI2SrEO22DrI1hyyfFx7DfFZA8znOzX9RWMPsA2BE,5137
3
- mwx/controls.py,sha256=jhru4HiIijb3QJz2elGt0in9soaR3xilgHsfItYY0JI,47595
4
- mwx/framework.py,sha256=rp93Nh7eqeAWGpkjxp-NY84RYBfmI1Ahn_tauavWSbg,75475
2
+ mwx/bookshelf.py,sha256=so-xSLq08sMlJBErTxOaDoKUAMa_g1CkIP2pNnff68c,5607
3
+ mwx/controls.py,sha256=TRlwxUNhY5myJYiCWIogisM-khVIVvKbjrCU19e_1Ms,47991
4
+ mwx/framework.py,sha256=RKYDybDicu1JQQmnWZETQjJCqMmSP2O6DqpZF1waMfs,75490
5
5
  mwx/graphman.py,sha256=A53ufapRAysL0wTCr1anrg_T_PqpumonnYn-swaC598,70165
6
6
  mwx/images.py,sha256=_-Eh3xF7Khu42ivkYp97NXIzSNGbjcidqtWjZQFGtqE,47827
7
7
  mwx/matplot2.py,sha256=xCJ_ZzdDEWmzctpPaOrzTnwXyHINP4nfFHweoTZa6ug,32899
@@ -21,8 +21,8 @@ mwx/plugins/frame_listview.py,sha256=hbApzZWa9-BmQthu7uZBlBbGbtf4iJ_prO8IhxoGMs8
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.98.6.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
25
- mwxlib-0.98.6.dist-info/METADATA,sha256=RDfB4NPf48FHJKeGXjSM72yYzMlOlrs5nqqPqO45ToU,7411
26
- mwxlib-0.98.6.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
27
- mwxlib-0.98.6.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
28
- mwxlib-0.98.6.dist-info/RECORD,,
24
+ mwxlib-0.98.7.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
25
+ mwxlib-0.98.7.dist-info/METADATA,sha256=AB3gj2NFJuTGe34FMOVYzjkQCZAFWZHNQ_bTb_dWMio,7411
26
+ mwxlib-0.98.7.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
27
+ mwxlib-0.98.7.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
28
+ mwxlib-0.98.7.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (73.0.1)
2
+ Generator: setuptools (74.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5