class AccountTab(MainSquareTab): """Display basic income and expenses of a settlement""" def __init__(self, instance): super(AccountTab, self).__init__(instance=instance, widget='tab_account.xml', \ icon_path='content/gui/icons/tabwidget/warehouse/account_%s.png') self.helptext = _("Account") self.widget.mapEvents({ 'show_production_overview/mouseClicked' : self.show_production_overview }) def show_production_overview(self): self.prod_overview = ProductionOverview(self.settlement) self.prod_overview.toggle_visibility() def refresh(self): super(AccountTab, self).refresh() taxes = self.settlement.cumulative_taxes running_costs = self.settlement.cumulative_running_costs buy_expenses = self.settlement.get_component(TradePostComponent).buy_expenses sell_income = self.settlement.get_component(TradePostComponent).sell_income balance = self.settlement.balance sign = '+' if balance >= 0 else '-' self.widget.child_finder('taxes').text = unicode(taxes) self.widget.child_finder('running_costs').text = unicode(running_costs) self.widget.child_finder('buying').text = unicode(buy_expenses) self.widget.child_finder('sale').text = unicode(sell_income) self.widget.child_finder('balance').text = unicode(sign+' '+str(abs(balance)))
class AccountTab(MainSquareTab): """Display basic income and expenses of a settlement""" def __init__(self, instance): super(AccountTab, self).__init__(widget = 'tab_account.xml') self.settlement = instance.settlement self.init_values() icon_path = 'content/gui/icons/tabwidget/branchoffice/account_%s.png' self.button_up_image = icon_path % 'u' self.button_active_image = icon_path % 'a' self.button_down_image = icon_path % 'd' self.button_hover_image = icon_path % 'h' self.tooltip = _("Account") self.widget.mapEvents({ 'show_production_overview/mouseClicked' : self.show_production_overview }) def show_production_overview(self): self.prod_overview = ProductionOverview(self.settlement) self.prod_overview.toggle_visibility() def refresh(self): taxes = self.settlement.cumulative_taxes running_costs = self.settlement.cumulative_running_costs buy_expenses = self.settlement.buy_expenses sell_income = self.settlement.sell_income balance = self.settlement.balance sign = '+' if balance >= 0 else '-' self.widget.child_finder('taxes').text = unicode(taxes) self.widget.child_finder('running_costs').text = unicode(running_costs) self.widget.child_finder('buying').text = unicode(buy_expenses) self.widget.child_finder('sale').text = unicode(sell_income) self.widget.child_finder('balance').text = unicode(sign+' '+str(abs(balance)))
class AccountTab(MainSquareTab): """Display basic income and expenses of a settlement""" def __init__(self, instance): super(AccountTab, self).__init__( instance=instance, widget='tab_account.xml', icon_path='content/gui/icons/tabwidget/warehouse/account_%s.png') self.helptext = _("Account") self.widget.mapEvents({ 'show_production_overview/mouseClicked': self.show_production_overview }) def show_production_overview(self): self.prod_overview = ProductionOverview(self.settlement) self.prod_overview.toggle_visibility() def refresh(self): super(AccountTab, self).refresh() taxes = self.settlement.cumulative_taxes running_costs = self.settlement.cumulative_running_costs buy_expenses = self.settlement.get_component( TradePostComponent).buy_expenses sell_income = self.settlement.get_component( TradePostComponent).sell_income balance = self.settlement.balance sign = '+' if balance >= 0 else '-' self.widget.child_finder('taxes').text = unicode(taxes) self.widget.child_finder('running_costs').text = unicode(running_costs) self.widget.child_finder('buying').text = unicode(buy_expenses) self.widget.child_finder('sale').text = unicode(sell_income) self.widget.child_finder('balance').text = unicode(sign + ' ' + str(abs(balance)))
def init_widget(self): super(AccountTab, self).init_widget() self.widget.mapEvents({ 'show_production_overview/mouseClicked': self.show_production_overview, }) # FIXME having to access the WindowManager this way is pretty ugly self._windows = self.instance.session.ingame_gui.windows self.prod_overview = ProductionOverview(self._windows, self.settlement) self.widget.child_finder('headline').text = self.settlement.get_component(NamedComponent).name self.widget.child_finder('headline').helptext = T('Click to change the name of your settlement') path = 'icons/widgets/cityinfo/settlement_{}'.format(self.settlement.owner.color.name) self.widget.child_finder('show_production_overview').path = path
def __init__(self, instance): super(AccountTab, self).__init__(instance=instance, widget='tab_account.xml', icon_path='icons/tabwidget/warehouse/account') self.helptext = _("Account") self.widget.child_finder( 'headline').text = self.settlement.get_component( NamedComponent).name self.widget.child_finder('headline').helptext = _( 'Click to change the name of your settlement') path = 'icons/widgets/cityinfo/settlement_%s' % self.settlement.owner.color.name self.widget.child_finder('show_production_overview').path = path self.widget.mapEvents({ 'show_production_overview/mouseClicked': self.show_production_overview }) # FIXME having to access the WindowManager this way is pretty ugly self._windows = self.instance.session.ingame_gui.windows self.prod_overview = ProductionOverview(self._windows, self.settlement)
def show_production_overview(self): self.prod_overview = ProductionOverview(self.settlement) self.prod_overview.toggle_visibility()