- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 align checkbutton in ttk to the left side?
To align the checkbuttons to left, you can use the anchor parameter and set it to "w" (west). Let's take an example and see how to do it.
Import the tkinter library and create an instance of tkinter frame.
Set the size of the frame using geometry method.
Create a LabelFrame to collect the checkbuttons in a group.
Next, create a checkbutton inside the LabelFrame and set its anchor to the West. anchor='w'.
Similarly, create three more checkbuttons with their anchor set at West. It will align all the checkbuttons to the left.
Finally, run the mainloop of the application window.
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()
On execution, it will produce the following output −
- How to align text to the right in ttk Treeview widget?
- How to align images side by side with CSS?
- How to align text to the left in Tkinter Label?
- How to move the Y-axis ticks from the left side of the plot to the right side in matplotlib?
- How to remove the label on the left side in matplotlib.pyplot pie charts?
- Usage of Bootstrap previous class to left align the links
- How to left align components vertically using BoxLayout with Java?
- How to Add One Side Left Border to TextView in Android using XML?
- Program to find the left side view of a binary tree in C++
- How to disable checkbutton Tkinter (grey out)?
- How to set the position of legend of a ggplot2 graph to left-top side in R?
- How to Align Column DIVs as Left-Center-Right with CSS Flex
- How to change the color of ttk button in Tkinter?
- Python Pandas - Check whether the interval is closed on the left-side, right-side, both or neither
- How to disable (grey out) a checkbutton in Tkinter?