コード例 #1
0
ファイル: gui_word.py プロジェクト: svisser/palabra
 def __init__(self, parent, puzzle):
     super(AccidentalWordsDialog, self).__init__(parent, u"View accidental words")
     self.puzzle = puzzle
     self.wordlists = parent.wordlists
     self.index = 0
     self.collapse = True
     self.timer = None
     wlist_hbox = gtk.HBox(False, 0)
     wlist_hbox.pack_start(create_label(u"Check for words in list:"), True, True, 0)
     def on_wordlist_changed(widget):
         self.index = widget.get_active()
         self.launch_accidental(self.puzzle.grid)
     combo = create_combo([w.name for w in self.wordlists]
         , active=self.index, f_change=on_wordlist_changed)
     wlist_hbox.pack_start(combo, False, False, 0)
     self.main.pack_start(wlist_hbox, False, False, 0)
     self.store, self.tree, s_window = create_tree((str, str)
         , [(u"Word", 0)], window_size=(300, 300))
     self.tree.get_selection().connect("changed", self.on_selection_changed)
     self.main.pack_start(s_window, True, True, 0)
     self.main.pack_start(create_label(u"Click to highlight the word(s) in the grid."), False, False, 0)
     def collapse_callback(button):
         self.collapse = button.get_active()
         self.launch_accidental(self.puzzle.grid)
     button = gtk.CheckButton("Collapse multiple occurrences into one item.")
     button.connect("toggled", collapse_callback)
     button.set_active(self.collapse)
     self.main.pack_start(button, False, False, 0)
     self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
     destroy = lambda w: highlight_cells(self.pwindow, self.puzzle, clear=True)
     self.connect("destroy", destroy)
     self.launch_accidental(puzzle.grid)
コード例 #2
0
ファイル: gui_word.py プロジェクト: svisser/palabra
 def __init__(self, parent):
     super(FindWordsDialog, self).__init__(parent, u"Find words")
     self.wordlists = parent.wordlists
     self.sort_option = 0
     self.pattern = None
     self.pack(create_label(u"Use ? for an unknown letter and * for zero or more unknown letters."))
     def on_entry_changed(widget):
         glib.source_remove(self.timer)
         self.launch_pattern(widget.get_text().strip())
     self.pack(create_entry(f_change=on_entry_changed), False)
     # word path score
     self.store, self.tree, s_window = create_tree((str, str, int)
         , [(u"Word", 0), (u"Word list", 1), (u"Score", 2)]
         , window_size=(-1, 300)
     )
     self.tree.get_column(0).set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
     self.tree.get_column(0).set_fixed_width(250)
     self.pack(s_window)
     self.n_label = create_label("")
     self.set_n_label(0)
     self.pack(self.n_label, False)
     sort_hbox = gtk.HBox(False, 6)
     sort_hbox.pack_start(create_label(u"Sort by:"), False, False, 0)
     def on_sort_changed(combo):
         self.sort_option = combo.get_active()
         self.launch_pattern(self.pattern)
     sort_hbox.pack_start(create_combo(["Alphabet", "Length", "Score"]
         , active=self.sort_option, f_change=on_sort_changed))
     self.pack(sort_hbox, False)
     self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
     self.launch_pattern(None)
コード例 #3
0
ファイル: gui_word.py プロジェクト: svisser/palabra
    def create_find_words(self, parent):
        hbox = gtk.HBox()
        hbox.set_spacing(9)
        # name path
        self.store, self.tree, s_window = create_tree((str, str)
            , [("Available word lists", 0)]
            , f_sel=self.on_tree_selection_changed
            , window_size=(256, 196))
        hbox.pack_start(s_window, True, True, 0)

        button_vbox = gtk.VBox()
        self.add_wlist_button = gtk.Button(stock=gtk.STOCK_ADD)
        self.add_wlist_button.connect("clicked", self.on_add_clicked)
        button_vbox.pack_start(self.add_wlist_button, True, False, 0)
        self.remove_wlist_button = gtk.Button(stock=gtk.STOCK_REMOVE)
        self.remove_wlist_button.connect("clicked", self.on_remove_clicked)
        button_vbox.pack_start(self.remove_wlist_button, True, False, 0)
        self.add_wlist_button.set_sensitive(False)
        self.remove_wlist_button.set_sensitive(False)
        hbox.pack_start(button_vbox, True, True, 0)

        # name path
        self.store2, self.tree2, s_window2 = create_tree((str, str)
            , [("Word lists for finding words", 0)]
            , f_sel=self.on_tree2_selection_changed
            , window_size=(256, 196))
        hbox.pack_start(s_window2, True, True, 0)

        # populate list stores
        c_find = preferences.prefs[constants.PREF_FIND_WORD_FILES]
        wlists1 = [w for w in parent.wordlists if w.path not in c_find]
        wlists2 = [w for w in parent.wordlists if w.path in c_find]
        for wlist in wlists1:
            self.store.append([wlist.name, wlist.path])
        for wlist in wlists2:
            self.store2.append([wlist.name, wlist.path])

        vbox = gtk.VBox()
        vbox.set_border_width(9)
        vbox.set_spacing(9)
        score_hbox = gtk.HBox()
        score_hbox.set_spacing(9)
        score_hbox.pack_start(create_label(u"Minimum word score:"), False, False, 0)
        value = preferences.prefs[constants.PREF_FIND_WORD_MIN_SCORE]
        adj = gtk.Adjustment(value, 0, 100, 1, 0, 0)
        self.find_min_score_spinner = gtk.SpinButton(adj, 0.0, 0)
        score_hbox.pack_start(self.find_min_score_spinner, False, False, 0)
        vbox.pack_start(hbox)
        vbox.pack_start(score_hbox, False, False, 0)
        label = create_label(u"These settings are loaded when you start " + constants.TITLE + ".")
        vbox.pack_start(label, False, False, 0)
        return vbox
コード例 #4
0
ファイル: gui_editor.py プロジェクト: svisser/palabra
    def create(self):
        main = gtk.VBox(False, 0)
        main.set_spacing(9)

        def on_fill_button_clicked(button):
            self.editor.fill()
        button = create_button(u"Fill", f_click=on_fill_button_clicked)
        main.pack_start(button, False, False, 0)

        start_combo = gtk.combo_box_new_text()
        for i, (c, txt) in enumerate(self.starts):
            start_combo.append_text(txt)
            if c == self.editor.fill_options[constants.FILL_OPTION_START]:
                start_combo.set_active(i)
        def on_start_changed(combo):
            self.editor.fill_options[constants.FILL_OPTION_START] = self.starts[combo.get_active()][0]
        start_combo.connect("changed", on_start_changed)

        main.pack_start(create_label(u"Start filling from:"), False, False, 0)
        main.pack_start(start_combo, False, False, 0)

        hbox = gtk.HBox(False, 0)
        hbox.set_border_width(6)
        hbox.set_spacing(6)
        hbox.pack_start(main, True, True, 0)
        return hbox
コード例 #5
0
ファイル: gui_word.py プロジェクト: svisser/palabra
    def __init__(self, parent, wlist):
        super(WordListScoreDialog, self).__init__(parent, u"Edit scores of words in word list")
        self.set_size_request(480, -1)
        self.wlist = wlist
        self.pack(create_label(u"Currently editing: " + wlist.path + " (" + wlist.name + ")"))

        def on_select_option(widget, arg):
            if widget.get_active() == 1:
                self.spin_to.set_sensitive(arg == "to")
                self.spin_by.set_sensitive(arg == "by")

        b1 = create_radio(u"Change all score by:", active=True, f_toggle=on_select_option, f_arg="by")
        self.spin_by = create_spinner(-1, -50, 50)
        self.spin_by.set_sensitive(True)
        b2 = create_radio(u"Change all scores to:", prev=b1, f_toggle=on_select_option, f_arg="to")
        self.spin_to = create_spinner(50)
        self.spin_to.set_sensitive(False)

        table = gtk.Table(2, 2)
        table.set_col_spacings(6)
        table.set_row_spacings(6)
        table.attach(b1, 0, 1, 0, 1)
        align = gtk.Alignment()
        align.add(self.spin_by)
        table.attach(align, 1, 2, 0, 1)
        table.attach(b2, 0, 1, 1, 2)
        align = gtk.Alignment()
        align.add(self.spin_to)
        table.attach(align, 1, 2, 1, 2)
        self.pack(table)

        self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
        self.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_APPLY)
コード例 #6
0
ファイル: clue.py プロジェクト: svisser/palabra
 def __init__(self, parent):
     PalabraDialog.__init__(self, parent, u"Manage clue databases")
     self.pwindow = parent
     self.store, self.tree, window = create_tree((str, str)
         , [(u"Name", 0), (u"Path", 1)]
         , f_sel=self.on_file_selected
         , window_size=(300, 300))
     self.pack(window)
     buttonbox = gtk.HButtonBox()
     buttonbox.set_layout(gtk.BUTTONBOX_START)
     self.add_file_button = create_stock_button(gtk.STOCK_ADD
         , f_click=lambda b: self.on_add_clue_db())
     buttonbox.pack_start(self.add_file_button, False, False)
     self.props_button = create_stock_button(gtk.STOCK_PROPERTIES, f_click=lambda b: self.on_properties())
     buttonbox.pack_start(self.props_button, False, False)
     self.props_button.set_sensitive(False)
     self.remove_button = create_stock_button(gtk.STOCK_REMOVE
         , f_click=lambda b: self.on_remove_db())
     buttonbox.pack_start(self.remove_button, False, False)
     self.remove_button.set_sensitive(False)
     self.pack(buttonbox)
     label = create_label(u"These clue databases are loaded when you start " + constants.TITLE + ".")
     self.pack(label, False)
     self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
     self.load_clue_files(parent.clues)
コード例 #7
0
ファイル: appearance.py プロジェクト: klochner/palabra
 def create_font_controls(title, key_color, key_size):
     label = create_label(title)
     button = create_color_button(properties[key_color], self.on_update)
     adj = gtk.Adjustment(properties[key_size][0], 10, 100, 1, 0, 0)
     spinner = gtk.SpinButton(adj)
     spinner.connect("value-changed", self.on_update)
     return label, button, spinner
コード例 #8
0
ファイル: gui_word.py プロジェクト: svisser/palabra
 def __init__(self, parent, unable):
     super(WordListUnableToStoreDialog, self).__init__(parent, u"Unable to store word list(s)")
     self.main.pack_start(create_label(constants.TITLE + " was unable to store the following word lists:"))
     self.store, self.tree, window = create_tree(str, [(u"Word list", 0)])
     for name, error in unable:
         self.store.append([name + " (" + error + ")"])
     window.set_size_request(200, 300)
     self.main.pack_start(window, True, True, 0)
     self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
コード例 #9
0
ファイル: gui_editor.py プロジェクト: klochner/palabra
    def create(self):
        img = gtk.Image()
        img.set_from_file(get_real_filename("resources/icon1.png"))

        def on_button_toggled(self, button):
            self.show_intersect = button.get_active()
            self.display_words()

        toggle_button = gtk.ToggleButton()
        toggle_button.set_property("image", img)
        toggle_button.set_tooltip_text(u"Show only words with intersecting words")
        toggle_button.connect("toggled", lambda b: on_button_toggled(self, b))

        img = gtk.Image()
        img.set_from_file(get_real_filename("resources/icon2.png"))

        def on_button2_toggled(self, button):
            self.show_used = not button.get_active()
            self.display_words()

        toggle_button2 = gtk.ToggleButton()
        toggle_button2.set_property("image", img)
        toggle_button2.set_tooltip_text(u"Show only unused words")
        toggle_button2.connect("toggled", lambda b: on_button2_toggled(self, b))

        buttons = gtk.HButtonBox()
        buttons.set_layout(gtk.BUTTONBOX_START)
        buttons.add(toggle_button)
        buttons.add(toggle_button2)

        self.main = gtk.VBox(False, 0)
        self.main.set_spacing(9)
        self.main.pack_start(buttons, False, False, 0)

        self.view = EditorWordWidget(self.parent)
        sw = gtk.ScrolledWindow(None, None)
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.add_with_viewport(self.view)
        self.main.pack_start(sw, True, True, 0)

        show_hbox = gtk.HBox()
        show_hbox.pack_start(create_label(u"Sort words by:"))

        def on_show_changed(widget):
            self.show_order = widget.get_active()
            self.display_words()

        show_combo = create_combo(WORD_DISPLAY_OPTIONS, active=self.show_order, f_change=on_show_changed)
        show_hbox.pack_start(show_combo)
        self.main.pack_start(show_hbox, False, False, 0)

        hbox = gtk.HBox(False, 0)
        hbox.set_border_width(6)
        hbox.set_spacing(6)
        hbox.pack_start(self.main, True, True, 0)
        return hbox
