-2
我有一个简单的GUI试用,我想在屏幕上显示少量图像。我开始与设置与灰色方块印花布它的窗口,并调整所希望的图像和现在我希望把它在框架上:图像不能从功能内显示
img = [img_resize(yellow_square, img_size), "text"]
base_panel = Label(root, image = img[0])
base_txt = Label(root, text = img[1])
base_panel.grid(row = x, column = y)
base_txt.grid (row = x, column = y)
...
for im in ls:
panel = Label(root, image = im[0])
panel.grid(row = x+im[1][1], column = y+im[1][2])
txt = Label(root, text = im[2])
txt.grid(row = x+im[1][1], column = y+im[1][2], sticky = 'S')
ls
是一个列表[图像(使用Image.open(img)
),位置偏移量,文本]
我猜想我的image = ...
有些问题,但我不明白是什么,因为我在将这些行复制到main之后工作。主体有另一个图像,所以这可能会影响到某种程度?
这是代码主:
for im in background: # background is a list of gray squares
# some manipulation an a,b
panel = Label(root, image = im)
panel.grid(row = a, column = b)
这里应该来的函数调用或线本身
字符串不需要相同的句柄?为什么? – CIsForCookies
因为字符串是不可变的。 – Novel
另一件事(无关)。如何在不声明第一个_global root_的情况下从函数内部安全地使用_root_? – CIsForCookies