def byrank(): get_rank_entry = rank_entry.get() if get_rank_entry != '': self.n.destroy() self.n = ttk.Notebook(self.view_frame) f1 = ttk.Frame(self.n) # All f2 = ttk.Frame(self.n) # Movies f3 = ttk.Frame(self.n) # Shows self.n.add(f1, text='All') self.n.add(f2, text='Movies') self.n.add(f3, text='Shows') self.n.grid(row=0,column=0) # Create a database or connect to one conn = sqlite3.connect('MovieDesire.db') # Create cursor c = conn.cursor() # Query the db c.execute("SELECT *, oid FROM moviedesireDB WHERE watched_rank =" + str(get_rank_entry)) records = c.fetchall() #print(records) # Loop through results if len(records) == 0: label_frame_A = tk.Frame(f1, width=550) label_frame_A.pack() print_titles_M = "No titles with selected rank" print_titles_M_label = tk.Label(label_frame_A, text=print_titles_M, justify='left') print_titles_M_label.pack() else: # All print_titles_A = '' print_desirerank_A = '' for record in records: #imdb_rate = get_imdb_rating(str(record[0])) print_titles_A += str(record[5]) + " : " + str(record[0]) + "\n" print_desirerank_A += "Desire: " + str(record[2]) + " | Rank: " + str(record[1]) + " | IMDB: " + str(record[3]) + "\n" if print_titles_A == '': print_titles_A = "No titles with selected desire" # frame in f1 label_frame_A = SFrame(f1, width=550) label_frame_A.pack() # info print_titles_A_label = tk.Label(label_frame_A, text=print_titles_A, justify='left') print_titles_A_label.grid(row=1, column=0, padx=30, pady=40) print_desirerank_A_label = tk.Label(label_frame_A, text=print_desirerank_A, justify='left') print_desirerank_A_label.grid(row=1, column=1, padx=50, pady=40) # Movies print_titles_M = '' print_desirerank_M = '' for record in records: if str(record[4]) == 'M': print_titles_M += str(record[5]) + " : " + str(record[0]) + "\n" print_desirerank_M += "Desire: " + str(record[2]) + " | Rank: " + str(record[1]) + " | IMDB: " + str(record[3]) + "\n" if print_titles_M == '': print_titles_M = "No movies with selected desire" # frame in f2 label_frame_M = SFrame(f2, width=550) label_frame_M.pack() # info print_titles_M_label = tk.Label(label_frame_M, text=print_titles_M, justify='left') print_titles_M_label.grid(row=1, column=0, padx=30, pady=40) print_desirerank_M_label = tk.Label(label_frame_M, text=print_desirerank_M, justify='left') print_desirerank_M_label.grid(row=1, column=1, padx=50, pady=40) # Shows print_titles_S = '' print_desirerank_S = '' for record in records: if str(record[4]) == 'S': print_titles_S += str(record[5]) + " : " + str(record[0]) + "\n" print_desirerank_S += "Desire: " + str(record[2]) + " | Rank: " + str(record[1]) + " | IMDB: " + str(record[3]) + "\n" if print_titles_S == '': print_titles_S = "No shows with selected desire" # frame in f3 label_frame_M = SFrame(f3, width=550) label_frame_M.pack() # info print_titles_M_label = tk.Label(label_frame_M, text=print_titles_S, justify='left') print_titles_M_label.grid(row=1, column=0, padx=30, pady=40) print_desirerank_M_label = tk.Label(label_frame_M, text=print_desirerank_S, justify='left') print_desirerank_M_label.grid(row=1, column=1, padx=50, pady=40) # Commit changes conn.commit() #Close connection conn.close() rank_entry.delete(0, 'end') # Clear entry box
def show_lists(): # Create a database or connect to one conn = sqlite3.connect('MovieDesire.db') # Create cursor c = conn.cursor() # Query the db c.execute("SELECT *, oid FROM moviedesireDB") records = c.fetchall() #print(records) # Loop through results # All print_titles_A = '' print_desirerank_A = '' for record in records: #imdb_rate = get_imdb_rating(str(record[0])) print_titles_A += str(record[5]) + " : " + str(record[0]) + "\n" print_desirerank_A += str(record[1]) + "\t" + str(record[2]) + "\t" + str(record[3]) + "\n" # frame in f1 label_frame_A = SFrame(f1, width=550) label_frame_A.pack() # header print_titleheader_A_label = tk.Label(label_frame_A, text="ID: " + "Title: ", justify='left', font="none 15 underline") print_titleheader_A_label.grid(row=1, column=0, ipadx=15, sticky='w') print_desirerank_A_header_label = tk.Label(label_frame_A, text=" Desire: " + "\t" + " Rank: " + "\t" + " IMDB Rating:", justify='left', font="none 15 underline") print_desirerank_A_header_label.grid(row=1, column=1, padx=15, sticky='w') # info print_titles_A_label = tk.Label(label_frame_A, text=print_titles_A, justify='left') print_titles_A_label.grid(row=2, column=0, ipadx=15) print_desirerank_A_label = tk.Label(label_frame_A, text=print_desirerank_A, justify='left') print_desirerank_A_label.grid(row=2, column=1, padx=15, ipadx=30, sticky='w') # Movies print_titles_M = '' print_desirerank_M = '' for record in records: if str(record[4]) == 'M': print_titles_M += str(record[5]) + " : " + str(record[0]) + "\n" print_desirerank_M += str(record[1]) + "\t" + str(record[2]) + "\t" + str(record[3]) + "\n" # frame in f2 label_frame_M = SFrame(f2, width=550) label_frame_M.pack() # header print_titleheader_M_label = tk.Label(label_frame_M, text="ID: " + "Title: ", justify='left', font="none 15 underline") print_titleheader_M_label.grid(row=1, column=0, ipadx=15, sticky='w') print_desirerank_M_header_label = tk.Label(label_frame_M, text=" Desire: " + "\t" + " Rank: " + "\t" + " IMDB Rating:", justify='left', font="none 15 underline") print_desirerank_M_header_label.grid(row=1, column=1, padx=15, sticky='w') # info print_titles_M_label = tk.Label(label_frame_M, text=print_titles_M, justify='left') print_titles_M_label.grid(row=2, column=0, ipadx=15) print_desirerank_M_label = tk.Label(label_frame_M, text=print_desirerank_M, justify='left') print_desirerank_M_label.grid(row=2, column=1, padx=15, ipadx=30, sticky='w') # Shows print_titles_S = '' print_desirerank_S = '' for record in records: if str(record[4]) == 'S': print_titles_S += str(record[5]) + " : " + str(record[0]) + "\n" print_desirerank_S += str(record[1]) + "\t" + str(record[2]) + "\t" + str(record[3]) + "\n" # frame in f3 label_frame_S = SFrame(f3, width=550) label_frame_S.pack() # header print_titleheader_label = tk.Label(label_frame_S, text="ID: " + "Title: ", justify='left', font="none 15 underline") print_titleheader_label.grid(row=1, column=0, ipadx=15, sticky='w') print_desirerank_S_header_label = tk.Label(label_frame_S, text=" Desire: " + "\t" + " Rank: " + "\t" + " IMDB Rating:", justify='left', font="none 15 underline") print_desirerank_S_header_label.grid(row=1, column=1, padx=15, sticky='w') # info print_titles_S_label = tk.Label(label_frame_S, text=print_titles_S, justify='left') print_titles_S_label.grid(row=2, column=0, ipadx=15) print_desirerank_S_label = tk.Label(label_frame_S, text=print_desirerank_S, justify='left') print_desirerank_S_label.grid(row=2, column=1, padx=15, ipadx=30, sticky='w') # Commit changes conn.commit() #Close connection conn.close()
def rank_highlow(): self.n.destroy() self.n = ttk.Notebook(self.view_frame) f1 = ttk.Frame(self.n) # All f2 = ttk.Frame(self.n) # Movies f3 = ttk.Frame(self.n) # Shows self.n.add(f1, text='All') self.n.add(f2, text='Movies') self.n.add(f3, text='Shows') self.n.grid(row=0,column=0) # Create a database or connect to one conn = sqlite3.connect('MovieDesire.db') # Create cursor c = conn.cursor() # Query the db c.execute("SELECT *, oid FROM moviedesireDB ORDER BY watched_rank DESC") records = c.fetchall() #print(records) # Loop through results # All print_titles_A = '' print_desirerank_A = '' print_titles_A_no_rank = '' print_desirerank_A_no_rank = '' for record in records: if record[2] != '': #imdb_rate = get_imdb_rating(str(record[0])) print_titles_A += str(record[5]) + " : " + str(record[0]) + "\n" print_desirerank_A += str(record[2]) + "\t" + str(record[1]) + "\t" + str(record[3]) + "\n" else: print_titles_A_no_rank += str(record[5]) + " : " + str(record[0]) + "\n" print_desirerank_A_no_rank += str(record[2]) + "\t" + str(record[1]) + "\t" + str(record[3]) + "\n" # frame in f1 label_frame_A = SFrame(f1, width=550) label_frame_A.pack() # header print_titleheader_A_label = tk.Label(label_frame_A, text="ID: " + "Title: ", justify='left', font="none 15 underline") print_titleheader_A_label.grid(row=1, column=0, ipadx=15, sticky='w') print_desirerank_A_header_label = tk.Label(label_frame_A, text="My Rank: " + " \t " + " Desire: " + "\t" + " IMDB Rating: ", justify='left', font="none 15 underline") print_desirerank_A_header_label.grid(row=1, column=1, padx=15, sticky='w') # info print_titles_A_label = tk.Label(label_frame_A, text=print_titles_A, justify='left') print_titles_A_label.grid(row=2, column=0, ipadx=15) print_desirerank_A_label = tk.Label(label_frame_A, text=print_desirerank_A, justify='left') print_desirerank_A_label.grid(row=2, column=1, padx=15, ipadx=30, sticky='w') print_titles_A_no_rank_label = tk.Label(label_frame_A, text=print_titles_A_no_rank, justify='left') print_titles_A_no_rank_label.grid(row=3, column=0, ipadx=15, sticky='w') print_desirerank_A_no_rank_label = tk.Label(label_frame_A, text=print_desirerank_A_no_rank, justify='left') print_desirerank_A_no_rank_label.grid(row=3, column=1, padx=15, ipadx=30, sticky='w') # Movies print_titles_M = '' print_desirerank_M = '' for record in records: if str(record[4]) == 'M' and str(record[2]) != '': print_titles_M += str(record[5]) + " : " + str(record[0]) + "\n" print_desirerank_M += str(record[2]) + "\t" + str(record[1]) + "\t" + str(record[3]) + "\n" # frame in f2 label_frame_M = SFrame(f2, width=550) label_frame_M.pack() # header print_titleheader_M_label = tk.Label(label_frame_M, text="ID: " + "Title: ", justify='left', font="none 15 underline") print_titleheader_M_label.grid(row=1, column=0, ipadx=15, sticky='w') print_desirerank_M_header_label = tk.Label(label_frame_M, text="My Rank: " + " \t " + " Desire: " + "\t" + " IMDB Rating: ", justify='left', font="none 15 underline") print_desirerank_M_header_label.grid(row=1, column=1, padx=15, sticky='w') # info print_titles_M_label = tk.Label(label_frame_M, text=print_titles_M, justify='left') print_titles_M_label.grid(row=2, column=0, ipadx=15) print_desirerank_M_label = tk.Label(label_frame_M, text=print_desirerank_M, justify='left') print_desirerank_M_label.grid(row=2, column=1, padx=15, ipadx=30, sticky='w') # Shows print_titles_S = '' print_desirerank_S = '' for record in records: if str(record[4]) == 'S' and str(record[2]) != '': print_titles_S += str(record[5]) + " : " + str(record[0]) + "\n" print_desirerank_S += str(record[2]) + "\t" + str(record[1]) + "\t" + str(record[3]) + "\n" # frame in f3 label_frame_S = SFrame(f3, width=550) label_frame_S.pack() # header print_titleheader_label = tk.Label(label_frame_S, text="ID: " + "Title: ", justify='left', font="none 15 underline") print_titleheader_label.grid(row=1, column=0, ipadx=15, sticky='w') print_desirerank_S_header_label = tk.Label(label_frame_S, text="My Rank: " + " \t " + " Desire: " + "\t" + " IMDB Rating: ", justify='left', font="none 15 underline") print_desirerank_S_header_label.grid(row=1, column=1, padx=15, sticky='w') # info print_titles_S_label = tk.Label(label_frame_S, text=print_titles_S, justify='left') print_titles_S_label.grid(row=2, column=0, ipadx=15) print_desirerank_S_label = tk.Label(label_frame_S, text=print_desirerank_S, justify='left') print_desirerank_S_label.grid(row=2, column=1, padx=15, ipadx=30, sticky='w') # Commit changes conn.commit() #Close connection conn.close()
def __init__(self): tk.Tk.__init__(self) self.resizable(0, 0) self.geometry('420x700+300+100') self.title('Mac OSX Button Testing') self.wm_attributes('-modified', 1) self.main_color = ColorVar(value='#ffe6f4') self['bg'] = self.main_color grid(self, 25, 5) self.L1 = tk.Label(self, text='Comparison', bg=self.main_color, font=('', 18, 'bold')) self.L1.grid(row=0, column=0, columnspan=5, sticky='nsew') Button(self, text='Hello').grid(row=1, column=1, sticky='s') ttk.Button(self, text='Hello').grid(row=1, column=3, sticky='s') tk.Button(self, text='Hello').grid(row=1, column=2, sticky='s') tk.Label(self, bg=self.main_color, font=('', 10), text='(Mac OSX)').grid(row=2, column=1, sticky='n',) tk.Label(self, bg=self.main_color, font=('', 10), text='(ttk themed)').grid(row=2, column=3, sticky='n') tk.Label(self, bg=self.main_color, font=('', 10), text='(Default)').grid(row=2, column=2, sticky='n') ttk.Separator(self, orient='vertical').grid( row=3, column=0, columnspan=5, sticky='ew') # ------------ Seperator ------------- # ------------ Demonstration ------------ self.sfr = SFrame(self, bg=self.main_color) self.sfr.grid(rowspan=27, columnspan=5, sticky='nsew') for i in range(5): self.sfr.grid_columnconfigure(i, weight=1) self.L2 = tk.Label(self.sfr, text='Demonstration', bg=self.main_color, font=('', 20, 'bold')) self.L2.grid(row=1, column=0, columnspan=5, sticky='new', pady=(20, 10)) # ------------ Active Color ------------ self.L3 = tk.Label(self.sfr, text='1. Change Active color', bg=self.main_color, font=('', 15, 'bold')) self.L3.grid(row=2, column=0, columnspan=5, sticky='nsew', pady=10) self.L4 = tk.Label(self.sfr, text='The active color can be changed to any gradient color.', bg=self.main_color, font=('', 10)) self.L4.grid(row=3, column=0, columnspan=5, sticky='new') self.B1 = Button(self.sfr, text='Press Me', pady=20) self.B1.grid(row=4, column=0, columnspan=5, pady=20) self.C1 = tk.StringVar(value='Select') self.L5 = tk.Label(self.sfr, text='From', bg=self.main_color, font=('', 12)) self.L5.grid(row=5, column=1, sticky='ew') self.L6 = tk.Label(self.sfr, text='To', bg=self.main_color, font=('', 12)) self.L6.grid(row=5, column=3, sticky='ew') button_container1 = tk.Frame(self.sfr, bg=self.main_color) button_container1.grid(row=6, column=0, columnspan=5, sticky='ew', pady=10, padx=10) button_container1.columnconfigure(0, weight=1) button_container1.columnconfigure(1, weight=1) self.Om1_b = Button(button_container1, text='Change Color', bg='#d0c0ea', borderless=1) self.Om1_b.grid(row=0, column=0, padx=(0, 2), sticky='ew') self.Om2_b = Button(button_container1, text='Change Color', bg="#d0c0ea", borderless=1) self.Om2_b.grid(row=0, column=1, sticky='ew') self.Om1_b['command'] = lambda: self.change_active_color(1) self.Om2_b['command'] = lambda: self.change_active_color(2) # ------------ Background Color ------------ self.L7 = tk.Label(self.sfr, text='2. Change Background color', bg=self.main_color, font=('', 15, 'bold')) self.L7.grid(row=7, column=0, columnspan=5, sticky='nsew', pady=(50, 0)) self.L8 = tk.Label(self.sfr, text='Click on the button to choose the color.', bg=self.main_color, font=('', 10)) self.L8.grid(row=8, column=0, columnspan=5, sticky='new', pady=10) self.B2 = Button(self.sfr, text='Color me', font=('', 30,), pady=10) self.B2.grid(row=9, column=0, columnspan=5, sticky='', pady=20) button_container2 = tk.Frame(self.sfr, bg=self.main_color) button_container2.grid(row=10, column=0, columnspan=5, sticky='ew', pady=10, padx=10) button_container2.columnconfigure(0, weight=1) button_container2.columnconfigure(1, weight=1) self.B3 = Button(button_container2, text='Change Background Color', bg='#d0c0ea', borderless=1) self.B3['command'] = lambda: self.B2.config(bg=askcolor()[1]) self.B3.grid(row=0, column=0, padx=(0, 2)) self.B4 = Button(button_container2, text='Change Foreground Color', bg="#d0c0ea", borderless=1) self.B4['command'] = lambda: self.B2.config(fg=askcolor()[1]) self.B4.grid(row=0, column=1) # ------------ Borderless ------------ self.L9 = tk.Label(self.sfr, text='3. Switch Between Borderless', bg=self.main_color, font=('', 15, 'bold')) self.L9.grid(row=11, column=0, columnspan=5, sticky='sew', pady=(50, 0)) self.L10 = tk.Label(self.sfr, text=""" In borderless it will blend with its parent widget background color. Give parameter `borderless = True / False` to use it.""", bg=self.main_color, font=('', 10)) self.L10.grid(row=12, column=0, columnspan=5, sticky='new') self.B5 = Button(self.sfr, text='No Borders', borderless=1, height=40, bg='#212F3D', fg='white', activebackground=("#EAECEE", "#212F3D")) self.B5.grid(row=13, columnspan=5, pady=(20, 5)) self.B6 = Button(self.sfr, text='No Borders', borderless=1, height=40, bg='#F7DC6F', fg='#21618C', activebackground=('#B3B6B7', '#58D68D')) self.B6.grid(row=14, columnspan=5, pady=(0, 20)) self.var1 = tk.BooleanVar(value=True) self.CB1 = tk.Checkbutton(self.sfr, text='Toggle Borderless', variable=self.var1, bg=self.main_color, command=self.change_borderless_state) self.CB1.grid(row=15, columnspan=5, pady=(0, 10)) # ------------ Bordercolor ------------ self.L11 = tk.Label(self.sfr, text='4. Change Bordercolor', bg=self.main_color, font=('', 15, 'bold')) self.L11.grid(row=16, column=0, columnspan=5, sticky='sew', pady=(50, 0)) self.L12 = tk.Label(self.sfr, text="Change Bordercolor of the button\nNote: if borderless=True, then the bordercolor won't work.", bg=self.main_color, font=('', 10)) self.L12.grid(row=17, column=0, columnspan=5, sticky='new') self.B7 = Button(self.sfr, text='Button', pady=10, padx=5, font=('Zapfino', 12, 'bold')) self.B7.grid(row=18, columnspan=5, pady=30) self.CS1 = Colorscale(self.sfr, value='hex', mousewheel=1, command=lambda e: self.B7.config(bordercolor=e)) self.CS1.grid(row=19, columnspan=5, sticky='ew', padx=10) self.CS2 = Colorscale(self.sfr, value='hex', mousewheel=1, gradient=('#FCF6F5', '#990011'), command=lambda e: self.B7.config(bg=e)) self.CS2.grid(row=20, columnspan=5, sticky='ew', padx=10, pady=5) self.CS3 = Colorscale(self.sfr, value='hex', mousewheel=1, gradient=('green', 'yellow'), command=lambda e: self.B7.config(fg=e)) self.CS3.grid(row=21, columnspan=5, sticky='ew', padx=10) self.CS4 = Colorscale(self.sfr, value='hex', mousewheel=1, gradient=('pink', 'purple'), command=lambda e: self.B7.config(overforeground=e)) self.CS4.grid(row=22, columnspan=5, sticky='ew', padx=10, pady=5) # ------------ Random button styling ------------ self.L11 = tk.Label(self.sfr, text='5. Button Styling', bg=self.main_color, font=('', 15, 'bold')) self.L11.grid(row=23, column=0, columnspan=5, sticky='sew', pady=(50, 0)) self.L12 = tk.Label(self.sfr, text="Press the button to ramdomise the style of the button.", bg=self.main_color, font=('', 10)) self.L12.grid(row=24, column=0, columnspan=5, sticky='new') self.B10 = Button(self.sfr, text='Button', borderless=1) self.B10.grid(row=25, columnspan=5, pady=20) self.B11 = Button(self.sfr, text='Change Style', borderless=1, fg='#21618C', activebackground=('#B3B6B7', '#58D68D'), command=self.change_button_style) self.B11.grid(row=26, columnspan=5, ipady=5) self.button_clicks = 1 self.Text1 = tk.Text(self.sfr, background=self.main_color, highlightthickness=0, relief='sunken', height=20, bd=2, padx=10) self.Text1.grid(row=27, columnspan=5, pady=20, padx=20) self.sfr._avoid_mousewheel( (self.Text1, self.CS1, self.CS2, self.CS3, self.CS4)) self.change_button_style() self.update_idletasks()