Package horizons :: Package gui :: Package tabs :: Module buyselltab :: Class BuySellTab
[hide private]
[frames] | no frames]

Class BuySellTab

source code

tabinterface.TabInterface --+
                            |
                           BuySellTab

Allows players to tell settlements which resources to buy or sell by adding slots in either buy or sell mode and introducing a limit per such slot. Also contains the trade history.

Instance Methods [hide private]
 
__init__(self, instance)
Set up the GUI and game logic for the buyselltab.
source code
 
init_widget(self)
Initialize widget after it was loaded.
source code
 
hide(self)
Hide the tab and all widgets we may have added at runtime.
source code
 
show(self)
Display the tab's content, start the refresher.
source code
 
is_visible(self) source code
 
_refresh_trade_history(self) source code
 
refresh(self)
This function is called by the TabWidget to redraw the widget.
source code
 
add_slots(self, amount)
Add `amount` slot widgets to the buysellmenu.
source code
 
add_resource(self, resource_id, slot_id, value=None)
Adds a resource to the specified slot
source code
 
toggle_buysell(self, slot_id, keep_hint=False)
Switches modes of individual resource slots between 'buy' and 'sell'.
source code
 
set_slot_info(self, slot_id, resource_id, selling, limit) source code
 
clear_slot(self, slot_id) source code
 
slider_adjust(self, resource_id, slot_id)
Couples the displayed limit of this slot to the slider position.
source code
 
handle_click(self, widget, event)
Handle clicks on resource slots.
source code
 
show_resource_menu(self, slot_id)
Displays a menu where players can choose which resource to add in the selected slot.
source code
 
_update_hint(self, slot_id)
Sets default hint for last updated slot
source code
 
_set_hint(self, text) source code
 
_show_buy(self, slot)
Make slot show buy button.
source code
 
_show_sell(self, slot)
Make slot show sell button.
source code
    Inherited from tabinterface.TabInterface
 
_get_position(self) source code
 
_schedule_refresh(self)
Schedule a refresh soon, dropping all other refresh request, that appear until then.
source code
 
_set_position(self, value)
Sets the widgets position to tuple *value*
source code
 
_setup_widget(self)
Gets the widget and sets up some attributes and helper.
source code
 
ensure_loaded(self)
Called when a tab is shown, acts as hook for lazy loading
source code
 
get_widget(self)
Loads the filename in self.widget.
source code
Class Methods [hide private]
    Inherited from tabinterface.TabInterface
 
shown_for(cls, instance)
Method for fine-grained control of which tabs to show.
source code
Class Variables [hide private]
  log = logging.getLogger("gui")
  widget = 'buysellmenu.xml'
hash(x)
  icon_path = 'icons/tabwidget/warehouse/buysell'
  buy_button_path = "content/gui/images/tabwidget/ship_to_wareho...
  sell_button_path = "content/gui/images/tabwidget/warehouse_to_...
  dummy_icon_path = "icons/resources/none_gray"
    Inherited from tabinterface.TabInterface
  lazy_loading = True
  position = property(_get_position, _set_position)
  scheduled_update_delay = 0.4
Method Details [hide private]

__init__(self, instance)
(Constructor)

source code 

Set up the GUI and game logic for the buyselltab.

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!
Overrides: tabinterface.TabInterface.__init__

init_widget(self)

source code 

Initialize widget after it was loaded.

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

Overrides: tabinterface.TabInterface.init_widget
(inherited documentation)

hide(self)

source code 

Hide the tab and all widgets we may have added at runtime.

Overrides: tabinterface.TabInterface.hide

show(self)

source code 

Display the tab's content, start the refresher.

Overrides: tabinterface.TabInterface.show

is_visible(self)

source code 
Overrides: tabinterface.TabInterface.is_visible

refresh(self)

source code 

This function is called by the TabWidget to redraw the widget.

Overrides: tabinterface.TabInterface.refresh
(inherited documentation)

add_slots(self, amount)

source code 

Add `amount` slot widgets to the buysellmenu.

Parameters:
  • amount - number of slot widgets that are to be added.

add_resource(self, resource_id, slot_id, value=None)

source code 

Adds a resource to the specified slot

Parameters:
  • resource_id - int - resource id
  • slot_id - int - slot number of the slot that is to be set

handle_click(self, widget, event)

source code 

Handle clicks on resource slots. Left: change resource; Right: empty slot.

show_resource_menu(self, slot_id)

source code 

Displays a menu where players can choose which resource to add in the selected slot. Available resources are all possible resources and a 'None' resource which allows to delete slot actions. The resources are ordered by their res_id.

_show_buy(self, slot)

source code 

Make slot show buy button. Purely visual change

_show_sell(self, slot)

source code 

Make slot show sell button. Purely visual change


Class Variable Details [hide private]

buy_button_path

Value:
"content/gui/images/tabwidget/ship_to_warehouse.png"

sell_button_path

Value:
"content/gui/images/tabwidget/warehouse_to_ship.png"