I'm writing a program in python,tkinter and I need the text on the button to update... is there a simple way to do this?
Thropian
3
Junior Poster in Training
Recommended Answers
Jump to PostI suggest
button.configure(text="new text")
. Example:from Tkinter import * class App: def __init__(self, parent): self.myParent = parent self.fm = Frame(parent, width=400, height=300) self.fm.pack_propagate(0) # to keep the frame size self.fm.pack() self.index=0 self.btnBlue = Button(self.fm, text = "Blue %d" % self.index, command=self.make_blue) self.btnBlue.pack() def make_blue(self): self.fm.configure(bg="blue") …
Jump to PostA second way is to use a StringVar(). See the "textvariable" write up at http://infohost.nmt.edu/tcc/help/pubs/tkinter/button.html
All 5 Replies
Gribouillis
1,391
Programming Explorer
Team Colleague
woooee
814
Nearly a Posting Maven
Thropian
3
Junior Poster in Training
woooee
814
Nearly a Posting Maven
Thropian
3
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.