Advertisement
here2share

# font_ChkBtn_demo.py

Jun 18th, 2015
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. # font_ChkBtn_demo.py
  2.  
  3. from Tkinter import *
  4.  
  5. itSw=['',' italic']
  6. bbSw=['',' bold']
  7. family,ffSz='Arial',' 10'
  8.  
  9. print family+ffSz+itSw[0]+bbSw[0]
  10.  
  11. root=Tk()
  12. frame1=Frame()
  13. frame1.pack()
  14.  
  15. text=Entry(frame1, width=40,font="Arial 10")
  16. text.insert(INSERT, "sample area")
  17. text.pack(padx=5, pady=5)
  18.  
  19. frame2=Frame()
  20. frame2.pack()
  21.  
  22. def setText():
  23.     text.config(font=family+ffSz+itSw[0]+bbSw[0])
  24.  
  25. def italicSw():
  26.     global itSw
  27.     itSw=(itSw[1],itSw[0])
  28.     setText()
  29.  
  30. def boldSw():
  31.     global bbSw
  32.     bbSw=(bbSw[1],bbSw[0])
  33.     setText()
  34.  
  35. checkBold=Checkbutton(frame2, text="Bold", command=boldSw)
  36. checkBold.pack(side=LEFT, padx=5, pady=5)
  37.  
  38. checkItalic=Checkbutton(frame2, text="Italic", command=italicSw)
  39. checkItalic.pack(side=LEFT, padx=5, pady=5)
  40.  
  41. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement