AGW Logo

svn SVN Revision 68881 For buttonbar

This file contains the SVN revision history for buttonbar, at revision 68881.

Available information include commit date, the name of the committer, the file size, the SVN log messages and a diff from the previous version (if available).


file_info File Information

  • Commit Date: 10-Dec-2009 18:09:38 UTC
  • Committer: AG
  • File Size: 34686 byte(s)

svn_log Log Messages

The following log message was entered by the committer:

  • AGW: General overhaul of the documentation, much improved. All the widgets have their own sample usage in the docs as well;

  • FlatNotebook: Added the FNB_NAV_BUTTONS_WHEN_NEEDED style, which hides the navigation left/right arrows if all tabs fit;

  • RibbonBar: - Added the EVT_RIBBONBAR_TAB_LEFT_DCLICK event, which generates a special event

    when a ribbon bar tab is double-clicked;

    • Added support for toggle buttons;
    • Improved support for ribbon panel sizers: panels with sizers should now automatically minimise at small sizes, and behave properly when popping up from a minimised state;
    • Added tooltips via SetToolTip for those buttons which have the help_string attribute set.
  • XLSGrid: a new widget was added to AGW, termed XLSGrid. It’s based on wx.grid.Grid and can be used to faithfully reproduce the appearance of a Microsoft Excel spreadsheets.


svn_diff Diff To Previous Version (65529)

Version SVN diff:

--- wxPython/3rdParty/AGW/agw/ribbon/buttonbar.py   2010/09/12 11:58:40     65529
+++ wxPython/3rdParty/AGW/agw/ribbon/buttonbar.py   2011/08/25 16:40:17     68881
@@ -206,12 +206,12 @@
"""
Default class constructor.

-        :param `parent`: Pointer to a parent window;
-        :param `id`: Window identifier. If ``wx.ID_ANY``, will automatically create
+        :param `parent`: pointer to a parent window;
+        :param `id`: window identifier. If ``wx.ID_ANY``, will automatically create
an identifier;
-        :param `pos`: Window position. ``wx.DefaultPosition`` indicates that wxPython
+        :param `pos`: window position. ``wx.DefaultPosition`` indicates that wxPython
should generate a default position for the window;
-        :param `size`: Window size. ``wx.DefaultSize`` indicates that wxPython should
+        :param `size`: window size. ``wx.DefaultSize`` indicates that wxPython should
generate a default size for the window. If no suitable size can be found, the
window will be sized to 20x20 pixels so that the window is visible but obviously
not correctly sized;
@@ -238,11 +238,11 @@
"""
Add a button to the button bar (simple version).

-        :param `button_id`: ID of the button to enable or disable;
-        :param `label`: Label of the new button;
-        :param `bitmap`: Large bitmap of the new button. Must be the same size as
+        :param `button_id`: ID of the button;
+        :param `label`: label of the new button;
+        :param `bitmap`: large bitmap of the new button. Must be the same size as
all other large bitmaps used on the button bar;
-        :param `help_string`: The UI help string to associate with the new button;
+        :param `help_string`: the UI help string to associate with the new button;
:param `kind`: The kind of button to add.

"""
@@ -255,11 +255,11 @@
"""
Add a dropdown button to the button bar (simple version).

-        :param `button_id`: ID of the button to enable or disable;
-        :param `label`: Label of the new button;
-        :param `bitmap`: Large bitmap of the new button. Must be the same size as
+        :param `button_id`: ID of the button;
+        :param `label`: label of the new button;
+        :param `bitmap`: large bitmap of the new button. Must be the same size as
all other large bitmaps used on the button bar;
-        :param `help_string`: The UI help string to associate with the new button.
+        :param `help_string`: the UI help string to associate with the new button.

:see: L{AddButton}
"""
@@ -271,11 +271,11 @@
"""
Add a hybrid button to the button bar (simple version).

-        :param `button_id`: ID of the button to enable or disable;
-        :param `label`: Label of the new button;
-        :param `bitmap`: Large bitmap of the new button. Must be the same size as
+        :param `button_id`: ID of the button;
+        :param `label`: label of the new button;
+        :param `bitmap`: large bitmap of the new button. Must be the same size as
all other large bitmaps used on the button bar;
-        :param `help_string`: The UI help string to associate with the new button.
+        :param `help_string`: the UI help string to associate with the new button.

