跳至主要內容
ImportError:No module named 'Tkinter'

For some reason, I can't use the Tkinter or tkinter module. After running the following command in the python shell

import Tkinter

AndersonHJB原创...大约 1 分钟tkinterdebugtkinterdebug
01-Tkinter 中 tearoff 的作用

你好,我是悦创。

我想你在学习 tkinter 的时候,会出现这个疑问:程序运行的时候菜单之下出现了一个虚线项。如下图:

image-20220524173907212

点击这个虚线选项后,菜单单独浮于应用之上:

image-20220524183243382

进查询发现了 tearoff 选项,当 tearoff=1 的时候该菜单被设置为可以独立出来的菜单,点击虚线就可以将菜单独立出来,当 tearoff=0 时就是正常的菜单了,但是默认情况下 tearoff=1 ,所以在程序中需要设置一下:


AI悦创原创...大约 2 分钟tkintertkinter