1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| import time
import tkinter as tk
import tkinter.font as tkfont
from tkinter.scrolledtext import ScrolledText
root = tk.Tk()
frame = tk.LabelFrame(root, text="Polices")
frame.grid()
ft = tkfont.families()
txt = ScrolledText(frame, width=50, height=20)
txt.grid()
## ascenseur_txt = tk.Scrollbar(root, orient='vertical',
## width=20, command=txt.yview)
## ascenseur_txt.grid(row= 0, column= 1,sticky='ns')
## txt["yscrollcommand"]= ascenseur_txt.set
## deltY=10
txt.insert("1.0", 'Polices:\n')
txt.tag_add("tagpolices", "1.0", "insert")
## liste = ["tagpolices"]
## police={}
for i,f in enumerate(ft):
font = tkfont.Font(frame, size=20, family=f)
tag = f'tag{i}'
txt.tag_config(tag, font=font)
txt.insert("end", f, tag, '\n')
## ancien_tag = liste[::].pop()
## txt.tag_add("tag"+str(i), ancien_tag+".last", "insert")
## liste.append("tag"+str(i))
## txt.tag_config("tag"+str(i), font=police[i])
#txt.update_idletasks()
#time.sleep(1/5)
root.mainloop() |
Partager