Setting focus to specific TKinter entry widget

后端 未结 2 697
慢半拍i
慢半拍i 2020-12-06 16:25

I\'d like to set the focus of my program to a specific entry widget so that I can start entering data straight-away - how can I do this?

My curr

相关标签:
2条回答
  • 2020-12-06 16:37

    I tried this way and it is ok

    entry= Entry(root)
    entry.focus()
    entry.pack
    
    0 讨论(0)
  • 2020-12-06 16:54

    Use entry.focus():

    from Tkinter import *
    root = Tk()
    frame=Frame(root,width=100,heigh=100,bd=11)
    frame.pack()
    label = Label(frame,text="Enter a digit that you guessed:").pack()
    entry= Entry(frame,bd=4)
    entry.pack()
    entry.focus()
    button1=Button(root,width=4,height=1,text='ok')
    button1.pack()
    
    root.mainloop()
    
    0 讨论(0)
提交回复
热议问题