- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
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
Python Tkinter – Set Entry width 100%
Tkinter Entry widgets accept single-line user input in a text field. We can change the properties of the Entry widget by providing the default attributes and values in its constructor.
Let us suppose that we want to create a full-width Entry widget for an application. There are several ways to do that but if we consider the simplest case where we use Pack Geometry Manager to display the Entry widget, then we can definitely set the width of Entry widget by adding fill(x or y) property.
Example
# Import the required library from tkinter import * from tkinter import ttk # Create an instance of tkinter frame or window win= Tk() # Set the size of the window win.geometry("700x350") # Add bottom widgets in the application label= Label(win, text= "Enter Your Name") label.pack() # Add an entry widget entry= Entry(win) entry.pack(fill='x') win.mainloop()
Output
Executing the above code will display a full-width Entry widget which is expanded to cover the X-axis in the window.
- Related Articles
- How to set the width of a Tkinter Entry widget in pixels?
- How to set focus on Entry widget in Tkinter?
- How to set default text for a Tkinter Entry widget?
- How to set the font size of Entry widget in Tkinter?
- Set the width of an element to 100% in Bootstrap
- Getting screens height and width using Tkinter Python
- How to set the height/width of a Label widget in Tkinter?
- Get contents of a Tkinter Entry widget
- Python Tkinter – How to export data from Entry Fields to a CSV file?
- How to create a multiline entry with Tkinter?
- How to use the Entry widget in Tkinter?
- Getting the Cursor position in Tkinter Entry widget
- How to disable an Entry widget in Tkinter?
- Set style for Labelframe in Python Tkinter
- How to add placeholder to an Entry in tkinter?

Advertisements