-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