I am using Tkinter Label widget to display some text to my UI Frame and I want the Label to change the text every-time I click the button. In my case I got wrong... it didn't change, is it possible?
This is my code..
currentCounterNumber = "0"
def counterPlus(teller_num):
#.... the data is working well ....
data = s.recv(1024)
if data:
currentCounterNumber = data
......
class Content(tk.Frame):
def __init__(self, master, teller_name,*args, **kwargs):
tk.Frame.__init__(self, *args, borderwidth=20, **kwargs)
self.L4 = tk.Label(self, text="Serving # " + currentCounterNumber +"!")
self.L4.pack( side = "top", fill="both", expand=False)
self.button1 = tk.Button(self, text="+", width=15, command=lambda: counterPlus(teller_no))
self.button1.pack(side = "top", fill="both", expand=True)
counterPlus
method to theContent
class, addContent.L4
as an argument tocounterPlus
or make achangeL4Text(newText)
method inContent
, because you need to access it to change its text. – Slate