コード例 #10
0
ファイル: gui_word.py プロジェクト: klochner/palabra
 def __init__(self, parent):
     super(WordListManager, self).__init__(parent, u"Manage word lists")
     self.palabra_window = parent
     self.modifications = set()
     # name path
     self.store, self.tree, s_window = create_tree((str, str)
         , [(u"Name", 0), (u"Path", 1)]
         , f_sel=self.on_selection_changed
         , window_size=(400, 400))
     self.current_wlist = None
     self.add_wlist_button = create_stock_button(gtk.STOCK_ADD, lambda b: self.add_word_list())
     self.rename_button = create_button(u"Rename", f_click=lambda b: self.rename_word_list())
     def show_word_list_props():
         w = WordListPropertiesDialog(self, self.current_wlist)
         w.show_all()
         w.run()
         w.destroy()
     self.props_button = create_stock_button(gtk.STOCK_PROPERTIES, lambda b: show_word_list_props())
     self.remove_button = create_stock_button(gtk.STOCK_REMOVE, lambda b: self.remove_word_list())
     buttonbox = gtk.HButtonBox()
     buttonbox.set_layout(gtk.BUTTONBOX_START)
     buttonbox.pack_start(self.add_wlist_button)
     buttonbox.pack_start(self.rename_button)
     buttonbox.pack_start(self.props_button)
     buttonbox.pack_start(self.remove_button)
     self.wlist_sensitives = [self.rename_button, self.props_button, self.remove_button]
     for b in self.wlist_sensitives:
         b.set_sensitive(False)
     wlist_vbox = gtk.VBox()
     wlist_vbox.set_spacing(12)
     wlist_vbox.pack_start(create_label("<b>Word lists</b>"), False, False, 0)
     wlist_vbox.pack_start(s_window)
     wlist_vbox.pack_start(buttonbox, False, False, 0)
     main = gtk.HBox()
     main.set_spacing(18)
     main.pack_start(wlist_vbox, False, False, 0)
     main.pack_start(self.create_contents_tab())
     self.main.pack_start(main)
     label = create_label(u"These word lists are loaded when you start " + constants.TITLE + ".")
     self.main.pack_start(label, False, False, 0)
     self.display_wordlists()
     self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
コード例 #11
0
ファイル: view.py プロジェクト: klochner/palabra
 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)
コード例 #12
0
ファイル: clue.py プロジェクト: svisser/palabra
 def create_entry(self, vbox, key, title):
     entry = gtk.Entry()
     def changed(widget):
         if self.timer is not None:
             glib.source_remove(self.timer)
         self.timer = glib.timeout_add(constants.INPUT_DELAY_VERY_SHORT
         , self.on_clue_changed, key, widget.get_text())
     c_id = entry.connect("changed", changed)
     entry.set_sensitive(False)
     vbox.pack_start(create_label(title), False, False, 3)
     vbox.pack_start(entry, False, False, 0)
     return entry, c_id
