From e53b09aea7f702242e07fbda487abb9f6431f9a5 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 15 Dec 2021 18:10:12 -0800 Subject: [PATCH] Revert "New button type: ShowHideToggleButton." --- demo/GenericButtons.py | 6 -- wx/lib/buttons.py | 140 ----------------------------------------- 2 files changed, 146 deletions(-) diff --git a/demo/GenericButtons.py b/demo/GenericButtons.py index 78e0f267..86668df9 100644 --- a/demo/GenericButtons.py +++ b/demo/GenericButtons.py @@ -140,12 +140,6 @@ class TestPanel(wx.Panel): self.Bind(wx.EVT_BUTTON, self.OnButton, b) vbox.Add(b, 0, wx.ALL, 5) - # A toggle button to show/hide an associated wx.Window object - w = buttons.GenButton(self, -1, label="Button") - b = buttons.GenShowHideToggleButton(self, -1, label='Show/Hide Button', menu=w) - vbox.Add(b, 0, wx.ALL, 5) - vbox.Add(w, 0, wx.ALL, 5) - border = wx.BoxSizer(wx.VERTICAL) diff --git a/wx/lib/buttons.py b/wx/lib/buttons.py index 9c165ed0..c69e623c 100644 --- a/wx/lib/buttons.py +++ b/wx/lib/buttons.py @@ -60,7 +60,6 @@ Sample usage:: import wx import wx.lib.imageutils as imageutils -import wx.lib.colourutils as colourutils #---------------------------------------------------------------------- @@ -1071,141 +1070,6 @@ class GenBitmapTextToggleButton(__ToggleMixin, GenBitmapTextButton): """ A generic toggle bitmap button with text label. """ pass -class GenShowHideToggleButton(GenToggleButton): - """ A generic toggle bitmap button with an associated wx.Window object to show/hide on toggle. """ - def __init__(self, *args, menu, **kwargs): - GenToggleButton.__init__(self, *args, **kwargs) - self.SetMenu(menu) - self.nctvBgClr = self.GetBackgroundColour() - self.nctvFgClr = colourutils.BestLabelColour(self.nctvBgClr, bw=True) - self.actvBgClr = colourutils.GetHighlightColour() - self.actvFgClr = colourutils.BestLabelColour(self.actvBgClr, bw=True) - self.Bind(wx.EVT_TOGGLEBUTTON, self._OnToggle) - - def GetInactiveBackgroundColour(self): - """ - Returns the :class:`GenShowHideToggleButton` inactive background colour. - """ - return self.nctvBgClr - - def SetInactiveBackgroundColour(self, colour): - """ - Sets the :class:`GenShowHideToggleButton` inactive background colour. - - :param `colour`: a valid :class:`wx.Colour` object. - - .. note:: Overridden from :class:`wx.GenButton`. - """ - self.nctvBgClr = wx.Colour(colour) - self.Update() - - def GetInactiveForegroundColour(self): - """ - Returns the :class:`GenShowHideToggleButton` inactive foreground colour. - """ - return self.nctvFgClr - - def SetInactiveForegroundColour(self, colour): - """ - Sets the :class:`GenShowHideToggleButton` inactive foreground colour. - - :param `colour`: a valid :class:`wx.Colour` object. - - .. note:: Overridden from :class:`wx.GenButton`. - """ - self.nctvFgClr = wx.Colour(colour) - self.Update() - - def GetActiveBackgroundColour(self): - """ - Returns the :class:`GenShowHideToggleButton` active background colour. - """ - return self.actvBgClr - - def SetActiveBackgroundColour(self, colour): - """ - Sets the :class:`GenShowHideToggleButton` active background colour. - - :param `colour`: a valid :class:`wx.Colour` object. - - .. note:: Overridden from :class:`wx.GenButton`. - """ - self.actvBgClr = wx.Colour(colour) - self.Update() - - def GetActiveForegroundColour(self): - """ - Returns the :class:`GenShowHideToggleButton` active foreground colour. - """ - return self.actvFgClr - - def SetActiveForegroundColour(self, colour): - """ - Sets the :class:`GenShowHideToggleButton` active foreground colour. - - :param `colour`: a valid :class:`wx.Colour` object. - - .. note:: Overridden from :class:`wx.GenButton`. - """ - self.actvFgClr = wx.Colour(colour) - self.Update() - - def Update(self): - """ - Update() - - Calling this method immediately repaints the invalidated area of the - window and all of its children recursively (this normally only happens - when the flow of control returns to the event loop). - """ - wx.Window.Update(self) - if self.GetToggle(): - self.SetBackgroundColour(self.actvBgClr) - self.SetForegroundColour(self.actvFgClr) - else: - self.SetBackgroundColour(self.nctvBgClr) - self.SetForegroundColour(self.nctvFgClr) - - def GetMenu(self): - """ - Returns the :class:`Window` or :class:`Sizer` associated with this :class:`GenShowHideToggleButton`. - """ - return self._Menu - - def SetMenu(self, menu): - """ - Sets the :class:`Window` or :class:`Sizer` associated with this :class:`GenShowHideToggleButton`, meaning - that it will be shown/hidden by :event:`EVT_TOGGLEBUTTON` events. - - :param `menu`: a :class:`Window` or :class:`Sizer` - - .. note:: Overridden from :class:`wx.GenButton`. - """ - assert isinstance(menu, wx.Window) or isinstance(menu, wx.Sizer) - self._Menu = menu - self.onToggle(self.GetToggle()) - - @property - def Menu(self): - """ - See :func:`GetMenu` and :func:`SetMenu` - """ - return self.GetMenu() - - @Menu.setter - def Menu(self, menu): - self.SetMenu(menu) - - def _OnToggle(self, event): - """ - Used internally - """ - state = event if isinstance(event, bool) else event.GetSelection() - self.Menu.Show(state) - self.Menu.GetContainingSizer.Layout() - self.Update() - return - #---------------------------------------------------------------------- @@ -1264,10 +1128,6 @@ class ThemedGenToggleButton(__ThemedMixin, GenToggleButton): """ A themed generic toggle button. """ pass -class ThemedGenShowHideToggleButton(__ThemedMixin, GenShowHideToggleButton): - """ A themed generic show/hide button. """ - pass - class ThemedGenBitmapToggleButton(__ThemedMixin, GenBitmapToggleButton): """ A themed generic toggle bitmap button. """ pass