def __init__(self, *args): super(TyperWindow, self).__init__(*args) self.setWindowTitle("Amphetype") tabs = QTabWidget() quiz = Quizzer() tabs.addTab(quiz, "Typer") tm = TextManager() self.connect(quiz, SIGNAL("wantText"), tm.nextText) self.connect(tm, SIGNAL("setText"), quiz.setText) self.connect(tm, SIGNAL("gotoText"), lambda: tabs.setCurrentIndex(0)) self.connect(quiz, SIGNAL("newReview"), tm.newReview) self.connect(quiz, SIGNAL("lastText"), tm.lastText) tabs.addTab(tm, "Sources") ph = PerformanceHistory() self.connect(tm, SIGNAL("refreshSources"), ph.refreshSources) self.connect(quiz, SIGNAL("statsChanged"), ph.updateData) self.connect(ph, SIGNAL("setText"), quiz.setText) self.connect(ph, SIGNAL("gotoText"), lambda: tabs.setCurrentIndex(0)) tabs.addTab(ph, "Performance") st = StringStats() self.connect(st, SIGNAL("lessonStrings"), lambda x: tabs.setCurrentIndex(4)) tabs.addTab(st, "Analysis") lg = LessonGenerator() self.connect(st, SIGNAL("lessonStrings"), lg.addStrings) self.connect(lg, SIGNAL("newLessons"), lambda: tabs.setCurrentIndex(1)) self.connect(lg, SIGNAL("newLessons"), tm.addTexts) self.connect(quiz, SIGNAL("wantReview"), lg.wantReview) self.connect(lg, SIGNAL("newReview"), tm.newReview) tabs.addTab(lg, "Lesson Generator") dw = DatabaseWidget() tabs.addTab(dw, "Database") pw = PreferenceWidget() tabs.addTab(pw, "Preferences") ab = AboutWidget() tabs.addTab(ab, "About/Help") self.setCentralWidget(tabs) tm.nextText()
def __init__(self): Gtk.Window.__init__(self) self.set_title("Amphetype") notebook = Gtk.Notebook() self.add(notebook) quiz = Quizzer() notebook.append_page(quiz, Gtk.Label.new("Typer")) textm = TextManager() notebook.append_page(textm, Gtk.Label.new("Sources")) quiz.connect("want-text", lambda _: textm.next_text()) textm.connect("set-text", lambda _, *text: quiz.set_target(text)) textm.connect("go-to-text", lambda _: notebook.set_current_page(0)) perf = PerformanceHistory() notebook.append_page(perf, Gtk.Label.new("Performance")) textm.connect("refresh-sources", lambda _: perf.refresh_sources()) quiz.connect("stats-changed", lambda _: perf.update_data()) perf.connect("set-text", lambda *text: quiz.set_target(text)) perf.connect("go-to-text", lambda _: notebook.set_current_page(0)) stats = StringStats() notebook.append_page(stats, Gtk.Label.new("Analysis")) # stats.connect("lesson-strings", lambda _: notebook.set_current_page(4)) lgen = LessonGenerator() notebook.append_page(lgen, Gtk.Label.new("Lesson Generator")) # stats.connect("lesson-strings", lgen.add_strings) lgen.connect("new-lessons", lambda _, _2: notebook.set_current_page(1)) lgen.connect("new-lessons", textm.add_texts) # quiz.connect("want-review", ...) lgen.connect("new-review", textm.new_review) dbase = DatabaseWidget() notebook.append_page(dbase, Gtk.Label.new("Database")) pref = PreferenceWidget() notebook.append_page(pref, Gtk.Label.new("Preferences")) textm.next_text()
def __init__(self, *args): super(TyperWindow, self).__init__(*args) self.setWindowTitle("Amphetype") self.updatePalette() update_palette_change_signals = [ "main_text_color", "widgets_background_color", "widgets_text_color", "main_background_color", 'main_text_area_color', "main_borders_color" ] for change_signal in update_palette_change_signals: self.connect(Settings, SIGNAL("change_{0}".format(change_signal)), self.updatePalette) tabs = QTabWidget() quiz = Quizzer() tabs.addTab(quiz, "Typer") tm = TextManager() self.connect(quiz, SIGNAL("wantText"), tm.nextText) self.connect(tm, SIGNAL("setText"), quiz.setText) self.connect(tm, SIGNAL("gotoText"), lambda: tabs.setCurrentIndex(0)) tabs.addTab(tm, "Sources") ph = PerformanceHistory() self.connect(tm, SIGNAL("refreshSources"), ph.refreshSources) self.connect(quiz, SIGNAL("statsChanged"), ph.updateData) self.connect(ph, SIGNAL("setText"), quiz.setText) self.connect(ph, SIGNAL("gotoText"), lambda: tabs.setCurrentIndex(0)) tabs.addTab(ph, "Performance") st = StringStats() self.connect(st, SIGNAL("lessonStrings"), lambda x: tabs.setCurrentIndex(4)) tabs.addTab(st, "Analysis") lg = LessonGenerator() self.connect(st, SIGNAL("lessonStrings"), lg.addStrings) self.connect(lg, SIGNAL("newLessons"), lambda: tabs.setCurrentIndex(1)) self.connect(lg, SIGNAL("newLessons"), tm.addTexts) self.connect(quiz, SIGNAL("wantReview"), lg.wantReview) self.connect(lg, SIGNAL("newReview"), tm.newReview) tabs.addTab(lg, "Lesson Generator") pw = PreferenceWidget() pw_scroll = QScrollArea() pw_scroll.setWidget(pw) tabs.addTab(pw_scroll, "Preferences") dw = DatabaseWidget() tabs.addTab(dw, "Database") ab = AboutWidget() tabs.addTab(ab, "About/Help") self.setCentralWidget(tabs) tm.nextText()