I have asked a question previously about the same, here is a link to that: "Blink" Prompt window if parent window is clicked Tkinter
But it was marked as duplicate. Please help me with my code as I am not able to implement grab_set() in my code even after repeated tries. I was advised to open a new question, so here it is.
My Code:
import tkinter
from tkinter import *
def mainwindow():
root = Tk()
root.geometry("100x100")
b1 = Button(root, text="Exit", command=prompt)
b1.place(x=50, y=40)
mainloop()
def prompt():
pr = Tk()
pr.geometry("175x100")
pr.grab_set()
lable = Label(pr, text="Do you want to exit?").grid(row=0, column=0, padx=20, pady=15)
b1 = Button(pr, text="Yes", command=exit).grid(row=1, column=0, padx=75)
mainloop()
mainwindow()
Even after putting grab_set() on the pr window , I can access the root window. Please tell the correct way to put this function inside my code.