Package interphase :: Module control :: Class Control

Class Control

object --+
         |
        Control

Control Object

The Control class provides the base control. To create Control instances, use the add() method of the Interface object, which should be passed the arguments that will be used to instantiate a control.

Clicking on control with identity 'Control' generates a State Object with the control being 'Control', and button pressed being 'Control' for main button or 'Control_top' or 'Control_bottom' for switches. With the method add_action(), an action function can be attached to the control that will be called when pressed.

Instance Methods
 
__init__(self, panel, identity, control_type, position, size=None, color=(40,80,120), fill=1, control_outline=None, control_image=None, font_color=None, font_type=None, font_size=None, split_text=True, center_text=True, control_list=None, icon_list=None, icon_size=None, tip_list=None, link=None, link_activated=True, activated_color=(0,120,160), activated_toggle=True, label=None, label_display=True, active=True, control_response=None, hold_response=1000, delay_response=0, loop=False, reverse=False, control_button=True, text_margin=5, text_paste=False, event=None)
Control Object: Define panel control.
 
set_control_image(self, control_image=None, data_folder=None, data_zip=None, file_obj=None, color_key=None, surface=None)
Set image of control.
 
set_color(self, color=None, activated_color=None, fill=None)
Set control color.
 
set_list(self, control_list, icon_list=None, size=None, icon_size=None, case=False, data_folder=None, data_zip=None, file_obj=None, color_key=None, surface=None, append=False, index=None, keep_link=True, keep_tip=True)
Set control listing of a control.
 
set_list_icon(self, control_list, icon_list=None, data_folder=None, data_zip=None, file_obj=None, color_key=None, surface=None, icon_size=None)
Set control listing icon of a control, changing if item in listing or appending new item.
 
get_list(self)
Return control listing.
 
remove_list(self, items=None, index=None)
Remove specified items (or item at index) from control listing, including corresponding tips and links. Passing no parameter removes complete control list.
 
set_label(self, label=None)
Set control label.
 
get_label(self)
Get control label.
 
set_tip(self, *tip)
Set tip for a control item. Parameters: tip: str or [] - single control tip or tip list for control list items; or tuple item:str,tip:str tip for control list item.
 
get_tip(self, item=None)
Get the tip for a control item, or list of tips if no parameter given. Parameter: item:str
 
set_link(self, control, link)
Set linked controls. Parameters: control:str, link:[].
 
set_link_activated(self, setting='Toggle')
Set whether linked control active immediately or upon control button activation.
 
add_action(self, function, obj=None)
Bind action function to control. Function should take two arguments, for instance Function(control, value), that will receive the control button pressed and control value. Optional obj argument to provide object for method binding in Pyjs -O mode.
 
get_id(self)
Get control identity
 
get_position(self)
Retrieve control position.
 
get_size(self)
Retrieve control size.
 
set_text_margin(self, margin)
Set text margin. Parameter: margin int or (t,r,b,l).
 
get_text_margin(self)
Get text margin. Return [t,r,b,l].
 
is_activated(self)
Check whether control is activated.
 
set_activated(self, setting='Toggle')
Set control activated.
 
is_activated_lock(self)
Check control activate lock.
 
set_activated_lock(self, setting='Toggle')
Set control activate lock.
 
set_value(self, value, change_index=True)
Set the value of a control. Parameters: value - control value; change_index - True change list index to first available value, False to leave index position unchanged, index number for specific index if is value.
 
get_value(self)
Get the value of a control.
 
set_list_index(self, index)
Set the place in control listing.
 
get_list_index(self, item=None)
Get the current place in control listing, or index of first occurrence of item.
 
is_active(self)
Check whether a control is active.
 
set_active(self, setting='Toggle')
Set control active setting.
 
is_enabled(self)
Check whether control is enabled.
 
set_enabled(self, setting='Toggle')
Set control enabled setting.
 
resize_control(self, size)
Resize control.
 
set_display_info(self, size, font_color, font_type, font_size, position=None, text=None, center=True)
Initiate control display text.
 
