- Trending Categories
- Data Structure
- Operating System
- MS Excel
- 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 place the text at the center of an Entry box in Tkinter?
To put a border around a Frame in Tkinter, we have to use the highlightbackground and highlightthickeness parameters while creating the Frame. Let's take an example and see how to use these two parameters.
Import the tkinter library and create an instance of tkinter frame.
Set the size of the frame using geometry method.
Create a frame with Frame() method. Highlight the border of the frame with a color, highlightbackground="blue". Then, set the thickness of the border, highlightthickness=2.
Next, create some widgets inside the frame. In the example, we have placed four checkbuttons and a button inside the frame.
Finally, run the mainloop of the application window.
# Import the libraries from tkinter import * # Create an instance of tkinter frame or window win = Tk() # Title of window win.title("Justify Text inside Textbox") # Dimensions of the window win.geometry("700x250") # Entry widget my_text = Entry(win, width=30, justify=CENTER, bg="green", font=('Times', 20,'bold')) my_text.insert(0, "Hello, How are you doing?") my_text.pack(padx=50, pady=50) # Run the mainloop win.mainloop()
It will produce the following output −
Kickstart Your Career
Get certified by completing the courseGet Started