here2share

# Tk_viewfonts.py

Oct 27th, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. # Tk_viewfonts.py
  2.  
  3. from Tkinter import *
  4. import tkFont
  5.  
  6. root = Tk()
  7.  
  8. yscrollbar = Scrollbar(root)
  9. yscrollbar.pack(side=RIGHT, fill=Y)
  10.  
  11. fonts=list(tkFont.families())
  12. fonts.sort()
  13.  
  14. c = Canvas(root, bg='black')
  15. c.pack(expand=1, fill=BOTH)
  16.  
  17. ta = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  18. tb = 'abcdefghijklmnopqrstuvwxyz'
  19. tc = '''0123456789!"#$%&'()*+'''
  20. td = ''',-./:;<=>?@[\]^_`{|}~'''
  21.  
  22. default_font = tkFont.Font(font='TkDefaultFont').configure()
  23. # {'family': 'Segoe UI', 'weight': 'normal', 'slant': 'roman', 'overstrike': 0, 'underline': 0, 'size': 9}
  24.  
  25. def new_line(i):
  26.     if i != len(fonts):
  27.         thefont=fonts[i]
  28.         ht=((i)*300)+20
  29.         c.create_text(20,ht, text=thefont, font=default_font, fill='white', anchor='w')
  30.         for ii,s in enumerate([ta,tb,tc,td,'','']):
  31.             tt = (thefont,40)
  32.             c.create_text(20,ht+((ii+1)*50), text=s, font=tt, fill='white', anchor='w')
  33.         new_line(i+1)
  34. new_line(0)
  35. c.config(scrollregion=c.bbox(ALL))
  36. c.config(yscrollcommand=yscrollbar.set)
  37. yscrollbar.config(command=c.yview)
  38. root.geometry('1280x680+0+0')
  39. root.mainloop()
Add Comment
Please, Sign In to add comment