1

I have an Entry input_field and I'm trying to create some internal x padding for the Entry so when you input a value the characters aren't so close to the left side of the Entry.

My code:

from tkinter import *

screen = Tk()

input_field = Entry(font=("Calibri", 16, "bold"), width=25,).pack()

screen.mainloop()

My output:

enter image description here

I would like something like this:

enter image description here

I have tried to use ipadx into the .pack() method but simply doesn't change. I've also looked through documentation and found no other replacements to ipadx except padx but this only creates external padding around the Entry.

Is there a way to create internal x padding instead of manually adding in spaces?

  • Does this answer your question? [Python Tkinter Entry pad text](https://stackoverflow.com/questions/51822820/python-tkinter-entry-pad-text) – Tomerikoo Feb 07 '21 at 17:32

1 Answers1

2

You need to use ttk.Entry and configure the Style like this:

import tkinter as tk
import tkinter.ttk as ttk

root = tk.Tk()
style = ttk.Style(root)
style.configure('My.TEntry', padding=(20,0, 0,0))
#padding = (padx left, pady up,padx right,pady down)

widget = ttk.Entry(root, style='My.TEntry')
widget.pack(expand=True, fill='both')

root.mainloop()
Thingamabobs
  • 7,274
  • 5
  • 21
  • 54