list - How can i display a 3x3 grid in Python tkinter? -


for program intend develop, essential me develop 3x3 grid display words set has been converted list. achieve i'm aware of method supposedly create 3x3 grid using list linebreaks within developed list. however, program functions @ more diverse level , instead of having pre-defined text file / list, set/list defined users input , utalises file dialog allows user select own 9 words 3x3 grid. reason dont think possible apply line breaks. there way display 3x3 grid displays each of these 9 words. extremely grateful of advice given. code... if feels particular section of code them solve problem, not hesitate leave comment. thank much!

creating 3x3 grid no more difficult looping on items , creating widgets.

this creates 3x3 grid of labels, storing references widgets in dictionary:

table = tk.frame(root) row in range(3):     col in range(3):         label = tk.label(table, text="")         label.grid(row=row, column=col, sticky="nsew", padx=1, pady=1)         table[(row, col)] = label 

you can modify of cells of table using configure method of label widget. example, sets middle cell "hello":

table[(1,1)].configure(text="hello") 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -