Пример #1
0
    def _init_gui(self):
        """Initial init of gui."""
        self._gui = load_xml_translated("configure_route.xml")
        self.listbox = self._gui.findChild(name="branch_office_list")
        self.listbox._setItems(list(self.branch_offices))

        vbox = self._gui.findChild(name="left_vbox")
        for entry in self.instance.route.waypoints:
            hbox = widgets.HBox()
            label = widgets.Label()
            label.text = unicode(entry['branch_office'].settlement.name)
            hbox.addChild(label)
            vbox.addChild(hbox)

        # we want escape key to close the widget, what needs to be fixed here?
        self._gui.on_escape = self.hide
        # needs to check the current state and set the button state afterwards
        #		self._gui.findChild(name='start_route').set_inactive()
        self._gui.mapEvents({
            'cancelButton':
            self.hide,
            'add_bo/mouseClicked':
            self.append_bo,
            'start_route/mouseClicked':
            self.instance.route.enable,
            #		  'start_route/mouseClicked' : self.toggle_route
        })
        center_widget(self._gui)
Пример #2
0
    def _add_generic_line_to_gui(self, id, line_prefix, people, tax, costs):
        inhabitants = widgets.Label(name='inhabitants_%d' % id)
        inhabitants.text = unicode(people)
        inhabitants.min_size = inhabitants.max_size = (110, 20)

        taxes = widgets.Label(name='taxes_%d' % id)
        taxes.text = unicode(tax)
        taxes.min_size = taxes.max_size = (50, 20)

        running_costs = widgets.Label(name='running_costs_%d' % id)
        running_costs.text = unicode(costs)
        running_costs.min_size = running_costs.max_size = (100, 20)

        balance = widgets.Label(name='balance_%d' % id)
        balance.text = unicode(tax - costs)
        balance.min_size = balance.max_size = (60, 20)

        hbox = widgets.HBox()
        for widget in line_prefix:
            hbox.addChild(widget)
        hbox.addChild(inhabitants)
        hbox.addChild(taxes)
        hbox.addChild(running_costs)
        hbox.addChild(balance)
        self._content_vbox.addChild(hbox)
Пример #3
0
    def _add_line_to_gui(self, player):
        stats = player.get_latest_stats()

        emblem = widgets.Label(name='emblem_{:d}'.format(player.worldid),
                               text="   ")
        emblem.background_color = player.color
        emblem.min_size = (12, 20)

        name = widgets.Label(name='player_{:d}'.format(player.worldid))
        name.text = player.name
        name.min_size = (108, 20)

        money_score = widgets.Label(
            name='money_score_{:d}'.format(player.worldid))
        money_score.text = str(stats.money_score)
        money_score.min_size = (60, 20)

        land_score = widgets.Label(
            name='land_score_{:d}'.format(player.worldid))
        land_score.text = str(stats.land_score)
        land_score.min_size = (50, 20)

        resource_score = widgets.Label(
            name='resource_score_{:d}'.format(player.worldid))
        resource_score.text = str(stats.resource_score)
        resource_score.min_size = (90, 20)

        building_score = widgets.Label(
            name='building_score_{:d}'.format(player.worldid))
        building_score.text = str(stats.building_score)
        building_score.min_size = (70, 20)

        settler_score = widgets.Label(
            name='settler_score_{:d}'.format(player.worldid))
        settler_score.text = str(stats.settler_score)
        settler_score.min_size = (60, 20)

        unit_score = widgets.Label(
            name='unit_score_{:d}'.format(player.worldid))
        unit_score.text = str(stats.unit_score)
        unit_score.min_size = (50, 20)

        total_score = widgets.Label(
            name='total_score_{:d}'.format(player.worldid))
        total_score.text = str(stats.total_score)
        total_score.min_size = (70, 20)

        hbox = widgets.HBox()
        hbox.addChild(emblem)
        hbox.addChild(name)
        hbox.addChild(money_score)
        hbox.addChild(land_score)
        hbox.addChild(resource_score)
        hbox.addChild(building_score)
        hbox.addChild(settler_score)
        hbox.addChild(unit_score)
        hbox.addChild(total_score)
        self._content_vbox.addChild(hbox)
