Tkinter GUI entry displaying two different font sizes

74 views Asked by At

I'm working on my first python Tkinter GUI and am getting along quite well. I'm now trying to create an entry with default text displayed with two font sizes.

I've managed to get the default text in the entry and even seperate the two parts with two times insert. I however haven't managed to get one in the originally defined font (defined by Entry) and one seperately defined.

In the MWE below I'm hoping to keep the 'big' text in the original font size and the 'small' text in a smaller font size.

# import all functions from the tkinter
from tkinter import *
  
# Create a GUI window  
window = Tk()
  
# Create a entry  box   
# for filling or typing the information.
entry = Entry(
    window, 
    fg="black", 
    font=("yu gothic ui semibold", 10), 
    highlightthickness=0, 
    justify=CENTER)

entry.insert(0, 'Big ')
entry.insert(END, "Small")

entry.place(relx=0.2, rely=0.5, width=100, height=30)
entry.config(highlightbackground="white", highlightcolor="white", bd=0)

  
# start the GUI
window.mainloop()

I know that for the tkinter Text the tag_add is able to do a similar thing. Any ideas if this an be done to an Entry box?

0

There are 0 answers