किसी भी एप्लिकेशन में टैब ऑर्डर यह तय करता है कि एप्लिकेशन के किस तत्व को फोकस सेट करना है। टिंकर एप्लिकेशन में, यह लगातार अगले विजेट की तलाश करता है जिस पर ध्यान केंद्रित करने की आवश्यकता होती है। एप्लिकेशन में टैब ऑर्डर सेट करने के लिए, हम एक फ़ंक्शन को परिभाषित कर सकते हैं और सभी विजेट चुन सकते हैं और लिफ्ट () विधि का उपयोग कर सकते हैं। यह फ़ंक्शन को प्रोग्रामेटिक रूप से किसी विशेष विजेट पर फ़ोकस सेट करने की अनुमति देगा।
उदाहरण
#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() आउटपुट
उपरोक्त कोड को चलाने से एंट्री विजेट्स के एक सेट के साथ एक विंडो और प्रत्येक विजेट के टैब क्रम को बदलने के लिए एक बटन प्रदर्शित होगा।
