python圖像,python顯示函數圖像_python – 顯示存儲在函數中的圖像

 2023-11-18 阅读 26 评论 0

摘要:我正在制作一個Python程序,讓用戶可以發現新喀里多尼亞的藝術作品(它是太平洋上一個小的法國島嶼:)).python圖像。我嘗試調用存儲圖像的函數.但經過幾個小時的研究后,我發現這個webpage描述了我所遇到的問題.會發生什么事情,因為我必須“保留對圖像對象的額外引用.”這樣做的一

我正在制作一個

Python程序,讓用戶可以發現新喀里多尼亞的藝術作品(它是太平洋上一個小的法國島嶼:)).

python圖像。我嘗試調用存儲圖像的函數.但經過幾個小時的研究后,我發現這個webpage描述了我所遇到的問題.會發生什么事情,因為我必須“保留對圖像對象的額外引用.”這樣做的一個簡單方法是將圖像分配給窗口小部件屬性.我試著這樣做,但由于我是初學者,我真的不知道該怎么做.

這是我的腳本:

from tkinter import *

python畫圖、# Création de la fenêtre de menu

fenetre=Tk()

fenetre.title("ART'CAL")

python讀取圖像。Canevas=Canvas(fenetre, height=768,width=1346)

Canevas.pack()

# Insertion de l'image du menu

python圖像增強。PhotoMenu = PhotoImage(file ='Diapositive1.gif')

Fond = Canevas.create_image(680, 350, image=PhotoMenu)

# Création de la fenêtre de règles du jeu

def Rules():

fenetre=Tk()

fenetre.title("Règles du jeu")

CanevasRules=Canvas(fenetre, height=768,width=1346)

CanevasRules.pack()

# Insertion de l'image des règles du jeu

PhotoRules = PhotoImage(file ='Diapositive2.gif')

Fond = CanevasRules.create_image(680, 350, anchor=CENTER, image=PhotoRules)

Suivant = Button(CanevasRules, text="Suivant")

Suivant.place(x=600, y=510)

Suivant.config(font=('Product Sans',20,'bold'))

# Création et personnalisaton du bouton "Découvrir"

Decouvrir = Button(Canevas, text="Découvrir")

Decouvrir.place(x=600, y=510)

Decouvrir.config(font=('Product Sans',20,'bold'), command=Rules)

fenetre.mainloop()

一切正常,直到我按DECOUVRIR(法語中的“發現”).它不顯示任何圖像.誰能幫助我并告訴我如何顯示這張圖片?

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/2/178026.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息