how to create a tkinter window
from tkinter import *
mywindow = Tk() #Change the name for every window you make
mywindow.title("New Project") #This will be the window title
mywindow.geometry("780x640") #This will be the window size (str)
mywindow.minsize(540, 420) #This will be set a limit for the window's minimum size (int)
mywindow.configure(bg="blue") #This will be the background color
mywindow.mainloop() #You must add this at the end to show the window
#Creating Tkinter Window In Python:
from tkinter import *
new_window = Tk() #Create a window ; spaces should be denoted with underscores ; every window should have a different name
new_window.title("My Python Project") #Name of screen ; name should be the one which you already declared (new_window)
new_window.geometry("200x150") #Resizes the default window size
new_window.configure(bg = "red") #Gives color to the background
new_window.mainloop() #Shows the window on the screen
# This will import all the widgets
# and modules which are available in
# tkinter and ttk module
from tkinter import *
from tkinter.ttk import *
# creates a Tk() object
master = Tk()
# sets the geometry of main
# root window
master.geometry("200x200")
# function to open a new window
# on a button click
def openNewWindow():
# Toplevel object which will
# be treated as a new window
newWindow = Toplevel(master)
# sets the title of the
# Toplevel widget
newWindow.title("New Window")
# sets the geometry of toplevel
newWindow.geometry("200x200")
# A Label widget to show in toplevel
Label(newWindow,
text ="This is a new window").pack()
label = Label(master,
text ="This is the main window")
label.pack(pady = 10)
# a button widget which will open a
# new window on button click
btn = Button(master,
text ="Click to open a new window",
command = openNewWindow)
btn.pack(pady = 10)
# mainloop, runs infinitely
mainloop()