Sunday, February 7, 2021

Entry Widget

 entry.py


#!/usr/bin/python3


from tkinter import *


root =Tk()


myLabel = Label(root)


e = Entry(root, width=50, bg='black', fg='white')

e.pack()

e.insert(0,"Tommy")


#button Function

def myClick():

    global myLabel

    myLabel.destroy()

    Hello = "Hello " + e.get()

    myLabel = Label(root, text=Hello)

    myLabel.pack()


#button calls Function - MyClick

myButton = Button(root, text="Type your name,", command=myClick)


#put Buttons in Window-root

myButton.pack()


root.mainloop( )


No comments:

Post a Comment