Apr-04-2019, 11:56 PM
Here is the window_2 portion of the code. I have removed a few lines regarding the image used for the background and the binding for clicking the items from the query to load the actual recipe (line 94). I have also changed the code to remove the pack() and I have only used place() as you have pointed out.
import os import tkinter import sqlite3 import win32print from tkinter import * from tkinter import ttk from tkinter import messagebox #===================================== MAIN ==================================== def main(): #============================= CONNECT TO DATABASE ============================= conn = sqlite3.connect('Recipe.db') c = conn.cursor() #========================= CREATE DATABASE WITH TABLES ========================= c.execute('''CREATE TABLE IF NOT EXISTS Recipes( Dish_Type CHAR(50), Recipe CHAR(50), Cook_Time CHAR(15), Serves CHAR(8), Ingredients CHAR(10000) , Instructions CHAR(10000));''') conn.commit() c.execute('''CREATE TABLE IF NOT EXISTS Version( Welcome Decimal(10));''') conn.commit() c.execute('''CREATE TABLE IF NOT EXISTS Welcome( Welcome TEXT(2500));''') conn.commit() #================================== WINDOW 2 =================================== window_2 = tkinter.Tk() window_2.title('Recipes') w = 1024 h = 612 ws = window_2.winfo_screenwidth() hs = window_2.winfo_screenheight() x = (ws/2) - (w/2) y = (hs/2) - (h/2) window_2.geometry('%dx%d+%d+%d' % (w, h, x, y)) #================================ SELECT QUERY ================================= def select(): try: output.delete(0, END) selection = var.get() c.execute('SELECT Recipe FROM Recipes WHERE Dish_Type = :selection ORDER BY Recipe DESC', {'selection': selection}) results = c.fetchall() for recipe, in results: output.insert(0,recipe) except: messagebox.showerror('Recipes', 'Failed to load category') #================================ OPTION MENU ================================== var = tkinter.StringVar(window_2) var.set('Category') choices = [ 'Appetizers', 'Beef', 'Beverages', 'Bakery', 'Desserts', 'Eggs', 'Lamb', 'Pasta', 'Pork', 'Potato', 'Poultry', 'Rice', 'Salads', 'Sandwiches', 'Sauces/Dips', 'Sea Food', 'Slow Cooker', 'Soups/Chili', 'Stews', 'Sushi', 'Vegetables', 'Vegetarian', 'Wild Game'] option = tkinter.OptionMenu(window_2, var, *choices) option.config(font=('Times 9 bold'), bg = '#F9F8D6', fg = '#9A0615') option.place(x=210, y=136) option['menu'].config(bg = '#F9F8D6', fg = '#9A0615') button = tkinter.Button(window_2, text='Load Category', font=('Times 9 bold'), bg = '#F9F8D6', fg = '#9A0615', command=select) button.place(x=362, y=139) #=================================== WINDGETS ================================== output = tkinter.Listbox(window_2, font=('Times 10'), height = 20, width=42, bd=0, bg = '#FFD599', fg = '#9A0615', selectmode=SINGLE) output.place(x=210, y=195) yscroll1 = tkinter.Scrollbar(command=output.yview, orient=tkinter.VERTICAL) yscroll1.place(x=463, y=196) output.configure(yscrollcommand=yscroll1.set) ## output.bind('<ButtonRelease-1>', getRecipe) window_2.mainloop() if __name__ == '__main__': main()
"Often stumped... But never defeated."