- Trending Categories
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 the tab order in a Tkinter application?
The Tab order in any application decides which element of the application have to set focus. In a Tkinter application, it constantly looks for the next widget that needs to be focused on. To set the tab order in the application, we can define a function and pick all the widgets and use lift() method. It will allow the function to set the focus on a particular widget programmatically.
Example
#Import the required libraries from tkinter import * #Create an instance of Tkinter Frame win = Tk() #Set the geometry of Tkinter Frame win.geometry("700x350") #Add entry widgets e1 = Entry(win, width= 35, bg= '#ac12ac', fg= 'white') e1.pack(pady=10) e2 = Entry(win, width= 35) e2.pack(pady=10) e3 = Entry(win, width= 35, bg= '#aa23dd',fg= 'white') e3.pack(pady=10) #Change the tab order def change_tab(): widgets = [e3,e2,e1] for widget in widgets: widget.lift() #Create a button to change the tab order Button(win, text="Change Order", font=('Helvetica 11'), command= change_tab).pack() win.mainloop()
Output
Running the above code will display a window with a set of Entry widgets and a button to change the Tab order of each widget.
- Related Articles
- How to bind to shift+tab in Tkinter?
- How to make a system tray application in Tkinter?
- How to remove Ttk Notebook Tab Dashed Line? (tkinter)
- How to display a tkinter application in fullscreen on macOS?
- How to bundle a Python Tkinter application including dependencies?
- Change the color of "tab header" in ttk.Notebook (tkinter)
- How to create a System Tray icon of a Tkinter application?
- How to set the background color of a single tab in a JTabbedPane Container with Java?
- How to create a borderless fullscreen application using Python-3 Tkinter?
- How to set the background color of a ttk.Combobox in tkinter?
- How do I change the overall theme of a tkinter application?
- Set the width of a tab character with CSS
- How to set the height/width of a Label widget in Tkinter?
- How to set the width of a Tkinter Entry widget in pixels?
- How to set a Tkinter window to a constant size?

Advertisements