我可以得到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