3
Contributors
2
Replies
20
Views
3 Years
Discussion Span
Last Post by ZZucker
0

Typical example:

''' tk_toplevel_window101.py
create a toplevel popup window that overlaps the root window
'''

try:
    # Python2
    import Tkinter as tk
except ImportError:
    # Python3
    import tkinter as tk

def popup_window():
    window2 = tk.Toplevel(root)
    # give window2 a position to overlap the root window
    window2.geometry("200x200+{}+{}".format(150, 150))
    window2.title("window2")
    window2['bg'] = 'yellow'
    tk.Button(window2, text='Leave window2', command=window2.destroy).pack()

root = tk.Tk()   # root is a toplevel window
# set 200x200 window upper left corner to x=100, y=50
root.geometry("200x200+{}+{}".format(100, 50))
root.title("root")
root['bg'] = 'green'

tk.Button(root, text='Pop up window2', command=popup_window).pack()

root.mainloop()
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.