0
A
回答
0
感謝您的鏈接,我現在正在閱讀它。圖像最終的解決方案是在需要時簡單地將兩個圖像放在另一個的上面。這似乎(我希望)不會造成電子內存泄漏,因爲相同的物品會不斷重複使用:
from tkinter import *
#by David Beck www.dwbeck.com
green_circle = 'Green_Circle.png'
red_circle = 'Red_Circle.png'
def create_image():
if var.get() == 1:
red_button.lift(green_button)
if var.get() == 0:
green_button.lift(red_button)
def pass_pass():
pass
root=Tk()
var = BooleanVar()
w = Canvas(width=250, height=150)
w.pack()
green_circle_tk = PhotoImage(file=green_circle)
red_circle_tk = PhotoImage(file=red_circle)
green_button = Button(root, text="", command=pass_pass)
green_button.config(image=red_circle_tk)
green_button.place(x=20, y=100)
red_button = Button(root, text="", command=pass_pass)
red_button.config(image=green_circle_tk) #,width="40",height="40"
red_button.place(x=20, y=100)
checkbox_2 = Checkbutton(root, text='red/green', variable=var, command=create_image).pack()
root.mainloop()
+0
所以,你真正的問題只是你需要交換按鈕上的圖像?你不需要兩個按鈕,你可以使用一個按鈕,只是換出圖像。 –
相關問題
- 1. 從內存中完全刪除視圖
- 2. 完全刪除Jupyter
- 3. 完全刪除Heroku
- 4. 完全刪除Javascript
- 5. kohana3.0如何完全刪除圖像文件?
- 6. 暫時從python中刪除圖像
- 7. 完全居中圖像?
- 8. MonetDB完全刪除表
- 9. 如何完全刪除gcloud?
- 10. 完全刪除SKSpriteNode變量
- 11. 從django完全刪除memcached
- 12. 完全刪除標籤
- 13. 完全刪除XCode目標
- 14. 刪除JavaScript對象完全
- 15. TYPO3庫完全刪除
- 16. 完全刪除wp登錄
- 17. 完全刪除空數組
- 18. 從vim完全刪除NERDTree?
- 19. 在Django中刪除圖像
- 20. Flex 3 - 刪除圖像閃爍
- 21. 刪除WooCommerce圖像 - 全屏寬度
- 22. 完全刪除EF數據庫在c#
- 23. 更改或完全刪除在Android
- 24. 完全刪除網址中的散列
- 25. 如何完全刪除Perl中的包?
- 26. 如何在arch linux中用python 2完全替換python 3
- 27. 完全刪除行除外第一個
- 28. 在n行中刪除n-1行在Python中是完全相同的
- 29. 從JBoss 6或Glassfish 3完全刪除JSF?
- 30. 刪除圖像
您在詢問之前是否做過任何研究?這個網站上有很多關於回收記憶的問題。例如:http://stackoverflow.com/q/3935675/7432 –