我可以得到tkinter來顯示窗口或背景圖像,沒有任何人有一個建議如何同時顯示(我希望對象進入背景圖像),我的代碼是如下:Tkinter畫布不顯示圖像
from tkinter import *
from tkinter import ttk
root= Tk()
# Code to add widgets will go here...
root.title("MTGO Daily Decklists")
def test():
print("things")
# pick a .gif image file you have in the working directory
# or give full path
image1 = PhotoImage(file="backgroundimage.gif")
w = Canvas(root, width=800, height=700,)
background = PhotoImage(file = "backgroundimage.gif")
w.create_image(500, 500, image=image1)
w.pack()
format_mtg= StringVar()
format_entry= ttk.Entry(w, width=25, textvariable=format_mtg)
format_entry_window = w.create_window(10, 10, anchor='n', window=format_entry)
format_entry.pack()
date= StringVar()
date_entry=ttk.Entry(root, width=25, textvariable=date)
date_entry_window = w.create_window(10, 10, anchor='n', window=date_entry)
date_entry.pack()
ttk.Label(w, text="input format here").pack()
ttk.Button(w, text="fetch", command=test).pack()
ttk.Label(w, text="input date here").pack()
sortby= StringVar()
sortby_entry= ttk.Entry()
sortby_entry.pack()
ttk.Label(w, text="input how you want the decklists to be sorted").pack()
root.mainloop()
我沒有看到任何嘗試在背景圖像之外創建畫布圖像。 – TigerhawkT3
哎呀,我改變 w.create_image(500,500,圖像=圖像1) 到 w.create_image(500,500,圖像=背景) 但它仍然有同樣的問題 – dovefromhell
當你把它改成'形象=背景「,你是否添加了一行來爲'image1'創建畫布圖像,還是隻創建一個圖像? – TigerhawkT3