Package interphase :: Module interface :: Class Interface

Class Interface

env.engine.sprite.Sprite --+
                           |
                          Interface

Interface Object

To design an interface panel, interphase.Interface can be subclassed. Within the __init__() method call interphase.Interface.__init__(). Interface Object provides methods to design and utilize an interface panel. Use add() to add controls to panel, place into a method called add_controls(); if controls added otherwise call activate() to activate the panel. The module maintains the update of the panel including changes through the methods, however panel_update() can be used to force an update if required. If the Interface Object is subclassed, when overriding the update() method call interphase.Interface.update().

Interface interaction can be maintained with the InterfaceState object, that is returned by update() or get_state(), or through Pygame event queue checking for event.type interphase.EVENT[ 'controlselect' ] and interphase.EVENT[ 'controlinteract' ] with the attribute event.state that references the InterfaceState object. To turn the panel off, deactivate() sets state.active to false. The panel can be drawn to the display with the draw() method.

Instance Methods
 
__init__(self, identity='Interface_Panel', position=None, image=None, color=(0,0,0), size=(350,100), screen=(500,500), moveable=False, position_offset=(0,0), move_rate=(200,200), fixed=False, button_image=None, control_image=None, color_key=None, control_minsize=None, control_size='min', button_size=(12,12), function_button='left', control_button='right', scroll_button=None, font_color=(125,130,135), font_type=None, font_size=10, label_display=False, info_display=False, info_fontsize=10, info_fontcolor=(125,130,135), info_position=(2,0), tips_display=False, tips_fontsize=8, tips_fontcolor=(125,130,135), tips_position=(0,-15), control_response=125, pointer_interact=False, data_folder='data', data_zip=None, text_paste=False, event=False)
**Interface Object: Define panel.**
 
add_controls(self)
Method to overide in subclass for adding controls.
 
add(self, identity, control_type, position, **parameters)
Add control to panel.
 
activate(self, activate_panel=True)
Panel activation.
 
deactivate(self)
Panel deactivation.
 
add_control(self, identity, control_type, position, **parameters)
Add control to panel.
 
get_control(self, *control)
Retrieve control object. Multiple controls return a dictionary of control objects, and if no parameter given return dictionary of all control objects.
 
remove_control(self, *control)
Remove control from panel.
 
enable_control(self, *control)
Set control enabled.
 
disable_control(self, *control)
Set control disabled.
 
get_value(self, *control)
Retrieve current value of control. Multiple controls return a dictionary of values, and if no parameter given return dictionary of all values.
 
get_position(self)
Retrieve panel position.
 
get_size(self)
Retrieve panel size.
 
get_default_image(self, mode=None, path=None)
Get or save default images.
 
get_panel_image(self, change=False)
Get panel image to modify. Parameter Change - True: mod permanent, False: mod transitory.
 
set_panel_image(self, image=None, data_folder=None, data_zip=None, file_obj=None, color_key=None, surface=None)
Set image used for panel.
 
set_control_image(self, control_image=None, data_folder=None, data_zip=None, file_obj=None, color_key=None, surface=None)
Set image used for control.
 
set_button_image(self, button_image=None, data_folder=None, data_zip=None, file_obj=None, color_key=None, surface=None)
Set image used for buttons.
 
get_clipboard(self)
Retrieve text from clipboard.
 
set_clipboard(self, text)
Save text to clipboard.
 
is_active(self)
Check whether panel is active.
 
is_moveable(self, setting=None)
Check whether panel is moveable.
 
set_moveable(self, setting='Toggle', position_offset=None, move_rate=None)
Set panel moveable setting.
 
move(self, x, y)
Move panel to new position x,y.
 
is_panel_display(self)
Check whether panel controls displayed or toggled with pointer interaction.
 
set_panel_display(self, setting='Toggle')
Set panel controls displayed or toggled with pointer interaction.
 
is_info_display(self)
Check whether info is displayed.
 
set_info_display(self, setting='Toggle')
Set info display setting.
 
is_label_display(self)
Check whether label is displayed.
 
set_label_display(self, setting='Toggle')
Set label display setting.
 
is_tips_display(self)
Check whether tips are displayed.
 
set_tips_display(self, setting='Toggle')
Set tips display setting.
 
add_info(self, *message_append)
Add text to info.
 
clear_info(self)
Clear text from info.
 
get_id(self)
Get panel identity
 
get_state(self)
Get the state object of the panel.
 
set_update(self, sustain=False)
Set panel update. Parameter: sustain bool for continuous update, default False.
 
is_update(self)
Check if panel was updated or set to sustained update.
 
draw(self, surface)
Draw panel on surface. Return Rect of surface area changed.
 
