简体   繁体   中英

How to make Entries with the same size but different fonts in Tkinter?

I need to make two identical Entries in a same row, but each Entry's text have a different font . I tried setting a fixed width to both entries, but the Font modifies it. Is there any way to set a fixed size to an Entry regardless its size?

Don't set the Entry size, set the size of whatever container they are in. As you say "row" I assume you are using a grid layout. This would be a good place to use the completely undocumented "uniform" argument.

frame.columnconfigure([0,1], uniform='entrycol') # set columns 0 and 1 to the same width

ent = tk.Entry(frame, width=2) # set the width small to start
ent.grid(row=0, column=0, sticky='ew') # set the entry to stick to the east and west

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM