Tkinter GUI
* GUI: Graphical User Interface
* Tkinter is the GUI library for the python
* It is a fastest and easiest way to create a GUI application in python and it is most commonly used for GUI application.
Step to Create GUI Application:
* Import the module tkinter
* Create the main window
* Add any number of widgets to the main window
* Apply the event trigger on the widgets.
Import and Method of Tkinter
* First Import the module tkinter
import tkinter
* There are two main methods
1) Tk()
2) mainloop()
Methods Of Tkinter
* Tk(): To create a main window tkinter provide a method.
* mainlooop(): There is a method know by the name mainloop(), it is used to run your application.
Widgets of Tkinter
* Button(): To add a button in your application.
Syntax: w=Button(master, option=value)
* Entry(): It is used to take input from user.
Syntax: w=Entry(master, option=value)
* Label(): It is used to display a text in your application.
Syntax: w=Label(master, option=value)
Program 1) #Create a main window
from tkinter import*
r=Tk() #create main window
mainloop() #mainloop method called
Program 2) #Create a customize window
from tkinter import*
r=Tk()
r.geometry(250x250)
r.title("HRSIKH")
r.configure(bg="Blue")
mainloop()
Program 3) #Adding widgets into window
from tkinter import*
r=Tk()
r.geometry(400x400)
r.title("HRSIKH")
r.configure(bg="Blue")
#adding label in main window
rn=Label(r,text="Roll no.")
rn.place(x=20, y=20)
fn=Label(r,text="Firstname")
fn.place(x=20, y=50)
rln=Label(r,text="Lastname")
ln.place(x=20, y=80)
em=Label(r,text="Email")
em.place(x=20, y=110)
#adding entry box in main window
ern=Entry()
ern.place(x=100, y=20)
efn=Entry()
efn.place(x=100, y=50)
eln=Entry()
eln.place(x=100, y=80)
eem=Entry()
eem.place(x=100, y=110)
#adding button in main window
btn1=Button(r,text="Button1", bg="Red")
btn1.place(x=20, y=200)
btn2=Button(r,text="Button2", bg="Yellow")
btn2.place(x=100, y=200)
mainloop()