Radiobuttons demonstration set Font in Text : Font : 2D PYTHON examples


PYTHON examples » 2D » Font »

 

Radiobuttons demonstration set Font in Text


Radiobuttons demonstration set Font in Text

from Tkinter import *

class RadioFontFrame ):
   def __init__self ):
      Frame.__init__self )
      self.packexpand = YES, fill = BOTH )
      self.master.title"Radiobutton Demo" 

      self.frame1 = Frameself )
      self.frame1.pack()
      
      self.text = Entryself.frame1, width = 40, font = "Arial 10" )
      self.text.insertINSERT, "Font Font Font" )
      self.text.packpadx = 5, pady = )

      self.frame2 = Frameself )
      self.frame2.pack()
      
      fontSelections = "Plain""Bold""Italic""Bold/Italic" ]
      self.chosenFont = StringVar()

      self.chosenFont.setfontSelections] ) 

      for style in fontSelections:
         aButton = Radiobuttonself.frame2, text = style,
            variable = self.chosenFont, value = style,
            command = self.changeFont )
         aButton.packside = LEFT, padx = 5, pady = )

   def changeFontself ):
      desiredFont = "Arial 10"

      if self.chosenFont.get() == "Bold":
         desiredFont += " bold"
      elif self.chosenFont.get() == "Italic":
         desiredFont += " italic"
      elif self.chosenFont.get() == "Bold/Italic":
         desiredFont += " bold italic"

      self.text.configfont = desiredFont )

def main():
   RadioFont().mainloop()

if __name__ == "__main__":
   main()


           
       



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo 2D
» Font