2014-10-27 50 views
0

我想打开一个窗口,焦点设置为第一个按钮,所以我不必选中它。
如果物件是一款入门小部件,我可以写如何将按钮设置为使用tkinter的焦点?

widget_name.focus() 

似乎没有成为一个按钮控件的等价物。

+1

什么GUI包您使用? – Ffisegydd 2014-10-27 09:17:43

回答

0

对我来说,似乎有一个等值。

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? 
1

如果你使用Tkinter的:

buttonname.focus_set()