def __init__(self, component_manager ): UiComponent.__init__(self, component_manager) self.formats = {} for _format in self.component_manager.get_all("file_format"): self.formats[_format.description] = _format.filename_filter # create widgets self.page, self.switcher, self.format_label, self.format_button, \ self.tags_box, self.tags_button, self.tags_name_label, \ self.file_chooser_button, self.file_name_label, \ self.menu_button, self.convert_button, self.format_prev_button, \ self.format_next_button, new_tag_button, self.new_tag_entry = \ create_importcard_ui(self.main_widget().switcher, \ self.component_manager.get_current("file_format").description) self.tags_mode = False self.selected_tags = [u"<default>"] self.fname = None # connect signals self.format_prev_button.connect('clicked', self.change_format_cb) self.format_next_button.connect('clicked', self.change_format_cb) self.menu_button.connect('clicked', self.back_to_main_menu_cb) self.file_chooser_button.connect('clicked', self.choose_file_cb) self.tags_button.connect('clicked', self.show_tags_dialog_cb) self.convert_button.connect('clicked', self.convert_cb) new_tag_button.connect('clicked', self.add_new_tag_cb) # update widgets content self.update_widgets( \ self.component_manager.get_current("file_format").description)
def __init__(self, component_manager): UiComponent.__init__(self, component_manager) self.client = None self.server = None self.db_path = None self.server_thread = None self.w_tree = self.main_widget().w_tree self.w_tree.signal_autoconnect(\ dict([(sig, getattr(self, sig + "_cb")) for sig in \ ("sync_to_main_menu", "activate_client_mode", \ "activate_server_mode", "start_client_sync", \ "start_server_sync")])) self.conf = self.config() self.get_widget = get_widget = self.w_tree.get_widget self.client_progressbar = get_widget("sync_mode_client_progressbar") self.server_progressbar = get_widget("sync_mode_server_progressbar") widgets_dict = {'sync_mode_client_login_entry': 'client_login', \ 'sync_mode_client_passwd_entry': 'client_passwd', \ 'sync_mode_client_address_entry': 'client_sync_address', \ 'sync_mode_client_port_entry': 'client_sync_port', \ 'sync_mode_server_login_entry': 'server_login', \ 'sync_mode_server_passwd_entry': 'server_passwd', \ 'sync_mode_server_port_entry': 'server_sync_port', \ 'sync_mode_server_address_entry': 'server_sync_address'} # Mandatory color setup for GtkEntry for widget_name, param_name in widgets_dict.items(): get_widget(widget_name).set_text(self.conf[param_name]) widget = get_widget(widget_name) widget.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse("#FFFFFF")) widget.modify_text(gtk.STATE_NORMAL, gtk.gdk.color_parse("#000000"))
def __init__(self, component_manager): UiComponent.__init__(self, component_manager) self.client = None self.server = None self.db_path = None self.server_thread = None self.conf = self.config() # create widgets self.page, self.client_progressbar, self.server_progressbar, \ self.client_start_button, self.server_start_button, \ self.role_switcher, self.client_mode_button, \ self.server_mode_button, self.client_status_label, \ self.server_status_label, self.client_login_entry, \ self.client_passwd_entry, self.client_address_entry, \ self.client_port_entry, self.server_login_entry, \ self.server_passwd_entry, self.server_address_entry, \ self.server_port_entry, self.menu_button, self.client_table, \ self.server_table = \ widgets.create_sync_ui(self.main_widget().switcher) # connect signals self.client_mode_button.connect('pressed', self.activate_client_mode_cb) self.server_mode_button.connect('pressed', self.activate_server_mode_cb) self.menu_button.connect('clicked', self.sync_to_main_menu_cb) self.client_start_button.connect('pressed', self.start_client_sync_cb) self.server_start_button.connect('pressed', self.start_server_sync_cb)
def __init__(self, component_manager): UiComponent.__init__(self, component_manager) # create widgets self.page, self.tags_box, menu_button, stat_button = \ widgets.create_tags_ui(self.main_widget().switcher) self.tags_dict = {} # connecting signals stat_button.connect('clicked', self.stat_cb) menu_button.connect('clicked', self.tags_to_main_menu_cb)
def __init__(self, component_manager, criterion, existing_names): UiComponent.__init__(self, component_manager) QtGui.QDialog.__init__(self, self.main_widget()) self.setupUi(self) self.criterion = criterion self.existing_names = existing_names if self.criterion.name: self.set_name.setText(self.criterion.name) self.set_name.selectAll() else: self.ok_button.setEnabled(False)
def __init__(self, component_manager): UiComponent.__init__(self, component_manager) self._main_widget = self.main_widget() self._main_widget.w_tree.signal_autoconnect( dict( [ (mode, getattr(self, mode + "_cb")) for mode in ["input", "review", "configure", "exit", "sync", "about"] ] ) )
def __init__(self, component_manager): UiComponent.__init__(self, component_manager) w_tree = self.main_widget().w_tree w_tree.signal_autoconnect(dict([(sig, getattr(self, sig + "_cb")) \ for sig in ('about_to_main_menu', 'show_team_info', 'show_guide')])) self.get_widget = w_tree.get_widget self.conf = self.config() self.renderer = self.component_manager.get_current('renderer') if self.config()['last_about_page'] == 0: self.show_team_info_cb(None) else: self.show_guide_cb(None)
def __init__(self, component_manager, criterion, existing_names, parent): UiComponent.__init__(self, component_manager) QtGui.QDialog.__init__(self, parent) self.setWindowFlags(self.windowFlags() \ | QtCore.Qt.WindowMinMaxButtonsHint) self.setWindowFlags(self.windowFlags() \ & ~ QtCore.Qt.WindowContextHelpButtonHint) self.setupUi(self) self.criterion = criterion self.set_name.addItem(criterion.name) if criterion.name == "": self.ok_button.setEnabled(False) for name in sorted(existing_names): self.set_name.addItem(name)
def __init__(self, component_manager): UiComponent.__init__(self, component_manager) self._main_widget = self.main_widget() # create widgets self.page, buttons = widgets.create_menu_ui(self._main_widget.switcher) # connect signals buttons['tags'].connect('clicked', self.tags_cb) buttons['review'].connect('clicked', self.review_cb) buttons['input'].connect('clicked', self.input_cb) buttons['settings'].connect('clicked', self.settings_cb) #buttons['sync'].connect('clicked', self.sync_cb) buttons['import'].connect('clicked', self.importcards_cb) buttons['stats'].connect('clicked', self.statistics_cb) buttons['help'].connect('clicked', self.about_cb) buttons['exit'].connect('clicked', self.exit_cb)
def __init__(self, component_manager): UiComponent.__init__(self, component_manager, ) # create widgets self.page, self.switcher, menu_button, about_button, help_button = \ widgets.create_about_ui(self.main_widget().switcher, os.path.join(self.config()['theme_path'], "mnemosyne.png"), os.path.join(self.config()['help_path'], "help.html")) # connect signals menu_button.connect('clicked', self.about_to_main_menu_cb) about_button.connect('released', self.show_about_cb) help_button.connect('released', self.show_help_cb) if self.config()['last_about_page'] == 0: about_button.set_active(True) self.show_about_cb(None) else: help_button.set_active(True) self.show_help_cb(None)
def __init__(self, component_manager ): UiComponent.__init__(self, component_manager) self.formats = [desc.description for desc in \ self.component_manager.get_all("file_format")] self.page, self.format_label, self.tags_box, menu_button, \ ok_button, self.file_name_label, \ self.format_prev_button, self.format_next_button, \ = create_importcard_ui( self.main_widget().window, \ self.main_widget().switcher, \ self.component_manager.get_current("file_format").description) self.tags_dict = {} # connect signals self.format_prev_button.connect('clicked', self.change_format_cb) self.format_next_button.connect('clicked', self.change_format_cb) menu_button.connect('clicked', self.back_to_main_menu_cb) ok_button.connect('clicked', self.ok_button_cb)
def __init__(self, component_manager): UiComponent.__init__(self, component_manager) self.conf = self.config() self.default_tag_name = _("<default>") self.content_type = None self.last_input_page = None self.fact = None self.tag_mode = False self.sounddir = None self.imagedir = None self.card_type = None self.selected_tags = None self.tags = sorted(self.database().get_tag_names(), \ cmp=numeric_string_cmp) or [self.default_tag_name] self.added_new_cards = False self._main_widget = self.main_widget() self._main_widget.soundplayer.stop() # create widgets self.page, card_type_button, content_button, menu_button, tags_button, \ sound_button, question_text, answer_text, foreign_text, \ pronunciation_text, translation_text, cloze_text, new_tag_button, \ new_tag_entry, tags_box, card_type_switcher, sound_container, \ question_container, toolbar_container, self.grades, tags_label, \ tags_button = widgets.create_input_ui(self._main_widget.switcher, \ self.conf["theme_path"]) # connect signals card_type_button.connect('clicked', self.show_cardtype_dialog_cb) content_button.connect('clicked', self.show_content_dialog_cb) menu_button.connect('clicked', self.input_to_main_menu_cb) tags_button.connect('clicked', self.show_tags_dialog_cb) sound_button.connect('button-press-event', self.preview_sound_in_input_cb) question_text.connect('button_release_event', self.show_media_dialog_cb) new_tag_button.connect('clicked', self.add_new_tag_cb) # create language switcher and set its callbacks for all text widgets text_widgets = [question_text, answer_text, foreign_text, pronunciation_text, translation_text, cloze_text] langswitcher = self.component_manager.get_current("langswitcher") for widget in text_widgets: widget.connect('focus-in-event', langswitcher.restore_cb) widget.connect('focus-out-event', langswitcher.save_cb) # Widgets as attributes self.areas = {"cloze": cloze_text, "answer": answer_text, "foreign": foreign_text, "pronunciation": pronunciation_text, "translation": translation_text, "question": question_text} # Change default font font = pango.FontDescription("Nokia Sans %s" % \ (self.conf['font_size'] - FONT_DISTINCTION)) for area in self.areas.values(): area.modify_font(font) self.widgets = {# Other widgets "TagsLabel": tags_label, "TagsButton": tags_button, "NewTagEntry": new_tag_entry, "TagsBox": tags_box, "CardTypeButton": card_type_button, "ContentButton": content_button, "CardTypeSwitcher": card_type_switcher, "SoundContainer": sound_container, "SoundButton": sound_button, "QuestionContainer": question_container, "ToolbarContainer": toolbar_container} # card_id: {"page": page_id, "selector": selector_widget, # "widgets": [(field_name:text_area_widget)...]} self.selectors = { FrontToBack.id: { "page": 0, "selector": None, "widgets": [('q', question_text), ('a', answer_text)]}, BothWays.id: { "page": 0, "selector": None, "widgets": [('q', question_text), ('a', answer_text)]}, ThreeSided.id: { "page": 1, "selector": None, "widgets": [('f', foreign_text), ('t', translation_text), ('p', pronunciation_text)]}, Cloze.id: { "page": 2, "selector": None, "widgets": [('text', self.areas["cloze"])]} } # add card_type to selectors subdict for card_type in self.card_types(): self.selectors[card_type.id]["card_type"] = card_type # Turn off hildon autocapitalization try: for widget in self.areas.values(): widget.set_property("hildon-input-mode", 'full') # stock gtk doesn't have hildon properties except (TypeError, AttributeError): pass # so, skip silently