- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set focus on Entry widget in Tkinter?
Let us suppose that there are some widgets present in an application such that we have to focus on a particular widget. By using the focus_set() method, we can activate the focus on any widget and give them priority while executing the application.
Example
#Import tkinter library from tkinter import * #Create an instance of tkinter frame win = Tk() #Set the geometry of tkinter window win.geometry("750x250") #Create an Entry Widget entry= Entry(win, width= 25) entry.insert(0,"ttk Entry widget") entry.pack() #Set the focus to Entry widget entry.focus_set() win.mainloop()
Output
When we run our program, it will display a window with an active entry widget.
Advertisements