def __init__(self): Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL) self.result = Gtk.Label() self.typer = Typer() self.label = Gtk.Label(wrap=True, xalign=0, yalign=1) update_result_vis = lambda: self.result.set_visible( Settings.get("show_last")) update_result_vis() sync_font = lambda: self.label.override_font( Pango.FontDescription.from_string(Settings.get("typer_font"))) sync_font() self.typer.connect("done", lambda *_: self.done()) self.typer.connect("want-text", lambda *_: self.emit("want-text")) Settings.connect("change_typer_font", sync_font) Settings.connect("change_show_last", update_result_vis) self.text = ("", 0, "") self.pack_start(self.result, False, False, 0) body = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, homogeneous=True, spacing=24) body.add(self.label) body.add(self.typer) self.pack_start(body, True, True, 0)
def __init__(self): GtkUtil.AmphBoxLayout.__init__(self, orientation=Gtk.Orientation.HORIZONTAL) self.diff_eval = lambda x: 1 self.model = SourceModel() treeview = GtkUtil.AmphTreeView(self.model) self.tree = treeview.treeview self.tree.connect("row-activated", self.double_clicked) self.tree.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE) self.progress = Gtk.ProgressBar() self.append_layout( [[ "Below you will see the different text sources used. Disabling" " texts or sources deactivates them so they won't be selected for" " typing. You can double click a text to do that particular text.\n", (treeview, ), self.progress, [ GtkUtil.new_button("Import Texts", self.add_files), GtkUtil.new_button("Enable All", self.enable_all), GtkUtil.new_button( "Delete Disabled", self.delete_disabled), GtkUtil.new_button("Update List", self.update) ], [ GtkUtil.new_button("Toggle", self.toggle_selected), " all selected text" ], ], [ [ "Selection method for new lessons", SettingsCombo('select_method', ['Random', 'In Order', 'Difficult', 'Easy']) ], "(in order works by selecting the next text after the one you" " completed last, in the order they were added to the database," " easy/difficult works by estimating your WPM for several random" " texts and choosing the fastest/slowest)\n", 0, "Repeat texts that don't meet the following requirements", ["WPM:", SettingsEdit("min_wpm")], ["Accuracy:", SettingsEdit("min_acc")], "Repeat lessons that don't meet the following requiements", ["WPM:", SettingsEdit("min_lesson_wpm")], ["Accuracy:", SettingsEdit("min_lesson_acc")], ]]) Settings.connect("change_select_method", lambda *_: self.set_select()) self.set_select()
def __init__(self): GtkUtil.AmphBoxLayout.__init__(self) self.model = WordModel() treeview = GtkUtil.AmphTreeView(self.model) self.update() which = SettingsCombo('ana_which', [ ('wpm asc', 'slowest'), ('wpm desc', 'fastest'), ('viscosity desc', 'least fluid'), ('viscosity asc', 'most fluid'), ('accuracy asc', 'least accurate'), ('misses desc', 'most mistyped'), ('total desc', 'most common'), ('damage desc', 'most damaging'), ]) what = SettingsCombo('ana_what', ['keys', 'trigrams', 'words']) lim = SettingsEdit('ana_many') mincount = SettingsEdit('ana_count') # XXX why are sometimes no args provided, sometimes Config.Settings? Settings.connect("change_ana_which", lambda *_: self.update()) Settings.connect("change_ana_what", lambda *_: self.update()) Settings.connect("change_ana_many", lambda *_: self.update()) Settings.connect("change_ana_count", lambda *_: self.update()) # TODO send lessons to generator send_to_generator = lambda: None self.append_layout([ [ "Display statistics about the", which, what, None, GtkUtil.new_button("Update list", self.update), GtkUtil.new_button("Send list to Lesson Generator", send_to_generator) ], [ "Limit list to", lim, "items and don't show items with a count less than", mincount ], (treeview, ), ])
def __init__(self): self.strings = StringListWidget() self.sample = Gtk.TextView( wrap_mode=Gtk.WrapMode.WORD, editable=False ) self.lesson_name_field = Gtk.Entry() scroll_sample = Gtk.ScrolledWindow() scroll_sample.add(self.sample) combo_what = SettingsCombo('str_what', [('e', 'encompassing'), ('s', 'similar'), ('r', 'random')]) layout = [ "Welcome to Amphetype's automatic lesson generator!", "You can retrieve a list of words/keys/trigrams to practice from the Analysis tab," " import from an external file, or even type in your own (separated by space).\n", 10, ["In generating lessons, I will make", SettingsEdit("gen_copies"), "copies of the list below and divide them into sublists of size", SettingsEdit("gen_take"), "(0 for all)"], ["I will then", SettingsCombo("gen_mix", [('c', "concatenate"), ('m', "commingle")]), "corresponding sublists into atomic building blocks which are fashioned into lessons" " according to your lesson size preferences."], [["Input words", self.strings, [ SettingsCombo("str_clear", [('s', "Supplement"), ('r', "Replace")]), "list with", SettingsEdit("str_extra"), combo_what, "words from", GtkUtil.new_button("a file", self.strings.add_from_file), "or", GtkUtil.new_button("analysis database", self.strings.add_from_typed)]], ["Lessons", scroll_sample, [ GtkUtil.new_button("Add to sources", self.accept_lessons), "with name", self.lesson_name_field]] ], ] GtkUtil.AmphBoxLayout.__init__(self, layout) Settings.connect("change_gen_take", lambda: self.generate_preview()) Settings.connect("change_gen_copies", lambda: self.generate_preview()) Settings.connect("change_gen_mix", lambda: self.generate_preview()) self.strings.connect("updated", lambda _: self.generate_preview())