Package horizons :: Package gui :: Module util
[hide private]
[frames] | no frames]

Module util

source code

Functions [hide private]
 
get_gui_files_map()
Returns a dictionary { basename : full_path } for all xml gui files in content/gui
source code
 
get_happiness_icon_and_helptext(value, session) source code
 
get_widget_xml(filename)
This function reads the given widget file's content and returns the XML.
source code
 
load_uh_widget(filename, style=None, center_widget=False)
Loads a pychan widget from an xml file and applies uh-specific modifications
source code
 
get_res_icon_path(res, size=32, greyscale=False, full_path=True)
Returns path of a resource icon or placeholder path, if icon does not exist.
source code
 
create_resource_icon(res_id, db)
Creates a pychan Icon for a resource.
source code
 
create_resource_selection_dialog(on_click, inventory, db, widget='select_trade_resource.xml', res_filter=None, amount_per_line=None)
Returns a container containing resource icons.
source code
Function Details [hide private]

get_gui_files_map()

source code 

Returns a dictionary { basename : full_path } for all xml gui files in content/gui

Decorators:
  • @decorators.cachedfunction

get_widget_xml(filename)

source code 

This function reads the given widget file's content and returns the XML. It is cached to avoid useless IO.

Decorators:
  • @decorators.cachedfunction

get_res_icon_path(res, size=32, greyscale=False, full_path=True)

source code 

Returns path of a resource icon or placeholder path, if icon does not exist.

Parameters:
  • res - resource id. Pass 'placeholder' to get placeholder path.
  • full_path - whether to return full icon path or a stub path suitable for ImageButton path=
Decorators:
  • @decorators.cachedfunction

create_resource_icon(res_id, db)

source code 

Creates a pychan Icon for a resource. Helptext is set to name of *res_id*.

Parameters:
  • res_id - resource id
  • db - dbreader for main db

create_resource_selection_dialog(on_click, inventory, db, widget='select_trade_resource.xml', res_filter=None, amount_per_line=None)

source code 

Returns a container containing resource icons.

Parameters:
  • on_click - called with resource id as parameter on clicks
  • inventory - to determine fill status of resource slots
  • db - main db instance
  • widget - which xml file to use as a template. Default: tabwidget. Required since the resource bar also uses this code (no tabs there though).
  • res_filter - callback to decide which icons to use. Default: show all
  • amount_per_line - how many resource icons per line. Default: try to fit layout