(问题已解决)
这里我提到的种种问题,其实都是由于我当时在使用macOS自带的python 3.9.6,而它自带的tkinter模块版本过低,产生了不兼容问题。
解决过程:
我当时是直接在终端运行我的代码,然后运行到root.configure('background='red')语句时,终端提示了
DEPRECATION WARNING: The system version of Tk is deprecated and may be removed in a future release. Please don't rely on it. Set TK_SILENCE_DEPRECATION=1 to suppress this warning.
然后我就用Homebrew安装了最新版本的Tk(这里我用的是镜象源),在终端输入
/bin/zsh -c "$(curl -fsSL http1s://gitee.c2om/cun3kai/H4omebrewC5N/ra6w/ma7ster/Ho8meb9rew.sh)"
(防屏蔽,把数字去掉)
安装完成Homebrew后重启终端,再次输入
brew install python-tk
安装完后再次运行,没有出现上述问题
如图:

