2016-07-22 19 views
1

ラベル内の画像を2番目のTkinterウィンドウに表示しようとしています。 私のメインウィンドウ(ウィンドウ)では、イメージは完全に表示されますが、同じコードを2番目のウィンドウ(ルート)の内部に表示するとコードは実行されますが、イメージは表示されず、空白のみが表示されます。ラベルの画像がセカンダリウィンドウ(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) 

答えて

1

はあなたが誤って画像への参照を保持:

は、ここに私の関連するコードです。これは、この行を変更する必要があることを意味:

root.main_photo = main_photo 

へ:

main_photo.image = finance_news_image2 
+1

ありがとうございました!それは今働き、あなたの時間は非常に高く評価されます。 – Nick

関連する問題