コード例 #13
0
ファイル: gui_word.py プロジェクト: svisser/palabra
 def create_blacklist(self, parent):
     vbox = gtk.VBox()
     vbox.set_border_width(9)
     vbox.set_spacing(9)
     self.blacklist_combo = create_combo([''] + [w.name for w in self.wordlists])
     for i, wlist in enumerate(self.wordlists):
         if preferences.prefs[constants.PREF_BLACKLIST] == wlist.path:
             self.blacklist_combo.set_active(i + 1)
             break
     vbox.pack_start(create_label(u"Word list to be used as blacklist:"), False, False, 0)
     vbox.pack_start(self.blacklist_combo, False, False, 0)
     return vbox
コード例 #14
0
ファイル: gui_word.py プロジェクト: svisser/palabra
 def __init__(self, parent, puzzle):
     super(SimilarWordsDialog, self).__init__(parent, u"View similar words")
     self.puzzle = puzzle
     self.store, self.tree, scrolled_window = create_tree((str, str)
         , [(u"Similar words", 1)]
         , f_sel=self.on_selection_changed
         , window_size=(512, 384))
     self.main.pack_start(scrolled_window, True, True, 0)
     self.main.pack_start(create_label(u"Click to highlight the words in the grid."), False, False, 0)
     self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
     destroy = lambda w: highlight_cells(self.pwindow, self.puzzle, clear=True)
     self.connect("destroy", destroy)
     self.entries = word.similar_entries(word.similar_words(puzzle.grid))
     self.load_entries(self.entries)
コード例 #15
0
ファイル: pattern.py プロジェクト: svisser/palabra
    def __init__(self, parent, size=None):
        super(GridEditor, self).__init__(parent, u"Grid editor", horizontal=True)
        self.size = size if size else (15, 15)

        table = gtk.Table(2, 2, False)

        radio = gtk.RadioButton(None, u"Tile from: ")
        radio.connect("toggled", self.on_option_toggle, "tile")
        self.tile_starts = [(p, q) for q in xrange(2) for p in xrange(2)]
        self.tile_combo = gtk.combo_box_new_text()
        self.tile_combo.append_text(u"")
        for x, y in self.tile_starts:
            content = str(''.join(["(", str(x + 1), ",", str(y + 1), ")" ]))
            self.tile_combo.append_text(content)
        self.tile_combo.connect("changed", self.on_tile_changed)
        table.attach(radio, 0, 1, 0, 1)
        table.attach(self.tile_combo, 1, 2, 0, 1)

        radio = gtk.RadioButton(radio, u"Fill with: ")
        radio.connect("toggled", self.on_option_toggle, "fill")
        self.fill_combo = create_combo([u"", u"Block"], f_change=self.on_fill_changed)
        table.attach(radio, 0, 1, 1, 2)
        table.attach(self.fill_combo, 1, 2, 1, 2)

        self.preview = GridPreview()
        self.preview.set_size_request(384, 384)

        alignment = gtk.Alignment()
        alignment.add(table)
        vbox2 = gtk.VBox(False, 6)
        vbox2.pack_start(create_label(u"<b>Options</b>"), False, False, 0)
        vbox2.pack_start(alignment, False, False, 0)
        self.pack(vbox2, False)
        self.pack(self.preview, False)

        self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
        self.ok_button = self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
        self.ok_button.set_sensitive(False)
        self._select_option("tile")
        self.display_pattern(None)