Пример #4
0
	def update(self):
		""" Sets up the button widget """
		if self._widget != None:
			self.removeChild(self._widget)
			self._widget = None
			
		if self._action is None:
			return
			
		widget = None
		icon = None
		text = None

		if self._action.isSeparator():
			widget = widgets.VBox()
			widget.base_color += Color(8, 8, 8)
			widget.min_size = (2, 2)
		else:
			if self._button_style != ToolBar.BUTTON_STYLE['TextOnly'] and len(self._action.icon) > 0:
				if self._action.isCheckable():
					icon = widgets.ToggleButton(hexpand=0, up_image=self._action.icon,down_image=self._action.icon,hover_image=self._action.icon,offset=(1,1))
					icon.toggled = self._action.isChecked()
				else:
					icon = widgets.ImageButton(hexpand=0, up_image=self._action.icon,down_image=self._action.icon,hover_image=self._action.icon,offset=(1,1))
				icon.capture(self._action.activate)
				
			if self._button_style != ToolBar.BUTTON_STYLE['IconOnly'] or len(self._action.icon) <= 0:
				if self._action.isCheckable():
					text = widgets.ToggleButton(hexpand=0, text=self._action.text,offset=(1,1))
					text.toggled = self._action.isChecked()
				else:
					text = widgets.Button(text=self._action.text)
				text.capture(self._action.activate)
			
			if self._button_style == ToolBar.BUTTON_STYLE['TextOnly'] or len(self._action.icon) <= 0:
				widget = text
				
			elif self._button_style == ToolBar.BUTTON_STYLE['TextUnderIcon']:
				widget = widgets.VBox()
				icon.position_technique = "center:top"
				text.position_technique = "center:bottom"
				widget.addChild(icon)
				widget.addChild(text)
				
			elif self._button_style == ToolBar.BUTTON_STYLE['TextBesideIcon']:
				widget = widgets.HBox()
				widget.addChild(icon)
				widget.addChild(text)
					
			else:
				widget = icon
			
		widget.position_technique = "left:center"
		widget.hexpand = 0
		
		self._widget = widget
		self.addChild(self._widget)
Пример #5
0
	def buildGui(self):
		if self.gui:
			self.removeChild(self.gui)
		
		if self.side == "left" or self.side == "right":
			self.gui = widgets.VBox()
		else:
			self.gui = widgets.HBox()
			
		self.gui.vexpand = 1
		self.gui.hexpand = 1
		
		self.addChild(self.gui)
Пример #6
0
	def _updateToolbar(self):
		actions = self._actions
		
		self.clear()
		
		if self._orientation == ToolBar.ORIENTATION['Vertical']:
			self.gui = widgets.VBox(min_size=(self._panel_size, self._panel_size))
		else:
			self.gui = widgets.HBox(min_size=(self._panel_size, self._panel_size))
		self.addChild(self.gui)
		
		for action in actions:
			self.addAction(action)

		self.adaptLayout()
Пример #7
0
    def _buildGui(self):
        if self.gui is not None:
            self.removeChild(self.gui)
            self._buttonlist = []

        self.gui = widgets.HBox()
        for i, menu in enumerate(self.menulist):
            button = widgets.Button(name=menu.name, text=menu.name)
            button.hexpand = 0
            button.capture(cbwa(self._showMenu, i))
            self._buttonlist.append(button)
            self.gui.addChild(button)

        self.gui.addSpacer(widgets.Spacer())

        self.addChild(self.gui)
Пример #8
0
    def append_bo(self):
        selected = self.listbox._getSelectedItem()
        if selected == None:
            return
        vbox = self._gui.findChild(name="left_vbox")

        hbox = widgets.HBox()
        label = widgets.Label()
        label.text = selected
        hbox.addChild(label)

        self.instance.route.append(self.branch_offices[selected], {4: -1})

        vbox.addChild(hbox)
        self.hide()
        self.show()
