Package horizons :: Package gui :: Package tabs :: Module tabinterface :: Class TabInterface
[hide private]
[frames] | no frames]

Class TabInterface

source code

The TabInterface should be used by all classes that represent Tabs for the TabWidget.

By default the code will the widget from a file given by `widget`. If you want to run code after the widget has been loaded, override `init_widget`. To handle widget loading yourself, override `get_widget` and return the new widget. In both cases the widget is accessible at `self.widget`.

If you want to override the TabButton image used for the tab, you also have to set the button_image_{up,down,hover} variables.

Use the refresh() method to implement any redrawing of the widget. The TabWidget will call this method based on callbacks. If you set any callbacks yourself, make sure you get them removed when the widget is deleted.

Instance Methods [hide private]
 
__init__(self, widget=None, icon_path=None, **kwargs) source code
 
_setup_widget(self)
Gets the widget and sets up some attributes and helper.
source code
 
get_widget(self)
Loads the filename in self.widget.
source code
 
init_widget(self)
Initialize widget after it was loaded.
source code
 
show(self)
Shows the current widget
source code
 
hide(self)
Hides the current widget
source code
 
is_visible(self) source code
 
refresh(self)
This function is called by the TabWidget to redraw the widget.
source code
 
_schedule_refresh(self)
Schedule a refresh soon, dropping all other refresh request, that appear until then.
source code
 
ensure_loaded(self)
Called when a tab is shown, acts as hook for lazy loading
source code
 
_get_position(self) source code
 
_set_position(self, value)
Sets the widgets position to tuple *value*
source code
Class Methods [hide private]
 
shown_for(cls, instance)
Method for fine-grained control of which tabs to show.
source code
Class Variables [hide private]
  lazy_loading = True
  widget = None
hash(x)
  icon_path = 'images/tabwidget/tab'
  scheduled_update_delay = 0.4
  position = property(_get_position, _set_position)
Method Details [hide private]

__init__(self, widget=None, icon_path=None, **kwargs)
(Constructor)

source code 
Parameters:
  • widget - filename of a widget. Set this to None if you create your widget in `get_widget`.
  • widget - Filename of widget to load.
  • icon_path - Where to look for ImageButton icons. Note: this is a `path` attribute!

_setup_widget(self)

source code 

Gets the widget and sets up some attributes and helper.

This is called when the Tab is created, or, when lazy loading is active once the tab is about to be shown.

get_widget(self)

source code 

Loads the filename in self.widget.

Override this in your subclass if you want to handle widget loading/creation yourself.

init_widget(self)

source code 

Initialize widget after it was loaded.

Override this in your subclass if you have custom post-load code.

_schedule_refresh(self)

source code 

Schedule a refresh soon, dropping all other refresh request, that appear until then. This saves a lot of CPU time, if you have a huge island, or play on high speed.

shown_for(cls, instance)
Class Method

source code 

Method for fine-grained control of which tabs to show.

Returns:
whether this tab should really be shown for this instance