コード例 #16
0
ファイル: appearance.py プロジェクト: klochner/palabra
    def create_content(self, properties):
        main = gtk.VBox()
        main.set_spacing(6)

        table = gtk.Table(10, 3)
        table.set_col_spacings(6)
        table.set_row_spacings(6)
        main.pack_start(table)

        def create_label(label):
            align = gtk.Alignment(0, 0.5)
            align.set_padding(0, 0, 12, 0)
            align.add(gtk.Label(label))
            return align

        def create_width_spinner(current):
            adj = gtk.Adjustment(current, 1, constants.MAX_LINE_WIDTH, 1, 0, 0)
            button = gtk.SpinButton(adj, 0.0, 0)
            return button

        def create_row(table, y, label, c1, c2=None):
            table.attach(label, 0, 1, y, y + 1, gtk.FILL, gtk.FILL)
            table.attach(c1, 1, 2, y, y + 1, 0, 0)
            if c2 is not None:
                table.attach(c2, 2, 3, y, y + 1, 0, 0)

        table.attach(create_label(u"Color"), 1, 2, 0, 1, gtk.FILL, gtk.FILL)
        table.attach(create_label(u"Width (px)"), 2, 3, 0, 1, gtk.FILL, gtk.FILL)

        def create_line_controls(title, key_color, key_width):
            label = create_label(title)
            button = create_color_button(properties[key_color], self.on_update)
            spinner = create_width_spinner(properties[key_width])
            return label, button, spinner

        # borders and lines
        widgets = create_line_controls(u"Border:", ("border", "color"), ("border", "width"))
        self.border_color_button = widgets[1]
        self.border_width_spinner = widgets[2]
        create_row(table, 1, *widgets)
        widgets = create_line_controls(u"Line:", ("line", "color"), ("line", "width"))
        self.line_color_button = widgets[1]
        self.line_width_spinner = widgets[2]
        create_row(table, 2, *widgets)

        def cap_line_width_at(bound):
            s = self.line_width_spinner
            adj = s.get_adjustment()
            adj.set_upper(bound)
            if s.get_value_as_int() > bound:
                s.set_value(bound)

        def on_border_width_update(widget):
            cap_line_width_at(widget.get_value_as_int())
            self.on_update()

        self.border_width_spinner.connect("value-changed", on_border_width_update)
        self.line_width_spinner.connect("value_changed", self.on_update)
        cap_line_width_at(properties["border", "width"])

        table.attach(create_label(u"Color"), 1, 2, 3, 4, gtk.FILL, gtk.FILL)
        table.attach(create_label(u"Size (%)"), 2, 3, 3, 4, gtk.FILL, gtk.FILL)

        def create_font_controls(title, key_color, key_size):
            label = create_label(title)
            button = create_color_button(properties[key_color], self.on_update)
            adj = gtk.Adjustment(properties[key_size][0], 10, 100, 1, 0, 0)
            spinner = gtk.SpinButton(adj)
            spinner.connect("value-changed", self.on_update)
            return label, button, spinner

        # letters and numbers
        widgets = create_font_controls(u"Letter:", ("char", "color"), ("char", "size"))
        self.char_color_button = widgets[1]
        self.char_size_spinner = widgets[2]
        create_row(table, 4, *widgets)
        widgets = create_font_controls(u"Number:", ("number", "color"), ("number", "size"))
        self.number_color_button = widgets[1]
        self.number_size_spinner = widgets[2]
        create_row(table, 5, *widgets)

        # cells
        table.attach(create_label(u"Color"), 1, 2, 6, 7, gtk.FILL, gtk.FILL)
        table.attach(create_label(u"Size (px)"), 2, 3, 6, 7, gtk.FILL, gtk.FILL)

        label = create_label(u"Cell:")
        self.cell_color_button = create_color_button(properties["cell", "color"], self.on_update)
        adj = gtk.Adjustment(properties["cell", "size"], 32, 128, 1, 0, 0)
        self.cell_size_spinner = gtk.SpinButton(adj, 0.0, 0)
        self.cell_size_spinner.connect("value-changed", self.on_update)
        create_row(table, 7, label, self.cell_color_button, self.cell_size_spinner)

        # blocks
        table.attach(create_label(u"Color"), 1, 2, 8, 9, gtk.FILL, gtk.FILL)
        table.attach(create_label(u"Margin (%)"), 2, 3, 8, 9, gtk.FILL, gtk.FILL)

        current = properties["block", "margin"]
        label = create_label(u"Block:")
        self.block_color_button = create_color_button(properties["block", "color"], self.on_update)
        adj = gtk.Adjustment(current, 0, 49, 1, 0, 0)
        self.block_margin_spinner = gtk.SpinButton(adj, 0.0, 0)
        self.block_margin_spinner.connect("value-changed", self.on_update)
        create_row(table, 9, label, self.block_color_button, self.block_margin_spinner)
        return main
