olo*_*fom 42 python tk-toolkit tkinter
我正在用Tkinter编写幻灯片程序,但我不知道如何将背景颜色更改为黑色而不是标准浅灰色.如何才能做到这一点?
import os, sys
import Tkinter
import Image, ImageTk
import time
root = Tkinter.Tk()
w, h = root.winfo_screenwidth(), root.winfo_screenheight()
root.overrideredirect(1)
root.geometry("%dx%d+0+0" % (w, h))
root.focus_set()
root.bind("<Escape>", lambda e: e.widget.quit())
image = Image.open(image_path+f)
tkpi = ImageTk.PhotoImage(image)
label_image = Tkinter.Label(root, image=tkpi)
label_image.place(x=0,y=0,width=w,height=h)
root.mainloop(0)
Run Code Online (Sandbox Code Playgroud)
msw*_*msw 85
root.configure(background='black')
Run Code Online (Sandbox Code Playgroud)
或更一般地说
<widget>.configure(background='black')
Run Code Online (Sandbox Code Playgroud)
iCo*_*dez 19
我知道这有点老问题但是:
root["bg"] = "black"
Run Code Online (Sandbox Code Playgroud)
也会做你想做的事情,而且打字更少.
config是另一种选择:
widget1.config(bg='black')
widget2.config(bg='#000000')
Run Code Online (Sandbox Code Playgroud)
或者:
widget1.config(background='black')
widget2.config(background='#000000')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
192235 次 |
| 最近记录: |