def __init__(self, parent, button): change_button_color(button) tk.Frame.__init__(self, parent) self.base_f = tk.Frame(None) place(self.base_f, h=0.93, w=1, x=0, y=0.04) self.target = None self.styles = DelPageStyles(self) self.check_target()
def __init__(self, parent, button): change_button_color(button) tk.Frame.__init__(self, parent) self.base_f = tk.Frame(None) self.max_rows = 0 place(self.base_f, h=0.93, w=1, x=0, y=0.04) self.styles = UpdatePageStyles(self) self.check_target()
def replace(self, cls, button): """Controller for changing self.content frame. Deletes current frame to wipe the non init tk objects from that page. """ self.content.destroy() self.content = tk.Frame(self.frame) tkh.place(self.content, h=0.93, w=1, x=0, y=0.04, a="n") cls(self.content, button)
def selection(self): self.base_f.destroy() self.canvas = tk.Canvas(None) place(self.canvas, h=0.93, w=1, x=0, y=0.04) self.base_f = tk.Frame(self.canvas) self.draw_scrollbar() display_page(self) self.styles.display_page(self) self.buttons()
def __init__(self, parent, button=None): tk.Frame.__init__(self, parent) tkh.clear_colors() self.max_rows = 0 self.canvas = tk.Canvas(None) self.base_f = tk.Frame(self.canvas) self.draw_scrollbar() self.styles = WikiPageStyles(self) tkh.place(self.canvas, h=0.93, w=1, x=0, y=0.04) self.query_entry()
def __init__(self, parent, button): change_button_color(button) tk.Frame.__init__(self, parent) self.base_f = tk.Frame(None) place(self.base_f, h=0.93, w=1, x=0, y=0.04) self.filepath = "" self.layout() self.labels() self.display() self.entries() self.buttons() self.styles = SettingsPageStyles(self)
def entries(self): self.name_e = tk.Entry(self.left_f) place(self.name_e, h="", w=0.3, x=0.25, y=0.01) self.notes_e = tk.Entry(self.left_f) place(self.notes_e, h="", w=0.3, x=0.25, y=0.05) self.swap = ttk.Combobox(self.left_f, value=g.WIKI_LIST) self.swap["state"] = "readonly" self.set_combobox() place(self.swap, h="", w=0.3, x=0.25, y=0.11) self.edit_e = tk.Entry(self.left_f) place(self.edit_e, h="", w=0.3, x=0.25, y=0.165) self.tag_e = tk.Entry(self.left_f) place(self.tag_e, h="", w=0.3, x=0.25, y=0.22)
def __init__(self, parent, button): tk.Frame.__init__(self, parent) change_button_color(button) self.base_f = tk.Frame(None) place(self.base_f, h=0.93, w=1, x=0.5, y=0.04, a="n") self.page_data = deepcopy(g.PAGE_TEMPLATE) self.err_amt = 3 self.errors = {i: tk.Text for i in range(self.err_amt)} self.display_objs = [] self.layout() self.labels() self.entries() self.buttons() self.styles = AddPageStyles(self) self.display()
def fuzzy_searchbar(self, event): self.search_term = self.search_e.get() if self.search_term != "": self.fuzz_list.delete(0, "end") suggestions = g.QUERY.fuzzy_page_match(self.search_term, s.SEARCHBAR_PG_LIMIT) self.fuzz_list.config(height=len(suggestions)) for item in suggestions: self.fuzz_list.insert("end", item.name) self.fuzz_bar_active = True tkh.place(self.fuzz_list, h="", w=0.6, x=0.2, y=0.04) else: self.fuzz_list.place_forget() self.fuzz_list.delete(0, "end") self.search_e.focus()
def __init__(self, parent, button): change_button_color(button) self.content = tk.Frame.__init__(self, parent) welcome = tk.Label(self.content, text=en.WELCOME, font=(s.FONT1, 12, "bold"), bg=s.FG, fg=s.SEARCHFG) welcome.place(relheight=0.93, relwidth=1, relx=0, rely=0.04) show_button = tk.Button(self.content, text=en.HELP_B1, font=(s.FONT1, 9, "bold"), bg=s.SEARCHBG, fg=s.TEXT3, command=lambda: self.show_more()) place(show_button, h="", w=0.3, x=0.35, y=0.55)
def display(self): self.display_f = tk.Frame(self.right) place(self.display_f, h=1, w=1, x=0, y=0) self.display_f.grid_columnconfigure(0, weight=1) self.styles.display(self) for e in range(0, len(self.errors.keys())): self.display_f.grid_rowconfigure(e, weight=0) err = self.errors[e](self.display_f) self.styles.errors(err) err.config(state="disabled") err.grid(row=e, sticky="ewns", rowspan=1) self.errors[e] = err self.display_f.grid_rowconfigure(self.err_amt, weight=0) # page title row self.display_f.grid_rowconfigure(self.err_amt + 1, weight=0) # page notes row
def entries(self): self.name_e = tk.Entry(self.layout_left_f) place(self.name_e, h="", w=0.67, x=0.25, y=0) self.notes_e = tk.Entry(self.layout_left_f) place(self.notes_e, h="", w=0.67, x=0.25, y=0.05) self.title_e = tk.Entry(self.layout_left_f) place(self.title_e, h="", w=0.67, x=0.25, y=0.14) self.content_t = tk.Text(self.layout_left_f) place(self.content_t, h=0.35, w=0.98, x=0, y=0.20)
def display_info(self): self.loaded_l = tk.Label(self.info_l) place(self.loaded_l, h=0.05, w=0.9, x=0.052, y=0) self.loaded_name_l = tk.Label(self.info_l) place(self.loaded_name_l, h=0.08, w=0.9, x=0.052, y=0.04) self.desc_l = tk.Label(self.info_l) place(self.desc_l, h=0.04, w=0.9, x=0.052, y=0.1) page_amt = f"{en.SETT_DIS2} {g.QUERY.page_amt_stats()}" tag_amt = f"{en.SETT_DIS3}" self.loaded_stats_l = tk.Label(self.info_l, text=page_amt) place(self.loaded_stats_l, h=0.04, w=0.4, x=0.052, y=0.17)
def __init__(self): self.root = tk.Tk() g.ROOT = self.root self.root.title(s.TITLE) self.root.geometry(f"{s.W_HEIGHT}x{s.W_WIDTH}") self.root.minsize(s.W_HEIGHT, s.W_WIDTH) self.root.bind("<Button-1>", self.fuzzy_on_off) self.frame = tk.Frame(self.root, bg=s.FG) tkh.place(self.frame, h=1, w=1, x=0, y=0) self.fuzz_bar_active = False self.search_term = "" self.create_menu_buttons() self.create_initial_frame() self.create_searchbar() db.init_database_info() self.styles = AppStyles(self) tkh.change_button_color("help") # Initial page self.root.mainloop() g.DB.close()
def labels(self): self.name_l = tk.Label(self.layout_left_f) place(self.name_l, h="", w=0.2, x=0, y=0.0) self.notes_l = tk.Label(self.layout_left_f) place(self.notes_l, h="", w=0.2, x=0, y=0.05) self.c_title_l = tk.Label(self.layout_left_f) place(self.c_title_l, h="", w=0.2, x=0, y=0.14)
def buttons(self): self.add_b = tk.Button( self.layout_left_f, command=lambda: self.add_content(self.get_inputs())) place(self.add_b, h="", w=0.3, x=0.33, y=0.575) self.undo_b = tk.Button(self.layout_left_f, command=lambda: self.undo_one()) place(self.undo_b, h="", w=0.16, x=0.82, y=0.575) self.create_b = tk.Button(self.layout_left_f, command=lambda: self.create_page()) place(self.create_b, h="", w=0.3, x=0.33, y=0.642) self.clear_b = tk.Button(self.layout_left_f, command=lambda: self.clear_all()) place(self.clear_b, h="", w=0.16, x=0, y=0.575)
def display(self): """Anything related to information displaying.""" self.info_l = tk.Label(self.right_f) place(self.info_l, h=0.92, w=1, x=0, y=0.08) self.errs_l = tk.Label(self.right_f) place(self.errs_l, h=0.08, w=1, x=0, y=0) self.info_imp_l = tk.Label(self.left_f) place(self.info_imp_l, h=0.035, w=0.9, x=0.02, y=0.365) self.display_info()
def create_searchbar(self): """Everything in the top section (search bar and buttons).""" self.search_f = tk.Frame(self.frame) tkh.place(self.search_f, h=0.04, w=2, x=0.1, y=0, a="n") g.DB_STATUS = tk.Label(self.search_f) tkh.place(g.DB_STATUS, h=1, w=0.1, x=0.45, y=0) self.search_e = tk.Entry(self.search_f) self.search_e.bind('<KeyRelease>', self.fuzzy_searchbar) self.search_e.bind("<Return>", (lambda event: [ self.set_query(), self.replace(WikiPage, ""), self.fuzz_list.place_forget(), self.frame.focus() ])) tkh.place(self.search_e, h=1, w=0.3, x=0.55, y=0) self.search_b = tk.Button( self.search_f, command=lambda: [self.set_query(), self.replace(WikiPage, "")]) tkh.place(self.search_b, h=1, w=0.05, x=0.85, y=0) self.search_tag_b = tk.Button(self.search_f, command=lambda: ImageWindow()) tkh.place(self.search_tag_b, h=1, w=0.05, x=0.90, y=0) self.fuzzy_frame() # Autocomplete popup
def selection(self): self.title_l = tk.Label(self.base_f, text=fm.format_title(g.TARGET).rstrip()) self.notes_l = tk.Label(self.base_f, text=g.TARGET_PAGE.notes.rstrip()) place(self.title_l, h=0.2, w=1, x=0, y=0.03) place(self.notes_l, h=0.3, w=1, x=0, y=0.23) message = f"{en.CONFIRM_1} {self.target}?" self.message_l = tk.Label(self.base_f, text=message) place(self.message_l, h=0.1, w=1, x=0, y=0.6) self.styles.selection(self) self.buttons()
def layout(self): """All partitions are relative to self.content""" self.right_f = tk.Frame(self.base_f, bg=s.FG) place(self.right_f, h=1, w=0.5, x=0.5, y=0) self.left_f = tk.Frame(self.base_f, bg=s.FG) place(self.left_f, h=1, w=0.5, x=0, y=0)
def create_initial_frame(self): """Initial screen when starting the app""" self.content = tk.Frame(self.frame) tkh.place(self.content, h=0.93, w=1, x=0, y=0.04, a="n") self.replace(HelpPage, "help")
def buttons(self): self.add_wiki_b = tk.Button(self.left_f, command=lambda: self.add_wiki( self.name_e.get(), self.notes_e.get())) place(self.add_wiki_b, h="", w=0.3, x=0.59, y=0.005) self.load_b = tk.Button(self.left_f, command=lambda: self.load_wiki()) place(self.load_b, h="", w=0.3, x=0.59, y=0.106) self.edit_name_b = tk.Button(self.left_f, command=lambda: self.update_wiki_name()) place(self.edit_name_b, h="", w=0.18, x=0.59, y=0.16) self.edit_notes_b = tk.Button(self.left_f, command=lambda: self.update_wiki_desc()) place(self.edit_notes_b, h="", w=0.18, x=0.79, y=0.16) self.browse_b = tk.Button(self.left_f, command=lambda: self.get_filepath()) place(self.browse_b, h="", w=0.3, x=0.25, y=0.3) self.import_b = tk.Button(self.left_f, command=lambda: self.import_wiki()) place(self.import_b, h="", w=0.3, x=0.59, y=0.3) self.tag_b = tk.Button(self.left_f) place(self.tag_b, h="", w=0.3, x=0.59, y=0.215) self.del_b = tk.Button(self.left_f, command=lambda: self.delete_wiki()) place(self.del_b, h="", w=0.2, x=0.79, y=0.96)
def fuzzy_frame(self): self.fuzz_list = tk.Listbox(self.root) tkh.place(self.fuzz_list, h="", w=0.6, x=0.2, y=0.04) self.fuzz_list.bind("<<ListboxSelect>>", self.fuzzy_query) self.fuzz_list.place_forget()
def labels(self): self.name_l = tk.Label(self.left_f) place(self.name_l, h=0.05, w=0.2, x=0, y=0) self.notes_l = tk.Label(self.left_f) place(self.notes_l, h=0.05, w=0.2, x=0, y=0.04) self.load_l = tk.Label(self.left_f) place(self.load_l, h=0.05, w=0.2, x=0, y=0.103) self.edit_l = tk.Label(self.left_f) place(self.edit_l, h=0.05, w=0.2, x=0, y=0.155) self.tag_l = tk.Label(self.left_f) place(self.tag_l, h=0.05, w=0.2, x=0, y=0.21) self.import_l = tk.Label(self.left_f) place(self.import_l, h=0.05, w=0.2, x=0, y=0.295)
def no_selection(self): self.message_l = tk.Label(self.base_f) place(self.message_l, h=1, w=1, x=0, y=0) self.styles.no_selection(self)
def button_info(self): tri1 = tk.Canvas(self.content, bg=s.FG, highlightthickness=0) tri1.create_polygon((0, 70, 35, 0, 70, 70), fill=s.SEARCHBG) place(tri1, h=0.22, w=0.3, x=0.04, y=0) tri3 = tk.Canvas(self.content, bg=s.FG, highlightthickness=0) tri3.create_polygon((0, 70, 35, 0, 70, 70), fill=s.SEARCHBG) searchbar = tk.Label(self.content, bg=s.FG, fg=s.SEARCHFG, text=en.SEARCH_HELP, font=(s.FONT1, 12, "bold")) place(searchbar, h=0.07, w=0.2, x=0.4, y=0.05) place(tri3, h=0.22, w=0.12, x=0.45, y=0) tri4 = tk.Canvas(self.content, bg=s.FG, highlightthickness=0) tri4.create_polygon((0, 70, 35, 120, 70, 70), fill=s.SEARCHBG) place(tri4, h=0.22, w=0.12, x=0.05, y=0.82) # add page tri5 = tk.Canvas(self.content, bg=s.FG, highlightthickness=0) tri5.create_polygon((0, 70, 35, 120, 70, 70), fill=s.SEARCHBG) place(tri5, h=0.22, w=0.12, x=0.245, y=0.82) # update page tri5 = tk.Canvas(self.content, bg=s.FG, highlightthickness=0) tri5.create_polygon((0, 70, 35, 120, 70, 70), fill=s.SEARCHBG) place(tri5, h=0.22, w=0.12, x=0.45, y=0.82) # delete page triangle2 = tk.Canvas(self.content, bg=s.FG, highlightthickness=0) triangle2.create_polygon((0, 70, 35, 120, 70, 70), fill=s.BUTTON_R) start_here = tk.Label(self.content, bg=s.FG, fg=s.SEARCHFG, text=en.START_HELP, font=(s.FONT1, 12, "bold")) place(triangle2, h=0.22, w=0.12, x=0.66, y=0.82) place(start_here, h=0.08, w=0.30, x=0.562, y=0.89)
def create_menu_buttons(self): """Everything on the bottom section (the row of buttons).""" self.menu_f = tk.Frame(self.frame) tkh.place(self.menu_f, h=0.03, w=1, x=0.5, y=1, a="s") self.menu_add_b = tk.Button( self.menu_f, command=lambda: self.replace(AddPage, "add")) tkh.place(self.menu_add_b, h=1, w=0.2, x=0, y=0) self.menu_update_b = tk.Button( self.menu_f, command=lambda: self.replace(UpdatePage, "update")) tkh.place(self.menu_update_b, h=1, w=0.2, x=0.2, y=0) self.menu_del_b = tk.Button( self.menu_f, command=lambda: self.replace(DelPage, "del")) tkh.place(self.menu_del_b, h=1, w=0.2, x=0.4, y=0) self.menu_sett_b = tk.Button( self.menu_f, command=lambda: [self.replace(SettingsPage, "sett"), tkh.refresh_globals()]) tkh.place(self.menu_sett_b, h=1, w=0.2, x=0.6, y=0) self.menu_help_b = tk.Button( self.menu_f, command=lambda: [self.replace(HelpPage, "help"), tkh.refresh_globals()]) tkh.place(self.menu_help_b, h=1, w=0.2, x=0.8, y=0) # Globals for changing button colors when pressed g.MENU_BUTTONS = { "add": self.menu_add_b, "update": self.menu_update_b, "sett": self.menu_sett_b, "help": self.menu_help_b, "del": self.menu_del_b }
def buttons(self): self.yes_b = tk.Button(self.base_f, command=lambda: self.delete_page()) place(self.yes_b, h="", w=0.15, x=0.3, y=0.7) self.no_b = tk.Button(self.base_f, command=lambda: self.back()) place(self.no_b, h="", w=0.15, x=0.55, y=0.7) self.styles.buttons(self)
def not_found(self): self.err_f = tk.Frame(self.base_f) tkh.place(self.err_f, h=0.93, w=1, x=0.5, y=0.04, a="n") self.message = tk.Label(self.err_f) tkh.place(self.message, h="", w=0.3, x=0.35, y=0.45)