當前位置: 首頁>>代碼示例>>Python>>正文


Python ImageButton.path方法代碼示例

本文整理匯總了Python中horizons.gui.widgets.imagebutton.ImageButton.path方法的典型用法代碼示例。如果您正苦於以下問題:Python ImageButton.path方法的具體用法?Python ImageButton.path怎麽用?Python ImageButton.path使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在horizons.gui.widgets.imagebutton.ImageButton的用法示例。


在下文中一共展示了ImageButton.path方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _init_tabs

# 需要導入模塊: from horizons.gui.widgets.imagebutton import ImageButton [as 別名]
# 或者: from horizons.gui.widgets.imagebutton.ImageButton import path [as 別名]
	def _init_tabs(self):
		"""Add enough tabbuttons for all widgets."""
		def on_tab_removal(tabwidget):
			# called when a tab is being removed (via weakref since tabs shouldn't have references to the parent tabwidget)
			# If one tab is removed, the whole tabwidget will die..
			# This is easy usually the desired behavior.
			if tabwidget():
				tabwidget().on_remove()

		# Load buttons
		for index, tab in enumerate(self._tabs):
			# don't add a reference to the
			tab.add_remove_listener(Callback(on_tab_removal, weakref.ref(self)))
			container = Container(name="container_%s" % index)
			background = Icon(name="bg_%s" % index)
			button = ImageButton(name=str(index), size=(50, 50))
			if self.current_tab is tab:
				background.image = tab.button_background_image_active
				button.path = tab.path_active
			else:
				background.image = tab.button_background_image
				button.path = tab.path
			button.capture(Callback(self._show_tab, index))
			if hasattr(tab, 'helptext') and tab.helptext is not None:
				button.helptext = tab.helptext
			container.size = background.size
			container.addChild(background)
			container.addChild(button)
			self.content.addChild(container)
		self.widget.size = (50, 55*len(self._tabs))
		self.widget.adaptLayout()

		self._apply_layout_hack()
開發者ID:STEVEOO6,項目名稱:unknown-horizons,代碼行數:35,代碼來源:tabwidget.py

示例2: __init__

# 需要導入模塊: from horizons.gui.widgets.imagebutton import ImageButton [as 別名]
# 或者: from horizons.gui.widgets.imagebutton.ImageButton import path [as 別名]
	def __init__(self):
		self.page_widgets = {}
		self.widget = load_uh_widget(self.widget_xml, center_widget=True)

		# Lists holding pickbelt ImageButtons, placed to the left/right of the book
		self.buttons = {'left': [], 'right': []}

		for i, (name, text) in enumerate(self.sections):
			self.page_widgets[i] = self.widget.findChild(name=name)

		# Create the required pickbelts
		for i, (name, text) in enumerate(self.sections):
			for side in self.buttons:
				pickbelt = ImageButton(text=text)
				pickbelt.name = name + '_' + side
				pickbelt.path = 'images/background/pickbelt_%s' % side
				pickbelt.font = "pickbelt"

				pickbelt.capture(Callback(self.update_view, i), event_name="mouseClicked")

				start_x, start_y = self.pickbelt_start_pos
				pickbelt.position = (start_x + 5*i, start_y + 70*i)

				container = self.widget.findChild(name="%s_pickbelts" % side)
				container.addChild(pickbelt)
				self.buttons[side].append(pickbelt)

		self.widget.show() # Hack to initially setup the pickbelts properly
		self.update_view()
		self.widget.hide() # Hack to initially setup the pickbelts properly
開發者ID:JamesOravec,項目名稱:unknown-horizons,代碼行數:32,代碼來源:pickbeltwidget.py

示例3: _create_build_buttons

# 需要導入模塊: from horizons.gui.widgets.imagebutton import ImageButton [as 別名]
# 或者: from horizons.gui.widgets.imagebutton.ImageButton import path [as 別名]
	def _create_build_buttons(self, building_id, container):
		# {{mode}} in double braces because it is replaced as a second step
		building_type = Entities.buildings[building_id]
		build_button = ImageButton(name="build{id}".format(id=building_id), helptext=building_type.get_tooltip())
		build_button.path = "icons/buildmenu/{id:03d}".format(id=building_id)
		build_button.capture(Callback(self.build_related, building_id))
		return build_button
開發者ID:BenjaminHarper,項目名稱:unknown-horizons,代碼行數:9,代碼來源:buildrelatedtab.py

示例4: _create_build_buttons

# 需要導入模塊: from horizons.gui.widgets.imagebutton import ImageButton [as 別名]
# 或者: from horizons.gui.widgets.imagebutton.ImageButton import path [as 別名]
	def _create_build_buttons(self, building_id, container):
		# {{mode}} in double braces because it is replaced as a second step
		helptext = self.instance.session.db.get_building_tooltip(building_id)
		build_button = ImageButton(name="build{id}".format(id=building_id), helptext=helptext)
		build_button.path = "icons/buildmenu/{id:03d}".format(id=building_id)
		build_button.capture(Callback(self.build_related, building_id))
		return build_button
