scientific-programming-exer.../exam/ex3/callbacks.py

28 lines
929 B
Python

from settings import load_words_from_file, manually_add_question, save_questions_to_file
class CallbackHandler(object):
def __init__(self, gtk_builder):
self.builder = gtk_builder
def on_manually_add_submit_button_clicked(self, widget):
question_view = self.builder.get_object("add_question_question_view")
answer_view = self.builder.get_object("add_question_answer_view")
question = question_view.get_text()
answer = answer_view.get_text()
manually_add_question(question, answer)
def on_load_from_file_submit_button_clicked(self, widget):
file_chooser = self.builder.get_object("load_from_file_chooser")
file_name = file_chooser.get_filename()
load_words_from_file(file_name)
def on_save_question_to_file_submit_button_clicked(self, widget):
file_chooser = self.builder.get_object("save_questions_to_file_chooser")
file_name = file_chooser.get_filename()
save_questions_to_file(file_name)