- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 justification on Tkinter Text box?
The Text widget supports multiline user input from the user. We can configure the Text widget properties such as its font properties, text color, background, etc., by using the configure() method.
To set the justification of our text inside the Text widget, we can use tag_add() and tag_configure() properties. We will specify the value of "justify" as CENTER.
# Import the required libraries from tkinter import * # Create an instance of tkinter frame or window win=Tk() # Set the size of the tkinter window win.geometry("700x350") # Create a text widget text=Text(win, width=40, height=10) # justify the text alignment to the center text.tag_configure("center", justify='center') text.insert(INSERT, "Welcome to Tutorialspoint...") # Add the tag from start to end text text.tag_add("center", 1.0, "end") text.pack() win.mainloop()
If you run the above code, you will observe that the cursor of the text window will have justification set to its center.
- How to Delete Tkinter Text Box's Contents?
- How to insert text at the beginning of the text box in Tkinter?
- How to set font for Text in Tkinter?
- Text Justification in C++
- How to set the titled justification (position title text) of the titled border in Java
- How to display LaTex in real time in a text box in Tkinter?
- How to set default text for a Tkinter Entry widget?
- How to change Tkinter label text on button press?
- How to put an outline on a canvas text on Tkinter?
- How to place the text at the center of an Entry box in Tkinter?
- Specify the dimensions of a Tkinter text box in pixels
- Preventing validation on HTML5 text box
- Tkinter - How to put an outline on a canvas text
- How to force Tkinter text widget to stay on one line?
- How to set the font size of a Tkinter Canvas text item?