Slipstream
Slipstream

Reputation: 407

default entry field in tkinter with python

I'm writing a small app using tkinter and Python to create a popup and ask for some input.

Currently I have to click on the text field before I can enter data. As there is only one text field I would like to just be able to type and the text field to be automatically active and ready to accept input, without having to first select the field.

How might I achieve this?

Upvotes: 3

Views: 426

Answers (1)

unutbu
unutbu

Reputation: 879561

If textfield is the Text object, call textfield.focus() to make the text field automatically active.

import tkinter as tk

root = tk.Tk()
textfield = tk.Text(root)
textfield.pack()
textfield.focus()
root.mainloop()

Upvotes: 4

Related Questions