Пример #9
0
    def _add_line_to_gui(self, container, resource_id, amount):
        res_name = self.db.get_res_name(resource_id)

        icon = create_resource_icon(resource_id, self.db)
        icon.name = 'icon_%s' % resource_id
        icon.max_size = icon.min_size = icon.size = (20, 20)

        label = widgets.Label(name='resource_%s' % resource_id)
        label.text = res_name
        label.min_size = (100, 20)

        amount_label = widgets.Label(name='produced_sum_%s' % resource_id)
        amount_label.text = unicode(amount)

        hbox = widgets.HBox()
        hbox.addChild(icon)
        hbox.addChild(label)
        hbox.addChild(amount_label)
        container.addChild(hbox)
	def __init__(self,callback,**kwargs):
		super(ObjectIcon,self).__init__(**kwargs)

		self.callback = callback

		self.capture(self._mouseEntered, "mouseEntered")
		self.capture(self._mouseExited, "mouseExited")
		self.capture(self._mouseClicked, "mouseClicked")

		vbox = widgets.VBox(padding=3)

		# Icon
		self.icon = widgets.Icon(**kwargs)
		self.addChild(self.icon)

		# Label
		hbox = widgets.HBox(padding=1)
		self.addChild(hbox)
		self.label = widgets.Label(**kwargs)
		hbox.addChild(self.label)
Пример #11
0
    def _add_line_to_gui(self, resource_id, amount):
        displayed = self.db.get_res_inventory_display(resource_id)
        if not displayed:
            return
        res_name = self.db.get_res_name(resource_id)

        icon = create_resource_icon(resource_id, self.db)
        icon.name = 'icon_%s' % resource_id
        icon.max_size = icon.min_size = icon.size = (20, 20)

        label = widgets.Label(name='resource_%s' % resource_id)
        label.text = res_name
        label.min_size = (100, 20)

        amount_label = widgets.Label(name='produced_sum_%s' % resource_id)
        amount_label.text = unicode(amount)

        hbox = widgets.HBox()
        hbox.addChild(icon)
        hbox.addChild(label)
        hbox.addChild(amount_label)
        self._content_vbox.addChild(hbox)
Пример #12
0
    def __init__(self, resizable=None, *args, **kwargs):
        if resizable == None:
            resizable = False

        widgets.VBox.__init__(self, *args, **kwargs)
        ResizableBase.__init__(self, resizable, *args, **kwargs)

        self.tabs = []

        self.buttonbox = widgets.HBox()
        self.widgetarea = widgets.VBox()
        self.buttonbox.hexpand = 1
        self.buttonbox.vexpand = 0
        self.widgetarea.hexpand = 1
        self.widgetarea.vexpand = 1

        self.addChild(self.buttonbox)
        self.addChild(self.widgetarea)

        self.resizable_top = False
        self.resizable_left = False
        self.resizable_right = False
        self.resizable_bottom = False
Пример #13
0
    def update(self):
        """ Sets up the button widget """
        if self._widget != None:
            self.removeChild(self._widget)
            self._widget = None

        if self._action is None:
            return

        widget = None
        icon = None
        text = None

        if self._action.isSeparator():
            widget = widgets.HBox()
            widget.base_color += Color(8, 8, 8)
            widget.min_size = (2, 2)
        else:
            hasIcon = len(self._action.icon) > 0

            if self._action.isCheckable():
                text = widgets.ToggleButton(text=self._action.text)
                text.toggled = self._action.isChecked()
                text.hexpand = 1
            else:
                text = widgets.Button(text=self._action.text)
            text.min_size = (1, MENU_ICON_SIZE)
            text.max_size = (1000, MENU_ICON_SIZE)
            text.capture(self._action.activate)

            if hasIcon:
                if self._action.isCheckable():
                    icon = widgets.ToggleButton(hexpand=0,
                                                up_image=self._action.icon,
                                                down_image=self._action.icon,
                                                hover_image=self._action.icon,
                                                offset=(1, 1))
                    icon.toggled = self._action.isChecked()
                else:
                    icon = widgets.ImageButton(hexpand=0,
                                               up_image=self._action.icon,
                                               down_image=self._action.icon,
                                               hover_image=self._action.icon,
                                               offset=(1, 1))

            else:
                if self._action.isCheckable():
                    icon = widgets.ToggleButton(hexpand=0, offset=(1, 1))
                    icon.toggled = self._action.isChecked()
                else:
                    icon = widgets.Button(text=u"", hexpand=0)

            icon.min_size = icon.max_size = (MENU_ICON_SIZE, MENU_ICON_SIZE)
            icon.capture(self._action.activate)

            widget = widgets.HBox()
            widget.addChild(icon)
            widget.addChild(text)

        widget.position_technique = "left:center"
        widget.hexpand = 1
        widget.vexpand = 0

        self._widget = widget
        self.addChild(self._widget)