![]() |
How To Create Windows Application in Python|Using Tkinter Modules |
How To Create Windows Application in Python|Using Tkinter Modules
Python Tkinter: Tkinter is a GUI library for Python. It is used to create a graphical user interface for desktop applications. It is a standard Python interface to the Tk GUI toolkit shipped with Python. A Python Tkinter is the fast and easy way to create GUI applications.it is very simple to Create the best Application and windows software using Tkinter Modules.
Tkinter mainloop(): A mainloop is a method known by the name mainloop() is used when your application is ready to run. mainloop() function is an infinite loop used to run the application, wait for an event to occur, and process the event as long as the window is not closed.m.mainloop() function.
Steps to Create GUI Window
1.import the Tkinter module in the python program.
2.Create the GUI main window.
3.Add the widgets like labels, buttons, etc.
4.Call the main loop so that the actions can take place on the user's computer screen show the output screen.
2.Create the GUI main window.
3.Add the widgets like labels, buttons, etc.
4.Call the main loop so that the actions can take place on the user's computer screen show the output screen.
How To Create GUI Window in Python?
How To Set Background Color GUI Window in Python?
Python Tkinter Label: A Label widget is used to provide a caption for other widgets. It can be used as a heading. It can also contain images.
Syntax of Label in Python.
Lbl = Label ( w, option1,option2, ... )
Here w is the parent window and the option can be used as key-value pairs.
How To Create Tkinter Label in Python?
Python Tkinter Button: A Python Tkinter Button widget is used to provide different kinds of buttons in an application.
Syntax of Button in Python.
btn = Button ( w, option1,option2, ... )
Here w is the parent window and the option can be used as key-value pairs.
How To Create Tkinter Button in Python?
How To Work Call Function Tkinter Button in Python?
Python Tkinter Entry: A Python Entry is used to create a single-line textbox that is used to take accept a value from the user.
Syntax of Entry in Python.
ent = Entry (w, option1,option2, ... )
Here w is the parent window and the option can be used as key-value pairs.
How To Create Entry Textbox in Python?
How To Create GUI Calculator in Python?
from tkinter import messagebox
from tkinter import *
w = Tk()
w.geometry("300x180")
w['bg']="pink"
def add():
f=firstNum.get()
s=secondNum.get()
messagebox.showinfo("Addition",(f+s))
def sub():
f=firstNum.get()
s=secondNum.get()
messagebox.showinfo("Subtraction",(f-s))
def mul():
f=firstNum.get()
s=secondNum.get()
messagebox.showinfo("Multiplication",(f*s))
def div():
f=firstNum.get()
s=secondNum.get()
messagebox.showinfo("Division",(f/s))
firstNum=IntVar()
secondNum=IntVar()
Label(w, text="First Number:",width="13").place(x=50,y=50)
Label(w, text="Second Number:",width="13").place(x=50,y=95)
Entry(w,textvariable=firstNum).place(x=280,y=50)
Entry(w,textvariable=secondNum).place(x=280,y=90)
Button(w,text="Add",width="5",bg="orange",command=add).place(x=150,y=220)
Button(w,text="Subtract",width="5",bg="orange",command=sub).place(x=285,y=220)
Button(w,text="Multiply",width="5",bg="orange",command=mul).place(x=430,y=220)
Button(w,text="Division",width="5",bg="orange",command=div).place(x=565,y=220)
w.mainloop()
*****OUTPUT*****
from tkinter import *
w = Tk()
w.geometry("300x180")
w['bg']="pink"
def add():
f=firstNum.get()
s=secondNum.get()
messagebox.showinfo("Addition",(f+s))
def sub():
f=firstNum.get()
s=secondNum.get()
messagebox.showinfo("Subtraction",(f-s))
def mul():
f=firstNum.get()
s=secondNum.get()
messagebox.showinfo("Multiplication",(f*s))
def div():
f=firstNum.get()
s=secondNum.get()
messagebox.showinfo("Division",(f/s))
firstNum=IntVar()
secondNum=IntVar()
Label(w, text="First Number:",width="13").place(x=50,y=50)
Label(w, text="Second Number:",width="13").place(x=50,y=95)
Entry(w,textvariable=firstNum).place(x=280,y=50)
Entry(w,textvariable=secondNum).place(x=280,y=90)
Button(w,text="Add",width="5",bg="orange",command=add).place(x=150,y=220)
Button(w,text="Subtract",width="5",bg="orange",command=sub).place(x=285,y=220)
Button(w,text="Multiply",width="5",bg="orange",command=mul).place(x=430,y=220)
Button(w,text="Division",width="5",bg="orange",command=div).place(x=565,y=220)
w.mainloop()
*****OUTPUT*****