首页 > 解决方案 > 是否可以在一个循环中迭代图像,使其自动将图像放入 tkinter python 的每个按钮中?

问题描述

在此处输入图像描述

db = open("products.txt", "r")
file = csv.reader(db, delimiter=',')


table = [ [col[0],col[1],col[2]] for col in file]
pos_x, pos_y, cntr = 1, 1, 0
for value in table:
    if cntr % 5 == 0:
        print(cntr)
        pos_x = pos_x + 1
        #pos_x = pos_x + 114
        pos_y = 0

    b = Button(frame, text = (value[1] ), height = 6, width = 15, command=None, anchor=S,compound=CENTER)
    b.grid(row=pos_x, column=pos_y)

    pos_y = pos_y + 1
    #pos_y = pos_y + 100
    cntr = cntr + 1       

标签: pythonpython-3.xtkinter

解决方案


推荐阅读