開發者ID:Daenor,項目名稱:unknown-horizons,代碼行數:9,代碼來源:buildrelatedtab.py

示例5: draw_widget

# 需要導入模塊: from horizons.gui.widgets.imagebutton import ImageButton [as 別名]
# 或者: from horizons.gui.widgets.imagebutton.ImageButton import path [as 別名]
	def draw_widget(self):
		"""
		Updates whole messagewidget (all messages): draw icons.
		Inactive messages need their icon hovered to display their text again
		"""
		button_space = self.widget.findChild(name="button_space")
		button_space.removeAllChildren() # Remove old buttons
		for index, message in enumerate(self.active_messages):
			if (self.item + index) >= len(self.active_messages):
				# Only display most recent notifications
				continue
			button = ImageButton()
			button.name = str(index)
			button.path = message.path
			# show text on hover
			events = {
				button.name + "/mouseEntered": Callback(self.show_text, index),
				button.name + "/mouseExited": self.hide_text,
			}
			# init callback to something callable to improve robustness
			callback = Callback(lambda: None)
			if message.x is not None and message.y is not None:
				# move camera to source of event on click, if there is a source
				callback = Callback.ChainedCallbacks(
					   callback, # this makes it so the order of callback assignment doesn't matter
					   Callback(self.session.view.center, message.x, message.y),
					   Callback(self.session.ingame_gui.minimap.highlight, (message.x, message.y) )
				   )
			if message.type == "logbook":
				# open logbook to relevant page
				callback = Callback.ChainedCallbacks(
					   callback, # this makes it so the order of callback assignment doesn't matter
					   Callback(self.session.ingame_gui.logbook.show, message.created)
				)
			if callback:
				events[button.name] = callback

			button.mapEvents(events)
			button_space.addChild(button)
		button_space.resizeToContent()
		self.widget.size = button_space.size
開發者ID:flaviusanton,項目名稱:unknown-horizons,代碼行數:43,代碼來源:messagewidget.py

示例6: create_resource_selection_dialog

# 需要導入模塊: from horizons.gui.widgets.imagebutton import ImageButton [as 別名]
# 或者: from horizons.gui.widgets.imagebutton.ImageButton import path [as 別名]
def 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.
	@param on_click: called with resource id as parameter on clicks
	@param inventory: to determine fill status of resource slots
	@param db: main db instance
	@param widget: which xml file to use as a template. Default: tabwidget. Required
	               since the resource bar also uses this code (no tabs there though).
	@param res_filter: callback to decide which icons to use. Default: show all
	@param amount_per_line: how many resource icons per line. Default: try to fit layout
	"""
    from horizons.gui.widgets.imagefillstatusbutton import ImageFillStatusButton

    dummy_icon_path = "icons/resources/none_gray"

    dlg = load_uh_widget(widget)

    icon_size = ImageFillStatusButton.ICON_SIZE  # used for dummy button
    cell_size = ImageFillStatusButton.CELL_SIZE
    button_width = cell_size[0]
    vbox = dlg.findChild(name="resources")
    amount_per_line = amount_per_line or vbox.width // button_width
    # Add the zero element to the beginning that allows to remove the currently
    # sold/bought resource:
    resources = [0] + db.get_res(only_tradeable=True)
    current_hbox = HBox(name="hbox_0", padding=0)
    index = 1
    for res_id in resources:
        # don't show resources that are already in the list
        if res_filter is not None and not res_filter(res_id):
            continue

            # on click: add this res
        cb = Callback(on_click, res_id)

        # create button (dummy one or real one)
        if res_id == 0 or inventory is None:
            reset_button = ImageButton(max_size=icon_size, name="resource_icon_00")
            reset_button.path = dummy_icon_path

            button = Container(size=cell_size)
            # add the "No Resource" image to the container, positioned in the top left
            button.addChild(reset_button)
            # capture a mouse click on the container. It's possible to click on the
            # image itself or into the empty area (below or to the right of the image)
            button.capture(cb, event_name="mouseClicked")
            button.name = "resource_%d" % res_id
        else:
            amount = inventory[res_id]
            filled = int(float(inventory[res_id]) / float(inventory.get_limit(res_id)) * 100.0)
            button = ImageFillStatusButton.init_for_res(
                db, res_id, amount=amount, filled=filled, uncached=True, use_inactive_icon=False, showprice=True
            )
            button.button.capture(cb)
            button.button.name = "resource_%d" % res_id

        current_hbox.addChild(button)
        if index % amount_per_line == 0:
            vbox.addChild(current_hbox)
            box_id = index // amount_per_line
            current_hbox = HBox(name="hbox_%s" % box_id, padding=0)
        index += 1
    vbox.addChild(current_hbox)
    vbox.adaptLayout()

    return dlg
開發者ID:unknown-horizons,項目名稱:unknown-horizons,代碼行數:69,代碼來源:util.py


注:本文中的horizons.gui.widgets.imagebutton.ImageButton.path方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。