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()
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
def _init_tab_buttons(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_{}".format(index)) background = Icon(name="bg_{}".format(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: button.helptext = tab.helptext container.size = (50, 52) container.addChild(background) container.addChild(button) self.content.addChild(container) self.widget.size = (54, 55 * len(self._tabs)) self.widget.adaptLayout() self._apply_layout_hack()
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
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
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