Rushy Panchal
Rushy Panchal

Reputation: 17532

Make Entry Widget Active

I am trying to change my window so that the Entry Widget is "active": without clicking in the widget, you can type and it goes directly into the box (same as IDLE's Alt + M window --- when the window opens, without having to click into the Entrybox, you can type into it).

I tried using entry.icursor():

from Tkinter import *
class GetFileName:
    def __init__(self, master):
        self.frame = Frame(master)
        self.entryFrame = Frame(self.frame)
        self.fEntry = Entry(self.entryFrame, width = 50, justify = CENTER)
        self.fEntry.icursor(0) # thought this would make it "active"
        # a bunch of other widgets
        self.fEntry.grid(row = 1, column = 2, padx = 5, pady = 5)
        self.entryFrame.grid(row = 1)
        self.frame.grid()

root = Tk(className = ' Module Opener')
app = GetFileName(root)
root.rowconfigure(0, weight = 1)
root.columnconfigure(0, weight = 1)
root.mainloop()

How can I fix this so that it is the active window? Thanks!

Upvotes: 0

Views: 182

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 386010

You need to call focus_set on the entry widget.

Upvotes: 1

Related Questions