如何更改 tkinter 窗口的背景颜色

问题描述 投票:0回答:1

这不是文字颜色的问题,我只是想改变tk背景,这样它看起来会更好。

label=Label(window,text='TMU,College library',font='75',bg=blue)

from tkinter import*
from tkinter.ttk import*
window=Tk()
window.title('hello sir,welcome to python library!')
window.geometry('500x350') 
label=Label(window,text='TMU,College library',font='75')
label.grid(column=1,row=3)
#label.pack(pady=10,padx=10)

lbl=Label(window,text='Student name')
lbl.grid(column=2,row=6)
lbl=Label(window,text='Enrollment no')
lbl.grid(column=2,row=7)
lbl=Label(window,text='year/semester')
lbl.grid(column=2,row=8)
lbl=Label(window,text='course')
lbl.grid(column=2,row=9)

a1=Entry(window)
a1.grid(column=3,row=6)
a1=Entry(window)
a1.grid(column=3,row=7)
a1=Entry(window)
a1.grid(column=3,row=8)

没有任何关于错误的信息。

python tkinter
1个回答
0
投票

尝试使用:

window.config(bg=SOMECOLOR(e.g:'red'))

或:

window.configure(background=SOMECOLOR(e.g:'black'))
© www.soinside.com 2019 - 2024. All rights reserved.