Python Forum
Avoid multiple windows of the same kind
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Avoid multiple windows of the same kind
#2
You can add a boolean to remember if the window was already created
def on_press(event):
    if on_press.window_created:
        return
    cont,att = rect[0].contains(event)
    if cont == True:
        win = tk.Tk()
        on_press.window_created = True
        label1 = ttk.Label(win, text ="Test1").grid(column=0,row=0)
        label2 = ttk.Label(win, text ="Test2").grid(column=0,row=1)
        label3 = ttk.Label(win, text ="Test3").grid(column=0,row=2)
on_press.window_created = False
...
Reply


Messages In This Thread
RE: Avoid multiple windows of the same kind - by Gribouillis - Oct-30-2018, 08:32 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Tkinter multiple windows in the same window tomro91 1 910 Oct-30-2023, 02:59 PM
Last Post: Larz60+
  'Your first program' type question, be kind davediamond 0 1,113 Apr-11-2022, 08:12 PM
Last Post: davediamond
  [Tkinter] Program with Multiple Windows - how to use Class: Riddle 1 3,009 Apr-09-2020, 08:30 PM
Last Post: Riddle
  What kind of widget is it? aquerci 1 1,847 Apr-05-2020, 05:37 PM
Last Post: DT2000
  [Tkinter] How to exit when multiple root windows. weatherman 4 5,540 May-10-2018, 11:52 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020