1
我試圖在第二個Tkinter窗口中顯示標籤內的圖像。 在我的主窗口(窗口)中,圖像顯示完美,但是當我編寫出現在第二個窗口(根)內部的相同代碼時,代碼將執行,但看不到圖像,只能看到空白區域。標籤中的圖像不出現在輔助窗口中(tkinter)
任何幫助將不勝感激!
這裏是我的相關代碼:
# Create a variable assigned to the location of the main image, and then change its proportions (the higher the number/s, the smaller)
finance_news_image1 = PhotoImage(file = 'C:\\Users\\user\\Projects\\project\\x\\y\\z\\finance news.gif')
finance_news_image2 = finance_news_image1.subsample(1, 1)
# Create a variable for the main image of the menu, and define its placement within the grid
main_photo = Label(root, image = finance_news_image2)
root.main_photo = main_photo
main_photo.grid(row = 4, column = 0)
非常感謝您!它現在可以工作,並且您的時間非常感謝。 – Nick