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
1from tkinter import Tk, Label, Button
2
3class MyFirstGUI:
4 def __init__(self, master):
5 self.master = master
6 master.title("A simple GUI")
7
8 self.label = Label(master, text="This is our first GUI!")
9 self.label.pack()
10
11 self.greet_button = Button(master, text="Greet", command=self.greet)
12 self.greet_button.pack()
13
14 self.close_button = Button(master, text="Close", command=master.quit)
15 self.close_button.pack()
16
17 def greet(self):
18 print("Greetings!")
19
20root = Tk()
21my_gui = MyFirstGUI(root)
22root.mainloop()
23
1import tkinter as tk
2
3window = tk.Tk() #Creates a window
4window.title("Trial") # Sets a title for the window
5window.geometry(520,850)# Size of window optional
6window.minisize(520,850) # Minimum size of window
7
8window.mainloop()# Sets visiblility to true
1#!/usr/bin/python
2
3import Tkinter
4top = Tkinter.Tk()
5# Code to add widgets will go here...
6top.mainloop()