Checkbuttons को बाईं ओर संरेखित करने के लिए, आप anchor पैरामीटर का उपयोग कर सकते हैं और इसे "w" (पश्चिम) पर सेट कर सकते हैं। आइए एक उदाहरण लेते हैं और देखते हैं कि यह कैसे करना है।
चरण
Tkinter लाइब्रेरी इम्पोर्ट करें और Tkinter फ्रेम का एक इंस्टेंस बनाएं।
geometry मेथड का उपयोग करके फ्रेम का आकार सेट करें।
Checkbuttons को एक समूह में इकट्ठा करने के लिए एक LabelFrame बनाएं।
अगला, LabelFrame के अंदर एक checkbutton बनाएं और इसका anchor पश्चिम पर सेट करें। anchor='w'।
इसी तरह, अपने anchor को पश्चिम पर सेट करके तीन और checkbuttons बनाएं। यह सभी checkbuttons को बाईं ओर संरेखित करेगा।
अंत में, एप्लिकेशन विंडो का mainloop चलाएं।
उदाहरण
from tkinter import * root = Tk() root.geometry("700x350") # Create a LabelFrame frame = LabelFrame(root, text="Select the Subjects", padx=20, pady=20) frame.pack(pady=20, padx=10) # Create four checkbuttons inside the frame C1 = Checkbutton(frame, text="Mathematics", width=200, anchor="w").pack() C2 = Checkbutton(frame, text = "Physics", width=200, anchor="w").pack() C3 = Checkbutton(frame, text = "Chemistry", width=200, anchor="w").pack() C4 = Checkbutton(frame, text = "Biology", width=200, anchor="w").pack() root.mainloop()आउटपुट
निष्पादन पर, यह निम्नलिखित आउटपुट देगा:
