| Home | Trees | Index | Help |
|---|
| Package ocempgui :: Package widgets :: Module Button :: Class Button |
|
object--+ |INotifyable--+ |BaseObject--+ |object--+ | | |Sprite--+ |BaseWidget--+ |Bin--+ |ButtonBase--+ | Button
Button (text=None) -> Button ()
A widget class, which can react upon mouse events.
The Button widget can listen to mouse events such as clicks or a pressed button and can display a short text.
The text to display on the Button can be set using the 'text' attribute or the set_text() method. The text is displayed using a Label widget, which is placed upon the Button surface, thus all text capabilities of the Label, such as mnemonics, can be applied to the Button as well.
button.text = '#Click me' # Use the C character as mnemonic. button.text = 'Button' # A simple text. button.set_text ('Button ##1') # Creates the text 'Button #1'
To operate on the displayed Label directly (which is NOT recommended), the 'child' attribute and set_child() method can be used. They have a slightly different behaviour than the methods of the ButtonBase class and allow only Label widgets to be assigned to the Button. Additionally the Label its 'widget' attribute will be bound to the Button.
button.child = Label ('#Button') button.set_child (None)
The Button supports different border types by setting its 'border' attribute to a valid value of the BORDER_TYPES constants.
button.border = BORDER_SUNKEN button.set_border (BORDER_SUNKEN)
Note: Changing the 'state' attribute of the Button will also affect the state of the Label placed on the Button.
Default action (invoked by activate()): See the ButtonBase class.
Mnemonic action (invoked by activate_mnemonic()): See the ButtonBase class.
Attributes: text - The text to display on the Button. border - The border style to set for the Button.| Method Summary | |
|---|---|
__init__(self,
text)
| |
B.draw () -> None | |
B.draw_bg () -> Surface | |
B.get_text () -> string | |
B.set_border (...) -> None | |
B.set_child (...) -> None | |
B.set_state (...) -> None | |
B.set_text (...) -> None | |
| Inherited from ButtonBase | |
B.activate () -> None | |
B.activate_mnemonic (...) -> bool | |
B.notify (...) -> None | |
| Inherited from Bin | |
B.destroy () -> None | |
B.set_depth (...) -> None | |
B.set_event_manager (...) -> None | |
B.set_indexable (...) -> None | |
B.set_padding (...) -> None | |
B.set_sensitive (...) -> None | |
B.update (...) -> None | |
| Inherited from BaseWidget | |
W.check_sizes (...) -> int, int | |
W.create_style () -> WidgetStyle | |
For debugging usage only | |
W.get_style () -> WidgetStyle | |
B.initclass () -> None (Class method) | |
W.lock () -> None | |
W.rect_to_client (...) -> pygame.Rect | |
W.set_dirty (...) -> None | |
W.set_entered (...) -> None | |
W.set_event_area (...) -> None | |
W.set_focus (...) -> bool | |
W.set_index (...) -> None | |
W.set_maximum_size (...) -> None | |
W.set_minimum_size (...) -> None | |
W.set_opacity (...) -> None | |
W.set_position (...) -> None | |
W.set_size (...) -> None | |
W.set_style (...) -> None | |
W.set_tooltip (...) -> None | |
W.unlock () -> None | |
W._get_rect () -> pygame.Rect | |
W._get_rect_attr (...) -> var | |
W._set_rect_attr (...) -> None | |
| Inherited from BaseObject | |
B.connect_signal (...) -> EventCallback | |
B.disconnect_signal (...) -> None | |
B.emit (...) -> bool | |
B.run_signal_handlers (...) -> None | |
| Inherited from Sprite | |
| |
add(group or list of of groups, ...) add a sprite to container | |
| |
alive() -> bool check to see if the sprite is in any groups | |
groups() -> list of groups list used sprite containers | |
kill() remove this sprite from all groups | |
remove(group or list of groups, ...) remove a sprite from container | |
| |
| Inherited from object | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
x.__hash__() <==> hash(x) | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
helper for pickle | |
helper for pickle | |
x.__setattr__('name', value) <==> x.name = value | |
x.__str__() <==> str(x) | |
| Property Summary | |
|---|---|
border: The border style to set for the Button. | |
text: The text of the Button. | |
| Inherited from Bin | |
child: The widget hold by the Bin. | |
padding: Additional padding between child and borders. | |
| Inherited from BaseWidget | |
bottom | |
bottomleft | |
bottomright | |
center | |
centerx | |
centery | |
controls: Widgets associated with the widget. | |
depth: The z-axis layer depth of the widget. | |
dirty: Indicates, whether the widget need to be redrawn. | |
entered: Indicates, whether the widget is entered. | |
eventarea: The area, which gets the events. | |
focus: The focus of the widget. | |
h | |
height | |
image: The visible surface of the widget. | |
index: The tab index position of the widget. | |
indexable: The IIndexable, the widget is attached to. | |
left | |
locked: Indicates, whether the widget is locked. | |
maxsize: The maximum size to occupy by the widget. | |
midbottom | |
midleft | |
midright | |
midtop | |
minsize: The guaranteed size of the widget. | |
opacity: The opacity of the widget. | |
position: The position of the topleft corner. | |
rect: The area occupied by the widget. | |
right | |
sensitive: The sensitivity of the widget. | |
size | |
state: The current state of the widget. | |
style: The style of the widget. | |
tooltip: The tool tip text to display for the widget. | |
top | |
topleft | |
topright | |
w | |
width | |
x | |
y | |
| Inherited from BaseObject | |
manager: The event manager to use by the object. | |
| Instance Method Details |
|---|
draw(self)B.draw () -> None Draws the Button surface and places its Label on it.
|
draw_bg(self)B.draw_bg () -> Surface Draws the Button background surface and returns it. Creates the visible surface of the Button and returns it to the caller. |
get_text(self)B.get_text () -> string Returns the set text of the Button. Returns the text set on the Label of the Button. |
set_border(self, border)B.set_border (...) -> None Sets the border type to be used by the Button. Raises a ValueError, if the passed argument is not a value from BORDER_TYPES |
set_child(self, child=None)B.set_child (...) -> None Sets the Label to display on the Button. Creates a parent-child relationship from the Button to a Label and causes the Label to set its mnemonic widget to the Button. Raises a TypeError, if the passed argument does not inherit from the Label class.
|
set_state(self, state)B.set_state (...) -> None Sets the state of the Button. Sets the state of the Button and causes its child to set its state to the same value. |
set_text(self, text=None)B.set_text (...) -> None Sets the text to display on the Button. Sets the text to display on the Button by referring to the 'text' attribute of its child Label. |
| Property Details |
|---|
borderThe border style to set for the Button.
|
textThe text of the Button.
|
| Home | Trees | Index | Help |
|---|
| Generated by Epydoc 2.1 on Thu Jan 10 10:18:43 2008 | http://epydoc.sf.net |