コード例 #17
0
ファイル: clue.py プロジェクト: svisser/palabra
    def create(self, puzzle):
        vbox = gtk.VBox()
        vbox.set_spacing(6)
        vbox.set_border_width(6)
        result = self.create_entry(vbox, "text", u"<b>Clue</b>")
        self.clue_entry, self.c_changed_id = result

        def on_cycle_clue(target):
            it = store_get_item(target, *self.tree.get_selection().get_selected())
            self.select_iter(self.tree.get_model(), it)
        f_next = lambda b: on_cycle_clue("next")
        f_prev = lambda b: on_cycle_clue("previous")
        np_box = gtk.HButtonBox()
        self.prev_button = create_button(u"Previous", f_click=f_prev)
        self.next_button = create_button(u"Next", f_click=f_next)
        np_box.pack_start(self.prev_button)
        np_box.pack_start(self.next_button)
        align = gtk.Alignment(1, 0.5)
        align.add(np_box)
        vbox.pack_start(align, False, False, 0)

        # number x y direction word clue explanation displayed_string
        types = (int, int, int, str, str, str, str, str)
        self.store, self.tree, window, self.selection_id = create_tree(types
            , [(u"", 7)]
            , f_sel=self.on_selection_changed
            , return_id=True)
        vbox.pack_start(gtk.HSeparator(), False, False, 0)

        o_vbox = gtk.VBox()
        o_vbox.set_spacing(6)
        o_vbox.set_border_width(6)
        result = self.create_entry(o_vbox, "explanation", u"<b>Explanation</b>")
        self.explanation_entry, self.e_changed_id = result

        w_hbox = gtk.HBox()
        w_hbox.set_spacing(6)
        w_hbox.pack_start(create_label(u"Word:"), False, False, 0)
        w_entry = gtk.Entry()
        def on_word_changed(widget):
            self.load_clues_for_word(widget.get_text().strip())
        w_entry.connect("changed", on_word_changed)
        w_hbox.pack_start(w_entry)

        l_vbox = gtk.VBox()
        l_vbox.set_spacing(6)
        l_vbox.set_border_width(6)

        l_vbox.pack_start(create_label(u"<b>Lookup clues</b>"), False, False, 0)
        l_vbox.pack_start(w_hbox, False, False, 0)
        self.c_store, self.c_tree, c_window = create_tree(str
            , [(u"Clues", 0)]
            , f_sel=self.on_clue_selected)
        l_vbox.pack_start(c_window, True, True, 0)
        self.use_clue_button = create_button(u"Use clue"
            , align=(0, 0.5), f_click=self.on_use_clicked)
        self.use_clue_button.set_sensitive(False)
        l_vbox.pack_start(self.use_clue_button, False, False, 0)

        pages = [(window, u"Words and clues")
            , (l_vbox, u"Lookup")
            , (o_vbox, u"Advanced")
        ]
        vbox.pack_start(create_notebook(pages, border=(4, 2)))
        self.tree.set_headers_visible(False)
        self.load_items(puzzle.grid)
        return vbox
コード例 #18
0
ファイル: gui_word.py プロジェクト: klochner/palabra
 def create_row(y, title, info):
     table.attach(create_label(title), 0, 1, y, y + 1)
     info_label = create_label(info, align=(1, 0))
     table.attach(info_label, 1, 2, y, y + 1)
     return info_label
コード例 #19
0
ファイル: appearance.py プロジェクト: klochner/palabra
 def create_line_controls(title, key_color, key_width):
     label = create_label(title)
     button = create_color_button(properties[key_color], self.on_update)
     spinner = create_width_spinner(properties[key_width])
     return label, button, spinner
