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
| import time
import tkinter as tk
import tkinter.font as tkfont
root = tk.Tk()
frame = tk.LabelFrame(root, text="Polices")
frame.grid()
ft = tkfont.families()
txt = tk.Text(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):
police[i] = tkfont.Font(frame, size=20, family=f)
txt.insert("end", f+"\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