mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-12-16 09:40:07 +01:00
Revert "New button type: ShowHideToggleButton."
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user