I'm working with Tkinter and I need to make 600 buttons in a grid of 6x100. Is there a way to produce generic variables by going through a for loop? Or do I have to type all 600?
Destray
0
Newbie Poster
Recommended Answers
Jump to PostYou don't have to type all 600 ! What code would you type to create only one ?
Jump to PostI suggest a button array
buttonlist = [] for i in range(600): buttonlist.append(Button(frame, *various_options))
Also, to change the image, i suggest something like
button.config(image=...)
but I normally don't use tkinter, so I'm not sure. This link may help.
Jump to PostHere is a widget with the 600 buttons
from Tkinter import* root = Tk() frame = Frame(root) frames = [] buttons=[] for i in range(24): f = Frame(frame) frames.append(f) for j in range(25): n = 25 * i + j b = Button(f, text= "%03d" % n) …
All 9 Replies
Gribouillis
1,391
Programming Explorer
Team Colleague
Destray
0
Newbie Poster
Gribouillis
1,391
Programming Explorer
Team Colleague
Destray
0
Newbie Poster
Gribouillis
1,391
Programming Explorer
Team Colleague
Destray
0
Newbie Poster
woooee
814
Nearly a Posting Maven
Gribouillis
1,391
Programming Explorer
Team Colleague
Destray
0
Newbie Poster
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.