0% found this document useful (0 votes)
37 views2 pages

Tkinter Text Entry Tutorial

Lesson 4 of my PDF written tutorials. Building GUI's in Python - using Tkinter - Python's built in toolkit for GUI development

Uploaded by

Ben Woodfield
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views2 pages

Tkinter Text Entry Tutorial

Lesson 4 of my PDF written tutorials. Building GUI's in Python - using Tkinter - Python's built in toolkit for GUI development

Uploaded by

Ben Woodfield
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

BenWoodfieldraserppsprograms@gmail.

comTkinterGUIBasics

Example4:TkinterGUIWindow/TextEntry
Inthisexample,[Link]
[Link],Irecommendchangingthecolours,orfontsizes
[Link].
[Link],butwehavegonea
[Link],andwhenthebuttonispressedthewrittentextgets
printedintheShellwindow.
Heresthenewcode:
from tkinter import *
top = Tk()
[Link]('Tkinter GUI - Example 4')
[Link](400, 400)
[Link](bg='orange')
lbl = Label(top, text='Assigning Functions To Buttons', bg='yellow', fg='blue', font='14')
[Link]()
def hello_callback(): print('Button Clicked')
def callback():
print([Link]())
btn = Button(top, text='Click Here', font='freesansbold, 14', command=hello_callback)
[Link]()
exit_button=Button(top, text='Exit', fg='red', bg='black', font='freesansbold, 14', command=quit)
exit_button.pack(side=BOTTOM)
ent = Entry(top)
[Link]()
btn2 = Button(top, text='Print Text', fg='blue', font='bold, 14', width=15, command=callback)
[Link]()
[Link]()

Sowehaveaddedanewfunction:

def callback()

Thenewfunctionhasalinereading print([Link]()) WhichtellsPythonto'Get'thestringthatis


enteredintheentrybox,and'print'[Link]
functionlikethis,wecanassignitasacommandtoabutton(ourclickherebutton)
Againafewvisualdetailshavemayhavebeenalteredbutbynowyoushouldbeabletochangethese
yourselfasit'snothingwehaven'tcoveredalready.
Inthenextexamplewewillrewriteanexistingprogramofminethattakesuserinput,performsacalculation
withit,thengivesitbacktotheuserbydisplayingitintheGUIItisaFeettoMetersconverterapp/
program.

You might also like