Class Button
About :
A button is a graphic node acting as a traditional button widget It is a flat button
Functions
Function | summury |
---|---|
__init__(self, obj=None, label=’Button’, texture=None, texture_pushed=None, font=None, texture_background=None) | obj : the application key (more…) |
set_push_color(self, color=(0.8, 1.0, 0.8, 1)) | |
set_release_color(self, color=(1.0, 0.8, 0.8, 1)) | |
get_push_color(self) | |
get_release_color(self) | |
set_push_depth(self, depth=0.1) | |
get_push_depth(self) | |
set_label_max_len(self, l) | define the current max size to be reserved in GPU for text (more…) |
trim_background(self, u=0, v=0, U=1, V=1) | |
trim_icon(self, u=0, v=0, U=1, V=1) | |
trim_icon_pushed(self, u=0, v=0, U=1, V=1) | |
is_pushed(self) | returns if the button is pushed (True) or released (False) (more…) |
set_colors(self, pushed, release) | |
set_toggle(self, toggle=True) | makes the button behave as a toggle button. When pushed it is not released automatically (more…) |
add_fellow(self, button) | add fellow (friends !) when the button is pushed fellows are also activated (more…) |
add_antagonist(self, button) | add antagonist (radio button !) when the button is pushed antagonists are released and vice versa (more…) |
remove_antagonist(self, button) | remove an antagonist button (radio button !) when the button is pushed antagonists are released and vice versa (more…) |
remove_all_antagonist(self) | remove all the antagonist buttons (more…) |
remove_all_fellow(self) | remove all the fellow buttons (more…) |
set_layout(self) | set_layout : redraw the button in a correct layout (more…) |
set_layout_right(self) | set_layout : redraw the button in a correct layout for right direction (more…) |
set_layout_bottom(self) | set_layout : redraw the button in a correct layout for bottom direction (more…) |
set_layout_left(self) | set_layout : redraw the button in a correct layout for left direction (more…) |
set_layout_top(self) | set_layout : redraw the button in a correct layout for top direction (more…) |
set_texture(self, texture=None) | set the release state texture (more…) |
set_texture_pushed(self, texture=None) | set the pushed state texture (more…) |
set_background(self, texture=None) | set the background texture (more…) |
set_font(self, font=None, update=True) | set the font for label (more…) |
set_label(self, label) | set the label (more…) |
set_label_scale(self, scale=1) | Set a scale factor for label respect to icon size (more…) |
set_label_color(self, r=1, g=1, b=1, a=1) | set the color for the text (more…) |
set_direction(self, direction=0) | set the relative position of label respect to the icon (more…) |
push(self, propagate=True) | realize the push action (more…) |
release(self, propagate=True) | realize the release action (more…) |
show_label(self, show=True) | show/hide label (more…) |
show_icon(self, show=True) | show/hide icon (more…) |
show_background(self, show=True) | show/hide background (more…) |
on_shot(self, device=None, picked={}) | callback when a device shot the button (more…) |
on_unshot(self, device=None, picked={}) | callback when a device unshot the button (more…) |
on_move(self, device=None, previous_pick={}, current_pick={}) | callback when a device move other the button (more…) |
Methods desciption :
init
def __init__(self, obj=None, label='Button', texture=None, texture_pushed=None, font=None, texture_background=None)
- → obj : the application key
- → label : label string
- → texture : pixmap drawn when the button is released
- → texture_pushed : pixmap drawn when the button is pushed
- → font : font used for the label
- → texture_background : texture used to draw the overall background
set_push_color
def set_push_color(self, color=(0.8, 1.0, 0.8, 1))
set_release_color
def set_release_color(self, color=(1.0, 0.8, 0.8, 1))
get_push_color
def get_push_color(self)
get_release_color
def get_release_color(self)
set_push_depth
def set_push_depth(self, depth=0.1)
get_push_depth
def get_push_depth(self)
set_label_max_len
def set_label_max_len(self, l)
define the current max size to be reserved in GPU for text it is the max of the given size and the current len +1 It avoids recompilation when the text changed unless text overpass the current limit
trim_background
def trim_background(self, u=0, v=0, U=1, V=1)
trim_icon
def trim_icon(self, u=0, v=0, U=1, V=1)
trim_icon_pushed
def trim_icon_pushed(self, u=0, v=0, U=1, V=1)
is_pushed
def is_pushed(self)
returns if the button is pushed (True) or released (False)
- ← pushed state
set_colors
def set_colors(self, pushed, release)
set_toggle
def set_toggle(self, toggle=True)
makes the button behave as a toggle button. When pushed it is not released automatically
- → toggle : True by default, but at its creation a normal button is not toggle
add_fellow
def add_fellow(self, button)
add fellow (friends !) when the button is pushed fellows are also activated
- → button : anothe button
add_antagonist
def add_antagonist(self, button)
add antagonist (radio button !) when the button is pushed antagonists are released and vice versa
- → button : anothe button
remove_antagonist
def remove_antagonist(self, button)
remove an antagonist button (radio button !) when the button is pushed antagonists are released and vice versa
- → button : anothe button
remove_all_antagonist
def remove_all_antagonist(self)
remove all the antagonist buttons
- → button : anothe button
remove_all_fellow
def remove_all_fellow(self)
remove all the fellow buttons
- → button : anothe button
set_layout
def set_layout(self)
set_layout : redraw the button in a correct layout
set_layout_right
def set_layout_right(self)
set_layout : redraw the button in a correct layout for right direction orefer use set_layout
set_layout_bottom
def set_layout_bottom(self)
set_layout : redraw the button in a correct layout for bottom direction orefer use set_layout
set_layout_left
def set_layout_left(self)
set_layout : redraw the button in a correct layout for left direction orefer use set_layout
set_layout_top
def set_layout_top(self)
set_layout : redraw the button in a correct layout for top direction orefer use set_layout
set_texture
def set_texture(self, texture=None)
set the release state texture
- → texture : an OGLTexture
set_texture_pushed
def set_texture_pushed(self, texture=None)
set the pushed state texture
- → texture : an OGLTexture
set_background
def set_background(self, texture=None)
set the background texture
- → texture : an OGLTexture
set_font
def set_font(self, font=None, update=True)
set the font for label
- → font : an OGLFont
- → update : if True (default the layout is rebuilt. May be false to delay layout reconstruction for containers
set_label
def set_label(self, label)
set the label
- → label : unicode string
set_label_scale
def set_label_scale(self, scale=1)
Set a scale factor for label respect to icon size
- → : scale factor : by default = 1
set_label_color
def set_label_color(self, r=1, g=1, b=1, a=1)
set the color for the text
- → r,g,b,a : a diffuse color
set_direction
def set_direction(self, direction=0)
set the relative position of label respect to the icon
- → direction
- 0 : label on icon right
- 1 : label on icon left
- 2 : label under icon
- 3 : label above icon
push
def push(self, propagate=True)
realize the push action
- → propagate : boolean : if True (default) the event is propagated to antagonists and fellows
release
def release(self, propagate=True)
realize the release action
- → propagate : boolean : if True (default) the event is propagated to antagonists and fellows
show_label
def show_label(self, show=True)
show/hide label
- → show : boolean
show_icon
def show_icon(self, show=True)
show/hide icon
- → show : boolean
show_background
def show_background(self, show=True)
show/hide background
- → show : boolean
on_shot
def on_shot(self, device=None, picked={})
callback when a device shot the button
- → device : the device which shot the button
- → picked : picking data (see Canvas pick method)
on_unshot
def on_unshot(self, device=None, picked={})
callback when a device unshot the button
- → device : the device which shot the button
- → picked : picking data (see Canvas pick method)
on_move
def on_move(self, device=None, previous_pick={}, current_pick={})
callback when a device move other the button
- → device : the device which shot the button
- → previous_pick : previous picking data (see Canvas pick method)
- → current_pick : picking data (see Canvas pick method)