I'm trying to make a GUI in python using tkinter
for a messaging. When I want to delete a specific person from the friend list, a new window will show up to ask me to confirm my decision. the problem is, after I select an answer, it's supposed to close that window, but it closes everything else too.
from tkinter import *
from tkinter import ttk
def open_win():
new= Tk()
new.geometry("750x250")
new.title("New Window")
#Create a Label in New window
Label(new, text="No friends to be seen, moving on", font=('Helvetica 17 bold')).pack(pady=30)
def close_window():
window.quit()
# exit()
def open_win_delete():
new= Tk()
new.geometry("750x250")
new.title("New Window")
#Create a Label in New window
Label(new, text="Are you sure you want to delete this friend?", font=('Helvetica 17 bold')).grid(row=0,column=2,sticky=NE)
Button(new, text="Yes",width=6, font="none 12 bold", command=close_window) .grid(row=1,column=2,sticky=NE)
Button(new, text="No",width=6, font="none 12 bold", command=close_window) .grid(row=1,column=3,sticky=NE)
def open_win_block():
new= Tk()
new.geometry("750x250")
new.title("New Window")
#Create a Label in New window
Label(new, text="Are you sure you want to block this friend?", font=('Helvetica 17 bold')).grid(row=0,column=2,sticky=NE)
Button(new, text="Yes",width=6, font="none 12 bold", command=close_window) .grid(row=1,column=2,sticky=NE)
Button(new, text="No",width=6, font="none 12 bold", command=close_window) .grid(row=1,column=3,sticky=NE)
def boxchat():
window = Tk()
window.title("Messenger")
window.configure(background="RoyalBlue4")
window.geometry("410x500")
Label(window,text="User:",bg="RoyalBlue4",fg="white",font="none 12 bold") .grid(row=0, column=0,sticky=SW)
output= Text(window, width=50, height=20,wrap=WORD,background="white")
output.grid(row=1,column=0,columnspan=3, sticky=N)
#photo = PhotoImage(file = "D:/SS/Screenshot_1999.png")
#photoimage = photo.subsample(6, 6)
Button(window, text="Send",width=4, font="none 12 bold") .grid(row=6,column=1,sticky=E)
Label(window, text="Input text: ", bg="RoyalBlue4", fg="white",font="none 12 bold") .grid(row=4,column=0,sticky=W)
Button(window, text="Friends",width=7, font="none 12 bold", command=open_win) .grid(row=0,column=1,sticky=NE)
t = Text(window, height=4, width=39)
t.grid(row=5,column=1,sticky=SW)
window.mainloop()
window = Tk()
window.title("Friend List")
window.configure(background="RoyalBlue4")
window.geometry("410x250")
#1user
Label(window, text="Bide ", bg="RoyalBlue4", fg="white",font="none 12 bold") .grid(row=0,column=0,sticky=W)
Label(window, text=" ", bg="RoyalBlue4", fg="white",font="none 12 bold") .grid(row=0,column=1,sticky=W)
Button(window, text="Chat",width=4, font="none 12 bold", command=boxchat) .grid(row=0,column=2,sticky=NE)
Button(window, text="Delete",width=6, font="none 12 bold", command=open_win_delete) .grid(row=0,column=3,sticky=NE)
Button(window, text="Block",width=5, font="none 12 bold", command=open_win_block) .grid(row=0,column=4,sticky=NE)
#2user
Label(window, text="Robi ", bg="RoyalBlue4", fg="white",font="none 12 bold") .grid(row=1,column=0,sticky=W)
Label(window, text=" ", bg="RoyalBlue4", fg="white",font="none 12 bold") .grid(row=1,column=1,sticky=W)
Button(window, text="Chat",width=4, font="none 12 bold", command=boxchat) .grid(row=1,column=2,sticky=NE)
Button(window, text="Delete",width=6, font="none 12 bold", command=open_win_delete) .grid(row=1,column=3,sticky=NE)
Button(window, text="Block",width=5, font="none 12 bold", command=open_win_block) .grid(row=1,column=4,sticky=NE)
#3user
Label(window, text="Ibo ", bg="RoyalBlue4", fg="white",font="none 12 bold") .grid(row=2,column=0,sticky=W)
Label(window, text=" ", bg="RoyalBlue4", fg="white",font="none 12 bold") .grid(row=2,column=1,sticky=W)
Button(window, text="Chat",width=4, font="none 12 bold", command=boxchat) .grid(row=2,column=2,sticky=NE)
Button(window, text="Delete",width=6, font="none 12 bold", command=open_win_delete) .grid(row=2,column=3,sticky=NE)
Button(window, text="Block",width=5, font="none 12 bold", command=open_win_block) .grid(row=2,column=4,sticky=NE)
Label(window, text=" ", bg="RoyalBlue4", fg="white",font="none 12 bold") .grid(row=5,column=5,sticky=W)
Label(window, text=" ", bg="RoyalBlue4", fg="white",font="none 12 bold") .grid(row=6,column=5,sticky=W)
Label(window, text=" ", bg="RoyalBlue4", fg="white",font="none 12 bold") .grid(row=7,column=5,sticky=W)
Label(window, text=" ", bg="RoyalBlue4", fg="white",font="none 12 bold") .grid(row=8,column=5,sticky=W)
Button(window, text="Exit",width=4, font="none 12 bold", command=close_window) .grid(row=9,column=6,sticky=SE)
window.mainloop()