clear(self, surface, background)
Clear panel from surface of previous draw, using background.
 
get_pointer_position(self)
Get position of pointer determined at latest update.
 
set_pointer_interact(self, setting='Toggle')
Set pointer interact monitoring.
 
process_event(self, clear=False)
Internally process event handlers. Required if no call to framework event method such as event.get or event.pump. Optional clear argument to remove events from framework event queue. With scroll_button active, call panel update prior to framework event method calls.
 
get_event_queue(self)
Return interface event queue. Event queue has mouse press events sequestered upon panel interaction with scroll_button active.
 
move_control(self, control=None, position=None, offset=None)
Move selected control. If no position supplied, use position of mouse pointer.
 
set_control_move(self, control=None, mouse_visible=True)
Select control to move.
 
get_control_move(self)
Return selected control to move.
 
is_control_moveable(self)
Check whether control is moveable.
 
set_control_moveable(self, setting='Toggle')
Set control moveable.
 
set_panel_function(self, function=None)
Add function to panel update list, call without function to delete list.
 
panel_update(self, force_update=True)
Update control panel, determines interaction, does control action.
 
update(self)
Update control panel. If overriding in interface subclass, call Interface.update(self).
Method Details

__init__(self, identity='Interface_Panel', position=None, image=None, color=(0,0,0), size=(350,100), screen=(500,500), moveable=False, position_offset=(0,0), move_rate=(200,200), fixed=False, button_image=None, control_image=None, color_key=None, control_minsize=None, control_size='min', button_size=(12,12), function_button='left', control_button='right', scroll_button=None, font_color=(125,130,135), font_type=None, font_size=10, label_display=False, info_display=False, info_fontsize=10, info_fontcolor=(125,130,135), info_position=(2,0), tips_display=False, tips_fontsize=8, tips_fontcolor=(125,130,135), tips_position=(0,-15), control_response=125, pointer_interact=False, data_folder='data', data_zip=None, text_paste=False, event=False)
(Constructor)

 

**Interface Object: Define panel.**

Optional Parameters <default>:
identity: 'id' panel name <'Interface_Panel'>.
position: (x,y) panel placement on screen <None>.
    values < 1 are %screen.
    None centers on screen.
image: 'image' panel image <None>.
    None use default image, 'none' suppress default image.
    Image in data folder.
color: (r,g,b) panel color <(0,0,0)>.
size: (w,h) dimension of panel <(350,100)>.
screen: (w,h) dimension of screen <(500,500)>.
moveable: bool panel can move <False>.
position_offset: (x,y) panel move offset <(0,0)>.
move_rate: (x,y) panel move rate pix/s <(200,200)>.
    values < 1 are %position_offset/s.
fixed: bool panel fixed in place <False>.
button_image: ['U','D'] or 'composite' control button image <None>.
    None use default image, 'none' suppress default image.
    Image in data folder.
control_image: 'image' control background image <None>.
    None use default image, 'none' suppress default image.
    Image in data folder.
color_key: (r,g,b) image color key transparency <None>.
    transparency set by image alpha value or color_key.
    value -1 color_key from pixel at (0,0).
control_minsize: (x,y) minimum control size <None>.
control_size: '' global control size if control_minsize set <'min'>.
    'auto', 'auto_width': fit items.
    'min', 'min_width': fit using control_minsize.
    'panel': use exact control_minsize.
button_size: (x,y) button size <(12,12)>.
function_button: placement of buttons of function_select <'left'>.
control_button: placement of buttons of control_select <'right'>.
scroll_button: activate scroll wheel <None>.
    - None,'vertical','horizontal','both'
font_color: (r,g,b) font color of control text <(125,130,135)>.
font_type: [] font type list <None>.
    None: default system font; []: use first font available.
    <control>.set_display_text(info='system') gets system fonts.
    'file:<font_name>' path to font file.
font_size: int font size of control text <10>.
label_display: bool label displayed <False>.
info_display: bool info text displayed <False>.
info_fontsize: int font size used for info text <10>.
info_fontcolor: (r,g,b) font color used for info text <(125,130,135)>.
info_position: (x,y) position of info text <(2,0)>.
tips_display: bool tip text displayed <False>.
tips_fontsize: int font size used for tip text <8>.
tips_fontcolor: (r,g,b) font color used for tip text <(125,130,135)>.
tips_position: (x,y) position offset of tip text <(0,-15)>.
control_response: int control click response (ms) <125>.
    - 0 for no response repeat.
pointer_interact: bool pointer interact monitored <False>.
data_folder: '' image data folder <'data'>.
data_zip: '' image data zip <None>.
text_paste: bool clipboard support <False>.
event: bool interaction generates events <False>.