how to use tkinter in python code example

Example 1: how to make 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

Example 2: how to install tkinter

sudo apt-get install python3-tk

Example 3: how to install tkinter for python

# for pip and windows, in cmd, write:
pip install tk

Example 4: python tkinter

import tkinter as tk

obj = tk.Tk() # Creates a tkinter object
label = tk.Label(obj, text="This is a text button")

Example 5: how to create tkinter window

import tkinter
master = tkinter.Tk()
master.mainloop()

Example 6: tkinter

#I love tkinter!

Tags:

Cpp Example