Package wx :: Package lib :: Package agw :: Module shapedbutton

[frames | no frames]

## Module wx.lib.agw.shapedbutton

Description:

ShapedButton tries to fill the lack of "custom shaped" controls in wxPython (that depends on the same lack in wxWidgets). It can be used to build round buttons or elliptic buttons.

I have stolen some code from wx.lib.buttons in order to recreate the same classes (GenButton, GenBitmapButton, GenBitmapTextButton, GenToggleButton, GenBitmapToggleButton, GenBitmapTextToggleButton). Here you have the same classes (with "Gen" replaced by "S"), with the same event handling, but they are rounded/elliptical buttons.

ShapedButton is based on a wx.Window, in which 2 images are drawn depending on the button state (pressed or not pressed). The 2 images have been stolen from Audacity (written with wxWidgets) and rearranged/reshaped/restyled using adobe PhotoShop. Changing the button colour in runtime was more difficult, but using some intelligent instruction from the PIL library it can be done.

ShapedButton reacts on mouse events only if the mouse event occurred inside the circle/ellipse, even if ShapedButton is built on a rectangular window. This behavior is a lot different with respect to Audacity round buttons.

Usage:

The ShapedButton constructions, excluding wxPython parameter are, for the 6 Classes:

MyShapedButton = SButton(parent,
  label)
MyShapedButton = SBitmapButton(parent,
  bitmap)
MyShapedButton = SBitmapTextButton(parent,
  bitmap, label)
MyShapedButton = SToggleButton(parent,
  label)
MyShapedButton = SBitmapToggleButton(parent,
  bitmap)
MyShapedButton = SBitmapTextToggleButton(parent,
  bitmap, label)

The ShapedButton construction and usage is quite similar to the wx.lib.buttons implementation. For the full listing of the input parameters, see the ShapedButton __init__() method.

Methods and Settings:

With ShapedButton you can:

- create rounded/elliptical buttons/togglebuttons;
- Set images for the enabled/disabled/focused/selected state of the button;
- Draw the focus indicator (or disable it);
- Set label colour and font;
- Apply a rotation to the ShapedButton label;
- Change ShapedButton shape and text orientation in runtime.

For more info on methods and initial styles, please refer to the __init__() method for ShapedButton or to the specific functions.

|=========================================================================== | | NOTE: ShapedButton requires PIL (Python Imaging Library) library to | | be installed. | |=========================================================================== |

ShapedButton control is freeware and distributed under the wxPython license.

Latest revision: Andrea Gavana @ 15 Oct 2008, 10.00 GMT Version 0.3

Classes
`SBitmapButton` |
`SBitmapTextButton` |
`SBitmapTextToggleButton` | A ShapedButton toggle bitmap button with a text label.
`SBitmapToggleButton` | A ShapedButton toggle bitmap button.
`SButton` |
`SButtonEvent` | Event sent from the generic buttons when the button is activated.
`SToggleButton` | A ShapedButton toggle button.

Function Summary
| ``opj`(path)` Convert paths to the platform-specific separator.

Function Details

### opj(path)

Convert paths to the platform-specific separator.

Generated by Epydoc 2.1.20050511.rpd on Mon Feb 16 12:52:41 2009 | http://epydoc.sf.net