我试着把句子(欢迎货币转换器)放在最上面,但没有成功。你知道吗
import tkinter as tk
my_window = tk.Tk()
photo = tk.PhotoImage(file='currency conventer.png')
background_window = tk.Label(my_window,
text='Welcome\nCurrency Converter',
image=photo,
compound=tk.CENTER,
font=('Calibri',20,'bold italic'),
fg='black')
background_window.pack()
my_window.mainloop()
两件事
您需要使用
compound=tk.BOTTOM
,这样图像就会位于文本下方。如果你的图片太大,你需要调整它的大小,这样它就不会把你的文字“推”到屏幕的顶端。
试试这个:
在这里,我使用枕头导入图像,调整大小,然后把它传递给ImageTk。要安装枕头,请遵循以下说明。How to install Pillow on Python 3.5?
请随时向我寻求更多的帮助。它对我有用,我很想知道它对你是否有用!你知道吗
相关问题 更多 >
编程相关推荐