1from tkinter import *
2
3mywindow = Tk() #Change the name for every window you make
4mywindow.title("New Project") #This will be the window title
5mywindow.geometry("780x640") #This will be the window size (str)
6mywindow.minsize(540, 420) #This will be set a limit for the window's minimum size (int)
7mywindow.configure(bg="blue") #This will be the background color
8
9mywindow.mainloop() #You must add this at the end to show the window
1#Creating Tkinter Window In Python:
2
3from tkinter import *
4
5new_window = Tk() #Create a window ; spaces should be denoted with underscores ; every window should have a different name
6new_window.title("My Python Project") #Name of screen ; name should be the one which you already declared (new_window)
7new_window.geometry("200x150") #Resizes the default window size
8new_window.configure(bg = "red") #Gives color to the background
9
10new_window.mainloop() #Shows the window on the screen
1#!/usr/bin/python
2
3import Tkinter
4top = Tkinter.Tk()
5# Code to add widgets will go here...
6top.mainloop()
1from tkinter import *
2
3root = Tk()
4root.geometry("500x500")
5root.title("My App")
6root.config(bg="#ff0000")
7
8def printhi(*args):
9 print("Hi!")
10
11btn = Button(root, text="Click to print hi", command=printhi)
12btn.place(x=200, y=200)
13
14root.mainloop()