बटन की स्थिति सेट करने के लिए, हम बटन विजेट के place मेथड का उपयोग करते हैं। place मेथड बटन के x और y निर्देशांक लेता है।
चरण
आवश्यक लाइब्रेरी इम्पोर्ट करें और Tkinter फ्रेम का एक इंस्टेंस बनाएं।
win.geometry मेथड का उपयोग करके फ्रेम का आकार सेट करें।
अगला, कई बटन बनाएं और उन्हें "Button-1", "Button-2", आदि नाम दें।
x और y निर्देशांक मान प्रदान करके place मेथड का उपयोग करके बटन की स्थिति सेट करें।
अंत में, एप्लिकेशन विंडो का mainloop चलाएं।
उदाहरण
# Import the Tkinter library from tkinter import * from tkinter import ttk # Create an instance of Tkinter frame win = Tk() # Define the geometry win.geometry("750x350") # Create Buttons in the frame button = ttk.Button(win, text="Button-1") button.place(x=325, y=125) button = ttk.Button(win, text="Button-2") button.place(x=325, y=175) button = ttk.Button(win, text="Button-3") button.place(x=325, y=225) #Create a Label Label(win, text="Position the Buttons", font='Consolas 15').pack() win.mainloop()आउटपुट
जब आप यह कोड निष्पादित करते हैं, तो यह निम्नलिखित विंडो दिखाएगा:

ध्यान दें कि हमने सभी तीन बटनों में x वेरिएबल को 325 पर फिक्स किया है इसीलिए बटन संरेखित हैं। आप place मेथड में (x, y) मानों को बदलकर बटन की स्थिति बदल सकते हैं।