【发布时间】:2022-11-11 02:17:34
【问题描述】:
我是 100% 的编码新手,几天前才开始遵循一些指南。我现在正在为我的桌面制作一个数字时钟,我想将我的背景更改为我拥有的自定义图像。
有人可以向我解释我可以在哪里更改它,以便背景成为我拥有的图像吗? BR
from tkinter import Tk
from tkinter import Label
import time
from PIL import Image, ImageTk
root = Tk()
root.title("Klocka")
root.attributes("-topmost", 1)
root.attributes('-alpha', 1)
root.iconbitmap('klocka.ico (1).ico')
root.geometry('600x400+50+50')
window_width = 255
window_height = 50
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
center_x = int(screen_width/3500 - window_width / 0.97)
center_y = int(screen_height/1 - window_height / 0.62)
root.geometry(f'{window_width}x{window_height}+{center_x}+{center_y}')
def present_time():
display_time = time.strftime("%I:%M:%S")
digi_clock.config(text=display_time)
digi_clock.after(200,present_time)
digi_clock = Label(root, font=("Arial",50),bg="black",fg="red")
digi_clock.pack()
present_time()
root.mainloop()
【问题讨论】:
标签: python image background