コード例 #20
0
ファイル: appearance.py プロジェクト: klochner/palabra
    def __init__(self, palabra_window, properties):
        super(CellPropertiesDialog, self).__init__(palabra_window, u"Cell properties")
        self.palabra_window = palabra_window
        self.properties = properties
        x, y = properties["cell"]
        c1 = (u"Background color", ("cell", "color"))
        c2 = (u"Block color", ("block", "color"))
        c3 = (u"Letter color", ("char", "color"))
        c4 = (u"Number color", ("number", "color"))
        self.colors = [c1, c2, c3, c4]

        self.grid = Grid(1, 1)
        self.grid.data[0][0].update(properties["grid"].data[y][x])

        table = gtk.Table(3, 3, False)
        table.set_col_spacings(6)
        table.set_row_spacings(6)

        def create_row(table, title, value, x, y):
            table.attach(create_label(title), x, x + 1, y, y + 1, gtk.FILL, gtk.FILL)
            table.attach(create_label(value, align=(0, 0)), x + 1, x + 2, y, y + 1)

        def create_color_row(table, title, b_align, r_align, x, y):
            table.attach(create_label(title), x, x + 1, y, y + 1, gtk.FILL, gtk.FILL)
            table.attach(b_align, x + 1, x + 2, y, y + 1)
            table.attach(r_align, x + 2, x + 3, y, y + 1)

        on_color_set = lambda button, key: self._on_update(key, color_tuple(button))
        for i, (title, key) in enumerate(self.colors):
            attr = "_".join(list(key) + ["button"])
            setattr(self, attr, create_color_button(properties[key]))
            getattr(self, attr).connect("color-set", on_color_set, key)
            attr2 = "_".join(list(key) + ["reset", "button"])
            setattr(self, attr2, gtk.Button(u"Reset"))
            getattr(self, attr2).connect("clicked", self.on_color_reset, key)
            b_align = gtk.Alignment(0, 0.5)
            b_align.add(getattr(self, attr))
            r_align = gtk.Alignment(0, 0.5)
            r_align.add(getattr(self, attr2))
            create_color_row(table, title, b_align, r_align, 0, i)

        table.attach(create_label(u"Other options"), 0, 1, 4, 5, gtk.FILL, gtk.FILL)
        on_circle = lambda b: self._on_update("circle", b.get_active())
        self.circle_button = create_check_button(u"Display circle", active=properties["circle"], f_toggle=on_circle)
        table.attach(self.circle_button, 1, 3, 4, 5)

        main = gtk.VBox()
        main.set_spacing(6)
        main.pack_start(create_label(u"<b>Properties</b>"), False, False, 0)
        main.pack_start(table, False, False, 0)
        content = gtk.HBox()
        content.set_border_width(6)
        content.set_spacing(6)
        content.pack_start(main)

        self.previews = []
        prevs = gtk.VBox()
        p1 = (constants.VIEW_MODE_PREVIEW_CELL, "Puzzle")
        p2 = (constants.VIEW_MODE_PREVIEW_SOLUTION, "Solution")
        for m, h in [p1, p2]:
            p = GridPreview(mode=m, header=h, cell_size=96)
            p.set_size_request(164, 164)
            align = gtk.Alignment()
            align.add(p)
            self.previews.append(p)
            p.display(self.grid)
            for k in DEFAULTS_CELL:
                p.view.properties[k] = properties[k]
            p.refresh()
            prevs.pack_start(align, False, False, 0)
        content.pack_start(prevs, False, False, 0)
        self.pack(content)
        self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
        self.add_button(gtk.STOCK_APPLY, gtk.RESPONSE_OK)
コード例 #21
0
ファイル: appearance.py プロジェクト: klochner/palabra
 def create_row(table, title, value, x, y):
     table.attach(create_label(title), x, x + 1, y, y + 1, gtk.FILL, gtk.FILL)
     table.attach(create_label(value, align=(0, 0)), x + 1, x + 2, y, y + 1)
コード例 #22
0
ファイル: appearance.py プロジェクト: klochner/palabra
 def create_color_row(table, title, b_align, r_align, x, y):
     table.attach(create_label(title), x, x + 1, y, y + 1, gtk.FILL, gtk.FILL)
     table.attach(b_align, x + 1, x + 2, y, y + 1)
     table.attach(r_align, x + 2, x + 3, y, y + 1)