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)
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)
def setup_setting_extras(self): slider_initial_data = {} slider_event_map = {} self.OptionsDlg = self._setting.loadSettingsDialog() center_widget(self.OptionsDlg) slider_dict = { 'AutosaveInterval': 'autosaveinterval', 'AutosaveMaxCount': 'autosavemaxcount', 'QuicksaveMaxCount': 'quicksavemaxcount' } for x in slider_dict.keys(): slider_initial_data[slider_dict[x] + '_value'] = unicode( int(self._setting.get(UH_MODULE, x))) slider_initial_data['volume_music_value'] = unicode( int(self._setting.get(UH_MODULE, "VolumeMusic") * 500)) + '%' slider_initial_data['volume_effects_value'] = unicode( int(self._setting.get(UH_MODULE, "VolumeEffects") * 200)) + '%' self.OptionsDlg.distributeInitialData(slider_initial_data) for x in slider_dict.values(): slider_event_map[x] = Callback(self.update_slider_values, x) slider_event_map['volume_music'] = self.set_volume_music slider_event_map['volume_effects'] = self.set_volume_effects self.OptionsDlg.mapEvents(slider_event_map)
def _init_gui(self): """Initial init of gui.""" self._gui = load_xml_translated("captains_log.xml") self._gui.mapEvents({ 'backwardButton' : Callback(self._scroll, -2), 'forwardButton' : Callback(self._scroll, 2), 'cancelButton' : self.hide }) center_widget(self._gui)
def _init_gui(self): """Initial init of gui.""" self._gui = load_xml_translated("captains_log.xml") self._gui.mapEvents({ 'backwardButton': Callback(self._scroll, -2), 'forwardButton': Callback(self._scroll, 2), 'cancelButton': self.hide }) center_widget(self._gui) self.backward_button = self._gui.findChild(name="backwardButton") self.forward_button = self._gui.findChild(name="forwardButton")
def setup_setting_extras(self): slider_initial_data = {} slider_event_map = {} self.OptionsDlg = self._setting.loadSettingsDialog() center_widget(self.OptionsDlg) slider_dict = {'AutosaveInterval' : 'autosaveinterval', 'AutosaveMaxCount' : 'autosavemaxcount', 'QuicksaveMaxCount' : 'quicksavemaxcount'} for x in slider_dict.keys(): slider_initial_data[slider_dict[x]+'_value'] = unicode(int(self._setting.get(UH_MODULE, x))) slider_initial_data['volume_music_value'] = unicode(int(self._setting.get(UH_MODULE, "VolumeMusic") * 500)) + '%' slider_initial_data['volume_effects_value'] = unicode(int(self._setting.get(UH_MODULE, "VolumeEffects") * 200)) + '%' self.OptionsDlg.distributeInitialData(slider_initial_data) for x in slider_dict.values(): slider_event_map[x] = Callback(self.update_slider_values, x) slider_event_map['volume_music'] = self.set_volume_music slider_event_map['volume_effects'] = self.set_volume_effects self.OptionsDlg.mapEvents(slider_event_map)
def _switch_current_widget(self, new_widget, center=False, event_map=None, show=False, hide_old=False): """Switches self.current to a new widget. @param new_widget: str, widget name @param center: bool, whether to center the new widget @param event_map: pychan event map to apply to new widget @param show: bool, if True old window gets hidden and new one shown @param hide_old: bool, if True old window gets hidden. Implied by show @return: instance of old widget""" old = self.current if (show or hide_old) and old is not None: self.log.debug("Gui: hiding %s", old) old.hide() self.log.debug("Gui: setting current to %s", new_widget) self.current = self.widgets[new_widget] if center: center_widget(self.current) if event_map: self.current.mapEvents(event_map) if show: self.current.show() return old