Home C C++ Java Python Perl PHP SQL JavaScript Linux Selenium QT Online Test

Home » Python » Tkinter Examples » New Window

How to show New Window in Python Tkinter


from tkinter import *
from PIL import ImageTk, Image

root = Tk()
root.title("Show new window in Python")

def open():
    top = Toplevel()
    global img
    top.title("New Window")
    img = ImageTk.PhotoImage(Image.open("c:/img/1.jpg"))
    imgLbl = Label(top, image=img)
    closeBtn = Button(top, text="Close", command=top.destroy)
    imgLbl.grid(row=0, column = 0)
    closeBtn.grid(row=1, column=0)


Button(root, text="Open New Window", command=open).pack()

mainloop()

Ouput of the Program

How to show a new window in Python tkinter