How to Open One Window from Another using Tkinter in Python

Python course with 57 real-time projects - Learn Python

Program 1

from tkinter import *

def btnclick():
   subwindow=Toplevel(mainw)
   subwindow.geometry('200x100')
   subwindow.title("This is Sub Window")
   subwindow.wm_iconbitmap('2.ico')
   Label(subwindow, text="This is sub Window Page", fg='green').pack()
subwindow.mainloop()

mainw=Tk()
mainw.geometry('300x300')
mainw.title("This is Main Window")
Label(mainw,text="This is Main Window Page",fg='Red').pack()
Button(mainw,text="Click here for Sub Window",command=btnclick).pack()

mainw.mainloop()

 

You give me 15 seconds I promise you best tutorials
Please share your happy experience on Google

follow dataflair on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *