質問

I have a tkinter page that will ask for user name and password( 2 entry boxes are used for this purpose). What i want is as soon as user run the script, the cursor should be in the username field(1st entry box)so that the user can type in the username without having to use mouse to click on the entry box before typing. Is there anyway to do it?

役に立ちましたか?

解決

The term you are looking for is "focus" -- focus defines which widget is active and accepting keyboard events. You can set the focus before the window is visible, and when it becomes visible it will have the focus.

To do this you should use the focus_set method, which is available for every widget:

import Tkinter as tk
...
entry1 = tk.Entry(...)
entry1.focus_set()
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top