Пожалуйста, у меня есть этот код ниже, и я хочу иметь возможность переключаться между windows с помощью кнопки self.database_btn
... это работает, но мне всегда приходится закрывать первое окно, прежде чем База данных windows появится ... Я хочу иметь возможность вызвать второе окно и закрыть первое окно, как только кнопка будет нажата ... Буду рад любой помощи
class Application:
def __init__(self, master, *args, **kwargs):
#frame
self.left = Frame(master, width=800, height=768, bg='white')
self.left.pack(side=LEFT)
self.right = Frame(master, width=566, height=768, bg='lightblue')
self.right.pack(side=RIGHT)
#components
self.heading = Label(master, text= "Quame Supermarket", font=('arial 40 bold'), bg='white')
self.heading.place(x=0, y=0)
self.date_l = Label(self.right, text="Today's Date: "+str(date), font=('arial 14 bold'), bg='lightblue', fg='white')
self.date_l.place(x=0, y=0)
#table invoice=========================
self.tproduct = Label(self.right, text="Products", font=('arial 18 bold'), bg='lightblue', fg='white')
self.tproduct.place(x=0, y=60)
self.tquantity = Label(self.right, text="quantity", font=('arial 18 bold'), bg='lightblue', fg='white')
self.tquantity.place(x=200, y=60)
self.tamount = Label(self.right, text="amount", font=('arial 18 bold'), bg='lightblue', fg='white')
self.tamount.place(x=400, y=60)
#enter stuff
self.enterid = Label(self.left, text="Enter Product's ID", font=('arial 18 bold'), bg='white')
self.enterid.place(x=0, y=80)
self.enteride = Entry(self.left, width=25, font=('arial 18 bold'), bg='lightblue')
self.enteride.place(x=260, y=80)
self.enteride.focus()
self.entername = Label(self.left, text="Enter Product's Name", font=('arial 18 bold'), bg='white')
self.entername.place(x=0, y=150)
# self.entername_e = Entry(self.left, width=25, font=('arial 18 bold'), bg='lightblue')
# self.entername_e.place(x=260, y=150)
self.entername_e = AutocompleteEntry(autocompleteList, listboxLength=10, width=25, font=('arial 18 bold'), bg='lightblue', matchesFunction=matches)
self.entername_e.place(x=260, y=150)
#button
self.database_btn = Button(self.left, text="Go to Database", width=20, height=2, bg='orange')
self.database_btn.place(x=600, y=300)
self.search_btn = Button(self.left, text="Search by Id(Right)", width=20, height=2, bg='orange', command=self.ajax1)
self.search_btn.place(x=600, y=80)
self.search_btn = Button(self.left, text="Search by Name", width=20, height=2, bg='orange', command=self.ajax2)
self.search_btn.place(x=600, y=150)
self.clear_btn = Button(self.left, text="Clear All", width=20, height=2, bg='green', fg='white', command=self.clear)
self.clear_btn.place(x=600, y=490)
#fill it later by the fucntion ajax
self.productname = Label(self.left, text="", font=('arial 27 bold'), bg='white', fg='green')
self.productname.place(x=0, y=250)
self.pprice = Label(self.left, text="", font=('arial 27 bold'), bg='white', fg='green')
self.pprice.place(x=0, y=290)
#total label
self.total_l = Label(self.right, text="Total", font=('arial 40 bold'), bg='lightblue', fg='green')
self.total_l.place(x=0, y=600)
def clear(self, *args, **kwargs):...
def ajax2(self, *args, **kwargs):...
def add_to_cart(self, *args, **kwargs):...
def generate_bill(self, *args, **kwargs):...
root = Tk()
b = Application(root)
root.geometry("1366x768+0+0")
root.mainloop()
class Database:
def __init__(self, master, *args, **kwargs):
self.master = master
self.heading = Label(master, text= "Update the database", font=('arial 40 bold'), fg='steelblue')
self.heading.place(x=400, y=0)
#labels for entrie
self.id_le = Label(master, text="Enter Id", font=('aarial 18 bold'))
self.id_le.place(x=0, y=80)
self.id_leb = Entry(master, width=15, font=('arial 18 bold'))
self.id_leb.place(x=350, y=80)
self.btn_search = Button(master, text="Search Id", width=15, height=2, bg='orange', fg='white', command=self.search1)
self.btn_search.place(x=565, y=80)
#labels for the windows
self.name_l = Label(master, text = "Enter Product Name", font=('arial 18 bold'))
self.name_l.place(x=0, y=150)
self.stock_l = Label(master, text = "Enter Stock", font=('arial 18 bold'))
self.stock_l.place(x=0, y=220)
self.cp_l = Label(master, text = "Enter Cost Price", font=('arial 18 bold'))
self.cp_l.place(x=0, y=290)
self.sp_l = Label(master, text = "Enter Selling Price", font=('arial 18 bold'))
self.sp_l.place(x=0, y=350)
self.totalcp_l = Label(master, text = "Total Cost Price", font=('arial 18 bold'))
self.totalcp_l.place(x=0, y=410)
self.totalsp_l = Label(master, text = "Total Selling Price", font=('arial 18 bold'))
self.totalsp_l.place(x=0, y=480)
self.vendor_l = Label(master, text = "Enter Vendor Name", font=('arial 18 bold'))
self.vendor_l.place(x=0, y=550)
self.vendor_num_l = Label(master, text = "Enter Vendor Phone Number", font=('arial 18 bold'))
self.vendor_num_l.place(x=0, y=620)
#label Entries
self.name_e = Entry(master, width=15, font=('arial 18 bold'))
self.name_e.place(x=350, y=150)
self.btn_search = Button(master, text="Search Name", width=15, height=2, bg='orange', fg='white', command=self.search2)
self.btn_search.place(x=565, y=150)
self.stock_e = Entry(master, width=25, font=('arial 18 bold'))
self.stock_e.place(x=350, y=220)
self.cp_e = Entry(master, width=25, font=('arial 18 bold'))
self.cp_e.place(x=350, y=290)
self.sp_e = Entry(master, width=25, font=('arial 18 bold'))
self.sp_e.place(x=350, y=350)
self.totalcp_e = Entry(master, width=25, font=('arial 18 bold'))
self.totalcp_e.place(x=350, y=410)
self.totalsp_e = Entry(master, width=25, font=('arial 18 bold'))
self.totalsp_e.place(x=350, y=480)
self.vendor_e = Entry(master, width=25, font=('arial 18 bold'))
self.vendor_e.place(x=350, y=550)
self.vendor_num_e = Entry(master, width=25, font=('arial 18 bold'))
self.vendor_num_e.place(x=350, y=620)
#Button to update the database
self.btn_add = Button(master, text="Update Database", width=20, height=2, bg='green', fg='white', command=self.update)
self.btn_add.place(x=440, y=660)
#Text box for the logs
self.tBox = Text(master, width=60, height=18)
self.tBox.place(x=750, y=74)
def search1(self, *args, **kwargs):...
def update(self, *args, **kwargs):....
root = Tk()
b = Database(root)
root.geometry("1366x768+0+0")
root.mainloop()