mwxlib 0.99.0__py3-none-any.whl → 1.7.13__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.
mwx/py/filling.py CHANGED
@@ -141,7 +141,7 @@ class FillingTree(wx.TreeCtrl):
141
141
  def filter(self, obj, key):
142
142
  """Filter function that determines whether the item is displayed."""
143
143
  if wx.Platform == '__WXMSW__':
144
- if key == 'DropTarget': # Windows bug fix.
144
+ if key == 'DropTarget': # Windows bug fix.
145
145
  return False
146
146
  return True
147
147
 
@@ -212,6 +212,7 @@ class FillingTree(wx.TreeCtrl):
212
212
  def display(self, rooting=True):
213
213
  """Display the current item data.
214
214
  Called when an item/branch needs to be updated.
215
+
215
216
  Args:
216
217
  rooting: True if the current item must be updated
217
218
  False otherwise to reduce overheads.
@@ -219,7 +220,7 @@ class FillingTree(wx.TreeCtrl):
219
220
  item = self.item
220
221
  if not item:
221
222
  return
222
- parent = self.GetItemParent(item) # Check a parent one above.
223
+ parent = self.GetItemParent(item) # Check a parent one above.
223
224
  if parent:
224
225
  def _roots(item):
225
226
  """Retrace the root of parent/item data.
@@ -231,8 +232,8 @@ class FillingTree(wx.TreeCtrl):
231
232
  obj = self.GetItemData(parent)
232
233
  key = self.GetItemText(item)
233
234
  try:
234
- # data = self.objGetChildren(obj)[key] # overheads...
235
- data = getattr(obj, key) # easier way to access here.
235
+ # data = self.objGetChildren(obj)[key] # overheads...
236
+ data = getattr(obj, key) # easier way to access here.
236
237
  if self.GetItemData(item) is not data:
237
238
  self.SetItemData(item, data)
238
239
  return item
@@ -242,15 +243,15 @@ class FillingTree(wx.TreeCtrl):
242
243
  root = _roots(item)
243
244
  if rooting:
244
245
  if root and self.IsExpanded(root):
245
- self.updateChildren(root) # Update roots items.
246
+ self.updateChildren(root) # Update roots items.
246
247
  if parent != root:
247
- self.updateChildren(parent) # Update parent items.
248
+ self.updateChildren(parent) # Update parent items.
248
249
  if self.IsExpanded(item):
249
- self.updateChildren(item) # Update the current item if necessary.
250
+ self.updateChildren(item) # Update the current item if necessary.
250
251
  self.setText('')
251
252
  obj = self.GetItemData(item)
252
253
  if wx.Platform == '__WXMSW__':
253
- if obj is None: # Windows bug fix.
254
+ if obj is None: # Windows bug fix.
254
255
  return
255
256
  self.SetItemHasChildren(item, self.objHasChildren(obj))
256
257
  otype = type(obj)
mwx/testsuite.py ADDED
@@ -0,0 +1,38 @@
1
+ #! python3
2
+ """Test suite for App, Frame, and ControlPanel.
3
+
4
+ Get the wx.App or wx.Frame instance and start the main-loop if needed.
5
+
6
+ Usage:
7
+ with testApp() as app:
8
+ frm = wx.Frame(None)
9
+ frm.Show()
10
+
11
+ Is equivalent to:
12
+ app = wx.App()
13
+ frm = wx.Frame(None)
14
+ frm.Show()
15
+ app.MainLoop()
16
+ """
17
+ from contextlib import contextmanager
18
+ import wx
19
+
20
+ __all__ = ["testApp", "testFrame"]
21
+
22
+
23
+ @contextmanager
24
+ def testApp():
25
+ app = wx.GetApp() or wx.App()
26
+ yield app
27
+ if not app.GetMainLoop():
28
+ app.MainLoop()
29
+ ## wx.App.run = staticmethod(testApp)
30
+
31
+
32
+ @contextmanager
33
+ def testFrame(**kwargs):
34
+ with testApp():
35
+ frm = wx.Frame(None, **kwargs)
36
+ yield frm
37
+ frm.Show()
38
+ ## wx.Frame.run = staticmethod(testFrame)