Checkbuttons demonstration: set font : Font « 2D « Python






Checkbuttons demonstration: set font

Checkbuttons demonstration: set font
from Tkinter import *

class CheckFont( Frame ):
   def __init__( self ):
      Frame.__init__( self )
      self.pack( expand = YES, fill = BOTH )
      self.master.title( "Checkbutton Demo" )   
      
      self.frame1 = Frame( self )
      self.frame1.pack()
      
      self.text = Entry( self.frame1, width = 40,
         font = "Arial 10" )
      self.text.insert( INSERT, "font style" )
      self.text.pack( padx = 5, pady = 5 )

      self.frame2 = Frame( self )
      self.frame2.pack()
      
      # create boolean variable
      self.italicOn = BooleanVar()

      # create "Italic" checkbutton
      self.checkItalic = Checkbutton( self.frame2, 
         text = "Italic", variable = self.italicOn, 
         command = self.changeFont )
      self.checkItalic.pack( side = LEFT, padx = 5, pady = 5 )

   def changeFont( self ):
      desiredFont = "Arial 10"

      if self.italicOn.get():
         desiredFont += " italic"

      self.text.config( font = desiredFont )

def main():
   CheckFont().mainloop()

if __name__ == "__main__":
   main()

           
       








Related examples in the same category

1.Checkbutton to set font to boldCheckbutton to set font to bold
2.Radiobuttons demonstration set Font in TextRadiobuttons demonstration set Font in Text
3.Set Button style: fontSet Button style: font
4.Set font from Root componentSet font from Root component
5.Button font: underline italicButton font: underline italic
6.Label fontLabel font