在使用Tkinter编写代码的时候,有时候会忘记某个组件的参数是什么或者忘记某个参数怎么拼写的,此时可以通过如下方式查询组件的参数列表,以按钮组件为例:
1 # -*- coding:utf-8 -*- 2 from tkinter import * 3 bt = Button() 4 print(bt.keys())
执行上述代码,就可以打印出按钮组件Button的参数选项有哪些,如下:
[‘activebackground’, ‘activeforeground’, ‘anchor’, ‘background’, ‘bd’, ‘bg’, ‘bitmap’, ‘borderwidth’, ‘command’, ‘compound’, ‘cursor’, ‘default’, ‘disabledforeground’, ‘fg’, ‘font’, ‘foreground’, ‘height’, ‘highlightbackground’, ‘highlightcolor’, ‘highlightthickness’, ‘image’, ‘justify’, ‘overrelief’, ‘padx’, ‘pady’, ‘relief’, ‘repeatdelay’, ‘repeatinterval’, ‘state’, ‘takefocus’, ‘text’, ‘textvariable’, ‘underline’, ‘width’, ‘wraplength’] |
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/19730.html