Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tkinter
#4
To change the text of a label you can use a tkinter StringVar:
label_name = StringVar()
Label(root, textvariable=label_name)
label_name.set('Some text')
Or you can use the configure command:
label = Label(root, text'='Initial Label')
label.configure(text='New label text')
Or you can use the fact that many tkinter attributes can be set like the widget is a dictionary.
label = Label(root, text'='Initial Label')
label['text'] = 'New label text'
To have get the text from an entry you will use the get() function. This is most easily done with a StringVar():
entry_text = StringVar()
Entry(root, textvariable=enry_text)
entry_text.set('Some text')
text = entry_text.get()
You will have to write a function that gets the text from the entry and sets the text of the label. Do you know how to do that?

You will have to call the function. You can make a button and when the button is pressed it calls the function. You can also bind events for the Entry. For example, you could call a function when the Enter/Return key is pressed. Which way are you planning to do this?

You will need to keep track of how many times the label is changed. Do you know how to do that?

After the variable is changed three times you should either make the entry not active or erase it. Do you know how to do that.

Sounds like such a simple thing, but there are several decisions to be made and several steps to writing and testing the code.

Good luck.
Reply


Messages In This Thread
tkinter - by nashenas - Feb-21-2021, 03:41 PM
RE: tkinter - by Yoriz - Feb-21-2021, 06:05 PM
RE: tkinter - by BashBedlam - Feb-21-2021, 06:21 PM
RE: tkinter - by deanhystad - Feb-21-2021, 06:25 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020