我想打开一个窗口并将焦点设置在第一个按钮上,这样我就不必通过制表符到达它。
如果小部件是输入小部件,我可以编写
如果小部件是输入小部件,我可以编写
widget_name.focus()
似乎没有与按钮小部件相对应的等效物。
widget_name.focus()
似乎没有与按钮小部件相对应的等效物。
如果您正在使用Tkinter:
buttonname.focus_set()
tkinter.Button = class Button(Widget)
| Button widget.
|
| Method resolution order:
| Button
| Widget
| BaseWidget
| Misc
| Pack
| Place
| Grid
| builtins.object
...
| focus = focus_set(self)
| Direct input focus to this widget.
|
| If the application currently does not have the focus
| this widget will get the focus if the application gets
| the focus through the window manager.
而且在tkinter.py
中
class Misc:
# ...
focus = focus_set # XXX b/w compat?