Application in Tkinter – Technoinc
Today we are going to use the first button and text widgets in our application. Where two-button, two labels, and two two text fields are there.
Here is the code for that. First, you can run this code and then try to edit it with your requirements.
from tkinter import *
print(“First Name: %s\nLast Name: %s” % (e1.get(), e2.get()))
master = Tk()
Label(master, text=”First Name”).grid(row=0)
Label(master, text=”Last Name”).grid(row=1)
e1 = Entry(master)
e2 = Entry(master)
Button(master, text=’Quit’, command=master.quit).grid(row=3, column=0, sticky=W, pady=4)
Button(master, text=’Show’, command=show_entry_fields).grid(row=3, column=1, sticky=W, pady=4)
Here we are using two labels i.e First Name and Last Name. Two buttons which are Quit and Show. Where Quit is to terminating our application and by pressing Show button our values of First Name and Last Name is going to print on terminal.
By running our application we can show this type of output.
If we going to press the Show button then it will show the text of text fields on a terminal.
And we get output like this,
On clicking on the Quit button it will simply close our application.
In the next blog, we are going to use some more buttons in our application, which are radio and check buttons and also we see how to draw different shapes in Tkinter.