def __init__(self, master): self.master = master tk.Frame.__init__( self, master=master, bg='#EEEEEE' #Background color ) self.db = config.active_objects['db'] self.key_label = self.create_key_label() self.key = Key(self) self.phrase_label = self.create_phrase_label() self.phrase = Phrase(self) self.widget1 = self.key #To allow same call as TranslationMainFrame self.widget2 = self.phrase #To allow same call as TranslationMainFrame if config.get_show_buttons(): print('creating buttons') self.left_button = self.create_left_button() self.right_button = self.create_right_button() self.up_button = self.create_up_button() self.down_button = self.create_down_button() self.activate_get_mode() self.configure_gui() self.bind_event_handlers() if config.get_show_tutorial(): self.load_tutorial()
def __init__(self, master): self.master = master tk.Frame.__init__( self, master=master, bg='#EEEEEE' #Background color ) self.db = config.active_objects['db'] self.db_type = config.get_db_type() self.label_1 = self.create_label_1() self.label_2 = self.create_label_2() if self.db_type == 'standard': self.box_1 = Key(self) self.box_2 = Phrase(self) else: self.box_1 = Language1(self) self.box_2 = Language2(self) if config.get_show_buttons(): print('creating buttons') self.save_button = self.create_save_button() self.copy_button = self.create_copy_button() self.up_button = self.create_up_button() self.down_button = self.create_down_button() self.configure_gui() self.bind_event_handlers()
def configure_gui(self): """ Configures tkinter GUI | None -> None """ #Define rows and columns self.columnconfigure(0, weight=1, pad=10) self.columnconfigure(1, weight=100, pad=10) self.rowconfigure(0, weight=0, pad=10) self.rowconfigure(1, weight=100, pad=10) self.master.rowconfigure(0, weight=1) self.master.columnconfigure(0, weight=1) #Place widgets self.label_1.grid(row=0, column=0, pady=(10, 0)) self.box_1.grid( row=0, column=1, sticky='ew', #Stretches horizontally with window padx=(0, 20), pady=(10, 0)) self.label_2.grid(row=1, column=0, sticky='n', pady=(10, 0)) self.box_2.grid( row=1, column=1, sticky='new', #Stretches horizontally with window padx=(0, 20), pady=(5, 10)) if config.get_show_buttons(): self.save_button.grid(row=2, column=1, sticky='w', padx=(20, 0), pady=(0, 15)) self.copy_button.grid(row=2, column=1, sticky='e', padx=(0, 40), pady=(0, 15)) self.up_button.grid(row=0, column=2, sticky='s', padx=(0, 15), pady=(30, 0)) self.down_button.grid(row=1, column=2, sticky='n', padx=(0, 15), pady=(30, 0)) #Place self in Root object self.grid( row=0, column=0, sticky='nsew' #Stretches with window ) self.box_1.focus() #Focus on key widget
def __init__(self, master): self.master = master tk.Frame.__init__( self, master=master, bg='#EEEEEE' #Background color ) self.db = config.active_objects['db'] self.lang1_label = self.create_lang1_label() self.lang1 = Language1(self) self.lang2_label = self.create_lang2_label() self.lang2 = Language2(self) self.widget1 = self.lang1 #To allow same call as MainFrame self.widget2 = self.lang2 #To allow same call as MainFrame if config.get_show_buttons(): print('creating buttons') self.left_button = self.create_left_button() self.right_button = self.create_right_button() self.up_button = self.create_up_button() self.down_button = self.create_down_button() self.configure_gui() self.bind_event_handlers()
def activate_put_mode(self): """ Sets app to save entry to database | None -> None """ if config.get_mode() == 'put': return language_dict = config.get_language_dict() for item in [self, self.key_label, self.phrase_label]: item.config(bg='#F5FCFF') self.phrase.config( bg='#FFFFFF', borderwidth=2 ) if config.get_show_buttons(): self.left_button.config( text=language_dict['cancel'], ) self.right_button.config( text=language_dict['save'], command=self.save_entry ) self.phrase.focus() self.key.ignore_suggestion() self.phrase.full_clear() config.set_mode('put')
def activate_get_mode(self): """ Sets app to get entry from database | None -> None """ if config.get_mode() == 'get': return language_dict = config.get_language_dict() for item in [self, self.key_label, self.phrase_label]: item.config(bg='#EEEEEE') self.phrase.config( bg='#F5F5F5', borderwidth=3 ) if config.get_show_buttons(): self.left_button.config( text=language_dict['new'], ) self.right_button.config( text=language_dict['copy'], command=self.copy_phrase ) self.key.focus() self.key.full_clear() self.phrase.full_clear() config.set_mode('get')