简体   繁体   English

无法更改框架颜色Tkinter

[英]Unable to change Frame colour Tkinter

I am trying to change colour of frame but unable to change it to black Please tell the error 我正在尝试更改框架的颜色,但无法将其更改为黑色,请告诉错误

from tkinter import * ;
root=Tk()
frame=Frame(root);
frame.configure(background='black')
logo=Label(frame,text="gogo",fg="green");
logo.pack();
frame.pack();

root.mainloop()

You are changing the color. 正在更改颜色。 You just can't see it because the frame shrunk to fit the label. 您只是看不到它,因为框架会缩小以适合标签。

If you want the frame to fill the window, you need to use some options to pack : 如果您希望框架填满窗口,则需要使用一些选项来pack

frame.pack(fill="both", expand=True)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM