The font in the text field does not change. Show what to do. Here is the code:

from tkinter import* def allrezum(): win = Toplevel(root,relief=SUNKEN,bd=10,bg="lightblue") win.title("Π”ΠΎΡ‡Π΅Ρ€Π½Π΅Π΅ ΠΎΠΊΠ½ΠΎ") win.minsize(width=400,height=200) def obnov(): tex.configure(font="Verdana"+a[sca1.get()]) root = Tk() m = Menu(root) root.config(menu=m) fm = Menu(m) m.add_cascade(label="РСзюмС",menu=fm) fm.add_command(label="ВсС Ρ€Π΅Π·ΡŽΠΌΠ΅", command = allrezum) lab1 = Label(root, text="НовоС РСзюмС", font="Arial 22") lab2 = Label(root, text="Имя", font="Arial 18") ent1 = Entry(root,width=20,bd=3) lab3 = Label(root, text="Ѐамилия", font="Arial 18") ent2 = Entry(root,width=20,bd=3) lab4 = Label(root, text="Π“ΠΎΡ€ΠΎΠ΄", font="Arial 18") lab5 = Label(root, text="Π‘Ρ‚Ρ€Π°Π½Π°", font="Arial 18") lab6 = Label(root, text="ВСхнологичСский Π‘Ρ‚Π΅ΠΊ", font="Arial 18") lab7 = Label(root, text="Π”ΠΎΠ»ΠΆΠ½ΠΎΡΡ‚ΡŒ", font="Arial 18") ent3 = Entry(root,width=20,bd=3) lab8 = Label(root, text="Π£Ρ€ΠΎΠ²Π΅Π½ΡŒ Английского", font="Arial 18") lab9 = Label(root, text="ΠšΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠΈ", font="Arial 18") frame2=Frame(root,bg='red',bd=5) sca1 = Scale(root,orient=HORIZONTAL,length=200, from_=10,to=22,tickinterval=2,resolution=2) a=[0,1,2,3,4,5,6,7,8,9,'10',11,'12',13,'14',15,'16',17,'18',19,'20',21,'22'] sca1.bind("ButtonRelease",obnov) tex = Text(frame2,width=20,height=5, font="Verdana"+a[sca1.get()], wrap=WORD) scr = Scrollbar(frame2,command=tex.yview,) tex.configure(yscrollcommand=scr.set) sca1 = Scale(root,orient=HORIZONTAL,length=300, from_=0,to=100,tickinterval=10,resolution=5) lab1.grid(row=0, column=1) lab2.grid(row=1, column=0) ent1.grid(row=1, column=1) lab3.grid(row=2, column=0) ent2.grid(row=2, column=1) lab4.grid(row=1, column=2) lab5.grid(row=2, column=2) lab6.grid(row=4, column=0) lab7.grid(row=4, column=2) lab8.grid(row=5, column=0) lab9.grid(row=4, column=2) sca1.grid(row=6, column=1) frame2.grid(row=5, column=1) scr.pack(side='right', fill='y') tex.pack(fill='both') root.mainloop() 

    1 answer 1

    Slightly changed the code:

     def obnov(event): tex.configure(font="Verdana "+str(8 + sca1.get()//5)) # Π Π°Π·ΠΌΠ΅Ρ€ ΡˆΡ€ΠΈΡ„Ρ‚Π° ΠΎΡ‚ 8, ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΠ΅ Ρ€Π°Π·ΠΌΠ΅Ρ€Π° ΡˆΡ€ΠΈΡ„Ρ‚Π° Π½Π° 1 ΠΏΡ‚ Π½Π° ΠΊΠ°ΠΆΠ΄Ρ‹Π΅ 5 Π΅Π΄ΠΈΠ½ΠΈΡ† ... tex = Text(frame2,width=20,height=5, font="Verdana "+str(8 + sca1.get()//5), wrap=WORD) ... sca1 = Scale(root,orient=HORIZONTAL,length=300, from_=0,to=100,tickinterval=10,resolution=5, command=obnov) # функция Ρ€Π΅Π°ΠΊΡ†ΠΈΠΈ Π½Π° ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Ρ‰Π΅Π½ΠΈΠ΅ прописана здСсь ... # sca1.bind("ButtonRelease", obnov) # Π£Π±Ρ€Π°Π» 

    Interestingly, the font size affects the size of the text field (apparently, because the size of the text field is specified in characters) and the size of the window, which is not very convenient.

    To prevent this from happening, it is better to set the size not for the text field, but for the frame in which the text field and the scroll bar lie, and disable the automatic resizing of the frame:

     frame2=Frame(root,bg='red',bd=5, width=300, height=200) # ΠŸΡ€ΠΎΠΏΠΈΡΠ°Π» Ρ€Π°Π·ΠΌΠ΅Ρ€Ρ‹ Ρ„Ρ€Π΅ΠΉΠΌΠ° (Π² пиксСлях) frame2.pack_propagate(False) ... tex = Text(frame2, # Π£Π±Ρ€Π°Π» Ρ€Π°Π·ΠΌΠ΅Ρ€Ρ‹ font="Verdana "+str(8 + sca1.get()//5), wrap=WORD) 

    If the elements in the frame were placed using the grid , you would use frame2.grid_propagate(False) .