set_display_text(self, font_color=None, font_bgcolor=None, font_type=None, font_size=None, split_text=None, size=None, info=False)
Set display text properties.
 
get_display_text(self)
Get display text object.
 
set_label_info(self, size, font_color, font_type, font_size, position=None, text=None)
Initiate control label text.
 
set_label_text(self, font_color=None, font_bgcolor=None, font_type=None, font_size=None, split_text=None)
Set label text properties.
 
check_link(self, ctrl, activate)
Maintain active state of linked controls.
 
reset(self, change_index=True)
Reset value to start of control list.
 
next(self)
Set value to next in control list.
 
previous(self)
Set value to previous in control list.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, panel, identity, control_type, position, size=None, color=(40,80,120), fill=1, control_outline=None, control_image=None, font_color=None, font_type=None, font_size=None, split_text=True, center_text=True, control_list=None, icon_list=None, icon_size=None, tip_list=None, link=None, link_activated=True, activated_color=(0,120,160), activated_toggle=True, label=None, label_display=True, active=True, control_response=None, hold_response=1000, delay_response=0, loop=False, reverse=False, control_button=True, text_margin=5, text_paste=False, event=None)
(Constructor)

 

Control Object: Define panel control.

Parameters:
panel: obj panel holding control.
    - automatically set by panel add() method.
identity: 'id' control name.
control_type: 'type' control type.
    - 'function_select', 'function_toggle': master control.
    - 'control_select', 'control_toggle': standard control.
    - 'label': label control.
    - 'textbox': textbox control.
position: (x,y) control placement on panel. Values < 1 are %panel.
Optional parameters <default>:
size: (w,h) control size override panel specified <None>.
    - 'auto', 'auto_width': fit items.
    - 'min', 'min_width': fit using control_minsize.
    - 'panel': use exact control_minsize.
color: (r,g,b) control color <(40,80,120)>.
fill: int button edge width, and 0 filled -1 none <1>.
control_outline: display control edge <None>.
control_image: 'image' control background image overrides panel <None>.
    - 'none' suppress image.
    - Image in data folder.
font_color: (r,g,b) font color. Overrides panel <None>.
font_type: [] font type list. Overrides panel <None>.
font_size: int font size. Overrides panel <None>.
split_text: bool split text at space to new line <True>.
control_list: [] list held by control <None>.
    - numeric: [0] '__numeric', [1] (start,stop,step).
    - alpha: [0] '__alpha', [1] 'upper','lower','mixed'.
    - alphanumeric: [0] '__alphanumeric' in list[0], [1] 'upper','lower','mixed'.
    - filelist: [0] '__filelist', [1] path, [2] root, [3] ext.
    - 'item': Value listing. Leading '__' not display or display available icon.
icon_list: [] control icons <None>.
    - replace '__item' in control_list - separate images or a composite image.
icon_size: (w,h) control icon size <None>.
    - values < 1 are %control size.
    - default use control size.
tip_list: [] tip list - single tip or multiple tip list <None>.
link: [] function control link to activate other controls <None>.
link_activated: bool function control link activated <True>.
activated_color: (r,g,b) highlight color of activated control <(0,120,160)>.
activated_toggle: bool control activated toggle <True>.
    - 'lock' for activate lock.
label: '' supply label to replace 'id' text <None>.
label_display: bool control label displayed <True>.
active: bool control active state <True>.
control_response: int control response (ms). Overrides panel <None>.
    - 0 no response repeat.
hold_response: int hold (ms) before control response quicken <1000>.
    - 0 no response change.
delay_response: int initial delay (ms) before control response <0>.
loop: bool option list loop <False>.
reverse: bool control switches reversed <False>.
control_button: bool control switches displayed <True>.
center_text: bool control text centered <True>.
text_margin: int or (t,r,b,l) textbox margin <5>.
text_paste: bool textbox copy/paste function <False>.
event: bool interaction generates events. Overrides panel <None>.

Overrides: object.__init__