def create_contents_tab(self): self.selected_word = None self.selected_offset = None def on_select_word(item, offset=None): self.selected_word = None if item is None else item[0] self.selected_offset = offset self.word_entry.set_sensitive(item is not None) self.word_spinner.set_sensitive(item is not None) if item is not None: word, score, h = item self.word_entry.set_text(word) self.word_spinner.set_value(score) self.word_widget = EditWordWidget(on_select_word) vbox = gtk.VBox() vbox.set_border_width(6) vbox.set_spacing(6) vbox.pack_start(create_scroll(self.word_widget, True, size=(300, -1))) edit_hbox = gtk.HBox() def on_word_changed(widget): word = widget.get_text().strip() self.word_widget.update(word, self.selected_offset) self.word_entry = create_entry(on_word_changed) self.word_entry.modify_font(pango.FontDescription('monospace')) def on_update(widget): score = widget.get_value_as_int() self.word_widget.update_score(score, self.selected_offset) word = self.word_widget.get_selected_word() self.current_wlist.update_score(word, score) self.word_spinner = create_spinner(0, 0, 100, f_change=on_update) self.clear_word_edit_controls() edit_hbox.pack_start(self.word_entry) edit_hbox.pack_start(self.word_spinner, False, False) vbox.pack_start(edit_hbox, False, False) def on_edit_scores(button): on_done = lambda window: window.get_settings() response, settings = launch_dialog(WordListScoreDialog, self , self.current_wlist, f_done=on_done) if response == gtk.RESPONSE_APPLY: self.clear_word_edit_controls() self.current_wlist.change_scores(*settings) self.word_widget.set_words(get_words_by_length(self.current_wlist)) self.scores_button = create_button(u"Edit scores", f_click=on_edit_scores, align=(0, 0)) self.wlist_sensitives.append(self.scores_button) self.scores_button.set_sensitive(False) vbox.pack_start(self.scores_button, False, False) hbox = gtk.HBox() hbox.set_spacing(6) vbox.pack_start(hbox, False, False) return vbox
def create_contents_tab(self): self.word_widget = EditWordWidget() vbox = gtk.VBox() vbox.set_border_width(6) vbox.set_spacing(6) vbox.pack_start(create_scroll(self.word_widget, True, size=(300, -1))) hbox = gtk.HBox() hbox.set_spacing(6) vbox.pack_start(hbox, False, False, 0) return vbox
def __init__(self, mode=constants.VIEW_MODE_PREVIEW, header="Preview", cell_size=16): gtk.VBox.__init__(self) self.cell_size = cell_size self.view = None self.preview_surface = None self.preview_pattern = None self.render_mode = mode self.drawing_area = create_drawing_area(self.on_expose_event) self.scrolled_window = create_scroll(self.drawing_area, viewport=True) self.pack_start(create_label("<b>" + header + "</b>"), False, False, 6) self.pack_start(self.scrolled_window)