简体   繁体   English

如何更改 python tkinter 中的背景颜色?

[英]How do I change the background color in python tkinter?

Python noob here, ive started a tkinter tutorial and no matter what method I use to change the background color it stays black. Python 菜鸟在这里,我开始了 tkinter 教程,无论我使用什么方法更改背景颜色,它都保持黑色。 Im using vs code on mac and I made sure everything is updated.我在 mac 上使用 vs 代码,并确保所有内容都已更新。 Ive also tried it in pycharm and the same problem occurs.我也在 pycharm 中尝试过,同样的问题发生了。 Im not getting any errors in the terminal.我在终端中没有收到任何错误。 Here is what I have,这是我所拥有的,

from tkinter import *

window = Tk()
window.geometry("500x500")
window.title("Weather.py")
window.config(bg="blue")
window.mainloop()

Any ideas?有任何想法吗?

Update: Tried it on another mac in the house and is seemed to work on that one.更新:在家里的另一台 Mac 上尝试过,似乎可以在那个 Mac 上工作。 Not sure why it wont work on mine.不知道为什么它不适用于我的。

Link provided by @Rory did the trick... Along with several restarts of both the computer and vs code. @Rory 提供的链接起到了作用......以及计算机和 vs 代码的几次重新启动。

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

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