Tkinter背景图片

时间:2019-02-27 20:48:14

标签: python tkinter pycharm

我尝试了类似主题的所有答案,但是它们并没有太大帮助。我正在使用grid方法来对齐我的小部件,这是我的代码的一部分:

import tkinter as tk

window = tk.Tk()
window.title("Sentiment analysis GUI")
window.resizable(0, 0)


logo = tk.PhotoImage(file="logo.png")
label = tk.Label(window, image=logo).grid(row=14)

tk.Label(window, text="Enter the keyword you want to search for:").grid(row=0)
text_entry = tk.Entry(window, width=20)
text_entry.grid(row=1)
tk.Button(window, text="Latest", width=6, command=gui.analysis).grid(row=2)
tk.Button(window, text="Yesterday", width=9, command=gui.analysis1).grid(row=3)
tk.Button(window, text="3-day", width=5, command=gui.analysis3).grid(row=4)
tk.Label(window, text="Enter the two keywords you want to compare and search for:").grid(row=5)
double_entry = tk.Entry(window, width=20)
double_entry.grid(row=6)
double_entry1 = tk.Entry(window, width=20)
double_entry1.grid(row=7)
tk.Button(window, text="Submit", width=6, command=gui.analysis2).grid(row=8)
tk.Label(window, text="Enter the Twitter username you want to search:").grid(row=9)
user_entry = tk.Entry(window, width=20)
user_entry.grid(row=10)
tk.Button(window, text="Submit", width=6, command=gui.user_analysis).grid(row=11)
tk.Label(window, text="Refer to the case study below:").grid(row=12)
tk.Button(window, text="Brexit", width=6, command=gui.image).grid(row=13)
window.mainloop()

但是,在我希望将其作为背景时,这会将图片放置在其他所有内容之下。有没有办法在保持网格布局的同时做到这一点?如果没有,那还有什么选择?

0 个答案:

没有答案