2014-10-27 90 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()