2016-07-22 1 views
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) 

답변

1

당신은 잘못 이미지에 대한 참조를 유지 :

여기 내 관련 코드입니다.

root.main_photo = main_photo 

하려면 :

main_photo.image = finance_news_image2 
+1

가 대단히 감사합니다 이것은 당신이이 줄을 변경해야 의미! 이제 작동하며 시간을 크게 얻었습니다. – Nick

관련 문제