:see: L{AddButton}
"""
@@ -289,19 +289,19 @@
Add a button to the button bar.

:param `button_id`: ID of the new button (used for event callbacks);
-        :param `label`: Label of the new button;
-        :param `bitmap`: Large bitmap of the new button. Must be the same size as
+        :param `label`: label of the new button;
+        :param `bitmap`: large bitmap of the new button. Must be the same size as
all other large bitmaps used on the button bar;
-        :param `bitmap_small`: Small bitmap of the new button. If left as ``None``,
+        :param `bitmap_small`: small bitmap of the new button. If left as ``None``,
then a small bitmap will be automatically generated. Must be the same size
as all other small bitmaps used on the button bar;
-        :param `bitmap_disabled`: Large bitmap of the new button when it is disabled.
+        :param `bitmap_disabled`: large bitmap of the new button when it is disabled.
If left as ``None``, then a bitmap will be automatically generated from `bitmap`;
-        :param `bitmap_small_disabled`: Small bitmap of the new button when it is disabled.
+        :param `bitmap_small_disabled`: small bitmap of the new button when it is disabled.
If left as ``None``, then a bitmap will be automatically generated from `bitmap_small`;
-        :param `kind`: The kind of button to add;
-        :param `help_string`: The UI help string to associate with the new button;
-        :param `client_data`: Client data to associate with the new button.
+        :param `kind`: the kind of button to add;
+        :param `help_string`: the UI help string to associate with the new button;
+        :param `client_data`: client data to associate with the new button.

:returns: An opaque pointer which can be used only with other button bar methods.

@@ -309,8 +309,11 @@
"""

if not bitmap.IsOk() and not bitmap_small.IsOk():
-            raise Exception("exception")
-
+            raise Exception("Invalid main bitmap")
+
+        if not isinstance(help_string, basestring):
+            raise Exception("Invalid help string parameter")
+
if not self._buttons:
if bitmap.IsOk():

@@ -372,6 +375,22 @@
return base


+    def AddToggleButton(self, button_id, label, bitmap, help_string=""):
+        """
+        Add a toggle button to the button bar.
+
+        :param `button_id`: ID of the button;
+        :param `label`: label of the new button;
+        :param `bitmap`: large bitmap of the new button. Must be the same size as
+         all other large bitmaps used on the button bar;
+        :param `help_string`: the UI help string to associate with the new button.
+
+        :see: L{AddButton}
+        """
+
+        return self.AddButton(button_id, label, bitmap, help_string, RIBBON_BUTTON_TOGGLE)
+
+
def FetchButtonSizeInfo(self, button, size, dc):

info = button.sizes[size]
@@ -407,8 +426,7 @@
added buttons will not be displayed. In normal situations, it will be called
automatically when L{RibbonBar.Realize} is called.

-        Reimplemented from L{RibbonControl}.
-
+        :note: Reimplemented from L{RibbonControl}.
"""

if not self._layouts_valid:
@@ -434,7 +452,7 @@
"""
Delete a single button from the button bar.

-        :param `button_id`: ID of the button to enable or disable.
+        :param `button_id`: ID of the button to delete.

:see: L{ClearButtons}
"""
@@ -456,7 +474,6 @@

:param `button_id`: ID of the button to enable or disable;
:param `enable`: ``True`` to enable the button, ``False`` to disable it.
-
"""

for button in self._buttons:
@@ -473,6 +490,28 @@
return


+    def ToggleButton(self, button_id, checked=True):
+        """
+        Toggles/untoggles a L{RibbonButtonBar} toggle button.
+
+        :param `button_id`: ID of the button to be toggles/untoggled;
+        :param `checked`: ``True`` to toggle the button, ``False`` to untoggle it.
+        """
+
+        for button in self._buttons:
+            if button.id == button_id:
+                if checked:
+                    if button.state & RIBBON_BUTTONBAR_BUTTON_TOGGLED == 0:
+                        button.state |= RIBBON_BUTTONBAR_BUTTON_TOGGLED
+                        self.Refresh()
+                else:
+                    if button.state & RIBBON_BUTTONBAR_BUTTON_TOGGLED:
+                        button.state &= ~RIBBON_BUTTONBAR_BUTTON_TOGGLED
+                        self.Refresh()
+
+                return
+
+
def IsButtonEnabled(self, button_id):
"""
Returns whether a button in the bar is enabled or not.
@@ -805,7 +844,10 @@
new_hovered_state |= RIBBON_BUTTONBAR_BUTTON_DROPDOWN_HOVERED

break
-
+
+        if new_hovered == None and self.GetToolTip():
+            self.SetToolTipString("")
+
if new_hovered != self._hovered_button or (self._hovered_button != None and \
new_hovered_state != self._hovered_button.base.state):

@@ -815,6 +857,7 @@
self._hovered_button = new_hovered
if self._hovered_button != None:
self._hovered_button.base.state = new_hovered_state
+                self.SetToolTipString(self._hovered_button.base.help_string)

self.Refresh(False)

@@ -892,7 +935,13 @@
event_type = wxEVT_COMMAND_RIBBONBUTTON_DROPDOWN_CLICKED
else:
break
+
notification = RibbonButtonBarEvent(event_type, id)
+
+                    if self._active_button.base.kind == RIBBON_BUTTON_TOGGLE:
+                        self._active_button.base.state ^= RIBBON_BUTTONBAR_BUTTON_TOGGLED
+                        notification.SetInt(self._active_button.base.state & RIBBON_BUTTONBAR_BUTTON_TOGGLED)
+
notification.SetEventObject(self)
notification.SetBar(self)
self._lock_active_state = True
Tree

Table Of Contents

Previous topic

RibbonButtonBarLayout

Next topic

SVN Revision 69086 For buttonbar