mwxlib 0.99.8__py3-none-any.whl → 0.99.9__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
@@ -8,7 +8,7 @@ from .framework import Frame, MiniFrame, ShellFrame, deb
8
8
 
9
9
  ## Controls
10
10
  from .controls import Param, LParam, Knob, ControlPanel, Clipboard, Icon
11
- from .controls import Button, ToggleButton, TextCtrl, Choice, Gauge, Indicator
11
+ from .controls import Button, ToggleButton, ClassicButton, TextCtrl, Choice, Gauge, Indicator
12
12
 
13
13
  ## Plugman
14
14
  ## from .graphman import Frame as GraphmanFrame, Layer, Thread, Graph
mwx/controls.py CHANGED
@@ -823,8 +823,17 @@ class Clipboard:
823
823
  ## --------------------------------
824
824
  ## Wx custom controls and bitmaps
825
825
  ## --------------------------------
826
- if 1:
827
- _provided_arts = {
826
+
827
+ class Icon(wx.Bitmap):
828
+ """Returns an iconic bitmap with the specified size (w, h).
829
+
830
+ The key is either Icon.provided_arts or Icon.custom_images key.
831
+ If the key is empty it returns a transparent bitmap, otherwise NullBitmap.
832
+
833
+ Note:
834
+ A null (0-shaped) bitmap fails with AssertionError from 4.1.1
835
+ """
836
+ provided_arts = {
828
837
  'cut' : wx.ART_CUT,
829
838
  'copy' : wx.ART_COPY,
830
839
  'paste' : wx.ART_PASTE,
@@ -858,32 +867,69 @@ if 1:
858
867
  '|<-' : wx.ART_GOTO_FIRST,
859
868
  '->|' : wx.ART_GOTO_LAST,
860
869
  }
861
- _custom_images = {
870
+ custom_images = {
862
871
  k:v for k, v in vars(images).items()
863
872
  if isinstance(v, wx.lib.embeddedimage.PyEmbeddedImage)
864
873
  }
865
-
866
- class Icon(wx.Bitmap):
867
- """Returns an iconic bitmap with the specified size (w, h).
868
-
869
- The key is either Icon.provided_arts or Icon.custom_images key.
870
- If the key is empty it returns a transparent bitmap, otherwise NullBitmap.
871
-
872
- Note:
873
- A null (0-shaped) bitmap fails with AssertionError from 4.1.1
874
- """
875
- provided_arts = _provided_arts
876
- custom_images = _custom_images
877
874
 
878
875
  def __init__(self, *args, **kwargs):
879
876
  try:
880
- bmp = _getBitmap1(*args, **kwargs)
877
+ bmp = Icon._getBitmap1(*args, **kwargs)
881
878
  except TypeError:
882
- bmp = _getBitmap2(*args, **kwargs)
879
+ bmp = Icon._getBitmap2(*args, **kwargs)
883
880
  wx.Bitmap.__init__(self, bmp)
884
881
 
885
882
  @staticmethod
886
- def bullet(colour, ec=None, size=(16,16), radius=4):
883
+ def _getBitmap1(key, size=None):
884
+ if isinstance(key, wx.Bitmap):
885
+ if size and key.Size != size:
886
+ key = (key.ConvertToImage()
887
+ .Scale(*size, wx.IMAGE_QUALITY_NEAREST)
888
+ .ConvertToBitmap())
889
+ return key #<wx.Bitmap>
890
+ if not size:
891
+ size = (16, 16)
892
+ if key:
893
+ try:
894
+ art = Icon.custom_images.get(key)
895
+ bmp = art.GetBitmap()
896
+ except Exception:
897
+ art = Icon.provided_arts.get(key)
898
+ bmp = wx.ArtProvider.GetBitmap(art or key, wx.ART_OTHER, size)
899
+ return bmp
900
+
901
+ ## Note: null (0-shaped) bitmap fails with AssertionError from 4.1.1
902
+ elif key == '':
903
+ bmp = wx.Bitmap(size)
904
+ with wx.MemoryDC(bmp) as dc:
905
+ dc.SetBackground(wx.Brush('black'))
906
+ dc.Clear()
907
+ bmp.SetMaskColour('black') # return dummy-sized blank bitmap
908
+ return bmp
909
+
910
+ return wx.NullBitmap # The standard wx controls accept this,
911
+
912
+ @staticmethod
913
+ def _getBitmap2(back, fore, size=None, subsize=3/4):
914
+ if not size:
915
+ size = (16, 16)
916
+ if isinstance(subsize, float):
917
+ subsize = wx.Size(size) * subsize
918
+ back = Icon._getBitmap1(back, size)
919
+ fore = Icon._getBitmap1(fore, subsize)
920
+ x = size[0] - subsize[0]
921
+ y = size[1] - subsize[1]
922
+ with wx.MemoryDC(back) as dc:
923
+ ## dc = wx.GCDC(dc)
924
+ ## dc.DrawBitmap(fore, x, y, useMask=True)
925
+ gc = wx.GraphicsContext.Create(dc)
926
+ gc.DrawBitmap(fore, x, y, *subsize)
927
+ return back
928
+
929
+ @staticmethod
930
+ def bullet(colour, ec=None, size=None, radius=4):
931
+ if not size:
932
+ size = (16, 16)
887
933
  bmp = wx.Bitmap(size)
888
934
  with wx.MemoryDC(bmp) as dc:
889
935
  dc.SetBackground(wx.Brush('black'))
@@ -910,55 +956,24 @@ class Icon(wx.Bitmap):
910
956
  return bmp
911
957
 
912
958
 
913
- def _getBitmap1(key, size=(16,16)):
914
- if isinstance(key, wx.Bitmap):
915
- if key.Size != size:
916
- key = (key.ConvertToImage()
917
- .Scale(*size, wx.IMAGE_QUALITY_NEAREST)
918
- .ConvertToBitmap())
919
- return key
920
- if key:
921
- try:
922
- art = _custom_images.get(key)
923
- bmp = art.GetBitmap()
924
- except Exception:
925
- art = _provided_arts.get(key)
926
- bmp = wx.ArtProvider.GetBitmap(art or key, wx.ART_OTHER, size)
927
- return bmp
928
-
929
- ## Note: null (0-shaped) bitmap fails with AssertionError from 4.1.1
930
- elif key == '':
931
- bmp = wx.Bitmap(size)
932
- with wx.MemoryDC(bmp) as dc:
933
- dc.SetBackground(wx.Brush('black'))
934
- dc.Clear()
935
- bmp.SetMaskColour('black') # return dummy-sized blank bitmap
936
- return bmp
959
+ class ClassicButton(wx.Button):
960
+ """Flat button
937
961
 
938
- return wx.NullBitmap # The standard wx controls accept this,
939
-
940
-
941
- def _getBitmap2(back, fore, size=(16,16), subsize=3/4):
942
- if isinstance(subsize, float):
943
- subsize = wx.Size(size) * subsize
944
- back = _getBitmap1(back, size)
945
- fore = _getBitmap1(fore, subsize)
946
- x = size[0] - subsize[0]
947
- y = size[1] - subsize[1]
948
- with wx.MemoryDC(back) as dc:
949
- ## dc = wx.GCDC(dc)
950
- ## dc.DrawBitmap(fore, x, y, useMask=True)
951
- gc = wx.GraphicsContext.Create(dc)
952
- gc.DrawBitmap(fore, x, y, *subsize)
953
- return back
954
-
955
-
956
- def _Icon(v):
957
- if isinstance(v, (str, bytes)):
958
- return Icon(v)
959
- if isinstance(v, wx.lib.embeddedimage.PyEmbeddedImage):
960
- return v.GetBitmap()
961
- return v
962
+ Args:
963
+ label : button label
964
+ handler : event handler when the button is pressed
965
+ icon : key:str or bitmap for button icon
966
+ **kwargs: keywords for wx.lib.platebtn.PlateButton
967
+ """
968
+ def __init__(self, parent, label='', handler=None, icon=None, **kwargs):
969
+ wx.Button.__init__(self, parent, -1, label, **kwargs)
970
+
971
+ if handler:
972
+ self.Bind(wx.EVT_BUTTON, _F(handler))
973
+
974
+ self.SetToolTip(_Tip(handler.__doc__))
975
+ if icon:
976
+ self.SetBitmap(Icon(icon))
962
977
 
963
978
 
964
979
  class Button(pb.PlateButton):
@@ -970,17 +985,6 @@ class Button(pb.PlateButton):
970
985
  icon : key:str or bitmap for button icon
971
986
  **kwargs: keywords for wx.lib.platebtn.PlateButton
972
987
  """
973
- @property
974
- def icon(self):
975
- """Icon key:str or bitmap."""
976
- return self.__icon
977
-
978
- @icon.setter
979
- def icon(self, v):
980
- self.__icon = v
981
- self.SetBitmap(_Icon(v))
982
- self.Refresh()
983
-
984
988
  def __init__(self, parent, label='', handler=None, icon=None, **kwargs):
985
989
  kwargs.setdefault('style', pb.PB_STYLE_DEFAULT | pb.PB_STYLE_SQUARE)
986
990
  pb.PlateButton.__init__(self, parent, -1, label, **kwargs)
@@ -988,8 +992,9 @@ class Button(pb.PlateButton):
988
992
  if handler:
989
993
  self.Bind(wx.EVT_BUTTON, _F(handler))
990
994
 
991
- self.ToolTip = _Tip(handler.__doc__)
992
- self.icon = icon
995
+ self.SetToolTip(_Tip(handler.__doc__))
996
+ if icon:
997
+ self.SetBitmap(Icon(icon))
993
998
 
994
999
  def SetBitmap(self, bmp):
995
1000
  """Set the bitmap displayed in the button.
@@ -998,7 +1003,8 @@ class Button(pb.PlateButton):
998
1003
  try:
999
1004
  pb.PlateButton.SetBitmap(self, bmp)
1000
1005
  except Exception:
1001
- self._bmp = dict(enable=None, disable=None)
1006
+ self._bmp['enable'] = None
1007
+ self._bmp['disable'] = None
1002
1008
 
1003
1009
 
1004
1010
  class ToggleButton(wx.ToggleButton):
@@ -1013,29 +1019,19 @@ class ToggleButton(wx.ToggleButton):
1013
1019
  Note:
1014
1020
  To get the status, check Value or event.GetInt or event.IsChecked.
1015
1021
  """
1016
- @property
1017
- def icon(self):
1018
- """Icon key:str or bitmap."""
1019
- return self.__icon
1020
-
1021
- @icon.setter
1022
- def icon(self, v):
1023
- self.__icon = v
1024
- if isinstance(v, tuple):
1025
- self.SetBitmap(_Icon(v[0]))
1026
- self.SetBitmapPressed(_Icon(v[1]))
1027
- elif v:
1028
- self.SetBitmap(_Icon(v))
1029
- self.Refresh()
1030
-
1031
1022
  def __init__(self, parent, label='', handler=None, icon=None, **kwargs):
1032
1023
  wx.ToggleButton.__init__(self, parent, -1, label, **kwargs)
1033
1024
 
1034
1025
  if handler:
1035
1026
  self.Bind(wx.EVT_TOGGLEBUTTON, _F(handler))
1036
1027
 
1037
- self.ToolTip = _Tip(handler.__doc__)
1038
- self.icon = icon
1028
+ self.SetToolTip(_Tip(handler.__doc__))
1029
+ if icon:
1030
+ try:
1031
+ self.SetBitmap(Icon(icon[0]))
1032
+ self.SetBitmapPressed(Icon(icon[1]))
1033
+ except Exception:
1034
+ self.SetBitmap(Icon(icon))
1039
1035
 
1040
1036
 
1041
1037
  class TextCtrl(wx.Control):
@@ -1057,15 +1053,6 @@ class TextCtrl(wx.Control):
1057
1053
 
1058
1054
  value = Value #: internal use only
1059
1055
 
1060
- @property
1061
- def icon(self):
1062
- """Icon key:str or bitmap."""
1063
- return self._btn.icon
1064
-
1065
- @icon.setter
1066
- def icon(self, v):
1067
- self._btn.icon = v
1068
-
1069
1056
  def __init__(self, parent, label='', handler=None, updater=None,
1070
1057
  icon=None, readonly=False, size=(-1,-1), **kwargs):
1071
1058
  wx.Control.__init__(self, parent, size=size, style=wx.BORDER_NONE)
@@ -1077,8 +1064,8 @@ class TextCtrl(wx.Control):
1077
1064
  self._ctrl = wx.TextCtrl(self, **kwargs)
1078
1065
  self._btn = Button(self, label, None, icon,
1079
1066
  size=(-1,-1) if label or icon else (0,0))
1080
- self._ctrl.ToolTip = _Tip(handler.__doc__)
1081
- self._btn.ToolTip = _Tip(updater.__doc__)
1067
+ self._ctrl.SetToolTip(_Tip(handler.__doc__))
1068
+ self._btn.SetToolTip(_Tip(updater.__doc__))
1082
1069
 
1083
1070
  self.SetSizer(
1084
1071
  pack(self, (
@@ -1134,15 +1121,6 @@ class Choice(wx.Control):
1134
1121
  lambda self,v: self._ctrl.SetItems(v),
1135
1122
  doc="combobox items:list")
1136
1123
 
1137
- @property
1138
- def icon(self):
1139
- """Icon key:str or bitmap."""
1140
- return self._btn.icon
1141
-
1142
- @icon.setter
1143
- def icon(self, v):
1144
- self._btn.icon = v
1145
-
1146
1124
  def __init__(self, parent, label='', handler=None, updater=None,
1147
1125
  icon=None, readonly=False, size=(-1,-1), **kwargs):
1148
1126
  wx.Control.__init__(self, parent, size=size, style=wx.BORDER_NONE)
@@ -1154,8 +1132,8 @@ class Choice(wx.Control):
1154
1132
  self._ctrl = wx.ComboBox(self, **kwargs)
1155
1133
  self._btn = Button(self, label, None, icon,
1156
1134
  size=(-1,-1) if label or icon else (0,0))
1157
- self._ctrl.ToolTip = _Tip(handler.__doc__)
1158
- self._btn.ToolTip = _Tip(updater.__doc__)
1135
+ self._ctrl.SetToolTip(_Tip(handler.__doc__))
1136
+ self._btn.SetToolTip(_Tip(updater.__doc__))
1159
1137
 
1160
1138
  self.SetSizer(
1161
1139
  pack(self, (
mwx/framework.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #! python3
2
2
  """mwxlib framework.
3
3
  """
4
- __version__ = "0.99.8"
4
+ __version__ = "0.99.9"
5
5
  __author__ = "Kazuya O'moto <komoto@jeol.co.jp>"
6
6
 
7
7
  from contextlib import contextmanager
mwx/matplot2.py CHANGED
@@ -387,7 +387,7 @@ class MatplotPanel(wx.Panel):
387
387
  def on_modeline_tip(self, evt): #<wx._core.MouseEvent>
388
388
  flag = self.modeline.HitTest(evt.Position)
389
389
  if flag == wx.HT_WINDOW_INSIDE:
390
- self.modeline.ToolTip = self.modeline.Label
390
+ self.modeline.SetToolTip(self.modeline.Label)
391
391
  evt.Skip()
392
392
 
393
393
  def on_focus_set(self, evt): #<wx._core.FocusEvent>
mwx/utilus.py CHANGED
@@ -43,6 +43,8 @@ def warn(message, category=None):
43
43
  stacklevel = 1
44
44
  while frame.f_code.co_filename in skip:
45
45
  frame = frame.f_back
46
+ if not frame:
47
+ break
46
48
  stacklevel += 1
47
49
  return warnings.warn(message, category, stacklevel+1)
48
50
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mwxlib
3
- Version: 0.99.8
3
+ Version: 0.99.9
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,15 +1,15 @@
1
- mwx/__init__.py,sha256=U7n9X8JAWdzOavKvVqecHdE4ooiXcCB5DSPCKWxfTnY,653
1
+ mwx/__init__.py,sha256=psabnAMei5VzB2TsB2qBNLrIZMX0LiqjlXCpNGmDejk,668
2
2
  mwx/bookshelf.py,sha256=so-xSLq08sMlJBErTxOaDoKUAMa_g1CkIP2pNnff68c,5607
3
- mwx/controls.py,sha256=5RDA9YgxrxCmjrHOU6XgA_5tcOU1UEwqU4tFEuBNcrk,47648
4
- mwx/framework.py,sha256=lxqSl_IrGp7ZAUPKJWP5JaUUm3vhaOCjAujFVPocPXg,75501
3
+ mwx/controls.py,sha256=LZqee9K8uPxs-Iqcp1zMMNBjFpGPrHbcMaIBuBOL7oo,47647
4
+ mwx/framework.py,sha256=nJ22_22Hk2U8xSbHOszluJdSMDwYsw6XjI3lOiprcJc,75501
5
5
  mwx/graphman.py,sha256=qX5aHEw4u9iGR8lNpZkXDnGPVMhyAH6NnBapiaUbKZw,70265
6
6
  mwx/images.py,sha256=_-Eh3xF7Khu42ivkYp97NXIzSNGbjcidqtWjZQFGtqE,47827
7
- mwx/matplot2.py,sha256=xCJ_ZzdDEWmzctpPaOrzTnwXyHINP4nfFHweoTZa6ug,32899
7
+ mwx/matplot2.py,sha256=zA56jIdRUdzu-wrmPai1PSOjzqV2Erqw2yFKW-jwdA8,32901
8
8
  mwx/matplot2g.py,sha256=gCXa8X1MEMP7n_mG73h3SkWKuNZOfjVKUTWNRXXK11c,64310
9
9
  mwx/matplot2lg.py,sha256=JRWjWnLJUytbSq6wxs4P0gbVUr3xoLSF6Wwqd5V_pJI,27404
10
10
  mwx/mgplt.py,sha256=M5rt-H7Uq1OHnlFvMA4a3945UBvppbR9L_mw8NL_YZ0,5602
11
11
  mwx/nutshell.py,sha256=zJULq1K8WiOBUncMpXE8HbunqUULa9MUt0hBET5jmgs,141810
12
- mwx/utilus.py,sha256=iizdVrbwL1lX7eTfsMmltFz4IfHqTXVM37wwlPQ3A3Y,37346
12
+ mwx/utilus.py,sha256=Yyw8L1f-ikhyd7wtFXYtsOswofWxmB4GAmLOZnhUXeU,37388
13
13
  mwx/wxmon.py,sha256=yzWqrbY6LzpfRwQeytYUeqFhFuLVm_XEvrVAL_k0HBQ,12756
14
14
  mwx/wxpdb.py,sha256=lLowkkAgMhPFHAfklD7wZHq0qbSMjRxnBFtSajmVgME,19133
15
15
  mwx/wxwil.py,sha256=hhyB1lPrF9ixeObxCOKQv0Theu-B-kpJg_yVU3EGSNg,5406
@@ -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.8.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
25
- mwxlib-0.99.8.dist-info/METADATA,sha256=C8n66k4LeYcPBb91oVSh7D68pfZI2d1JteEJn3F4UQU,7411
26
- mwxlib-0.99.8.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
27
- mwxlib-0.99.8.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
28
- mwxlib-0.99.8.dist-info/RECORD,,
24
+ mwxlib-0.99.9.dist-info/LICENSE,sha256=PGtRKCaTkmUDlBQwpptJAxJtdqxIUtAmdBsaT9nUVkA,1091
25
+ mwxlib-0.99.9.dist-info/METADATA,sha256=1-yAjrG-AehfMfbbEyPN3eMtrGErVkNft7OHtTkwSU0,7411
26
+ mwxlib-0.99.9.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
27
+ mwxlib-0.99.9.dist-info/top_level.txt,sha256=SI1Mh118AstnUFGPNq5aMNKiAnVNmZk1S9Ij-OwAEpY,4
28
+ mwxlib-0.99.9.dist-info/RECORD,,