gpt4 book ai didi

python - tkinter/tk() 的配置方法的参数是什么

转载 作者:太空宇宙 更新时间:2023-11-04 02:28:17 25 4
gpt4 key购买 nike

代码:

root = Tk()
root.configure(background="red")

.configure 方法中存在哪些参数 (args)。

它只是背景吗?如果不是,我该如何查看它们?

最佳答案

configure 方法的参数对于每个小部件都是不同的。

Tkinter 的小部件有一个概念 optionscolorsize 等等。每个小部件都存在其中一些选项,但其他选项则不存在。例如,Entry class有一个大多数其他小部件没有的 validatecommand 选项。

configure 方法允许您更改小部件的选项,可用参数取决于您正在配置的小部件。 Entry().configure(validatecommand=bool) 有效,但 Label().configure(validatecommand=bool) 无效。

要查找有效参数/选项的完整列表,您可以查看 the documentation小部件,或调用不带参数的 configure 方法,这将列出所有可用选项:

>>> root.configure().keys()
dict_keys(['bd', 'borderwidth', 'class', 'menu', 'relief', 'screen', 'use', 'background', 'bg', 'colormap', 'container', 'cursor', 'height', 'highlightbackground', 'highlightcolor', 'highlightthickness', 'padx', 'pady', 'takefocus', 'visual', 'width'])

关于python - tkinter/tk() 的配置方法的参数是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49831943/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com