返回顶部

收藏

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()

标签:Python,2D

收藏

0人收藏

支持

0

反对

0

»更多 您可能感兴趣的代码
  1. 2015-02-23 09:40:23ubuntu安装python3的python-pip by 甄码农
  2. 2015-12-18 09:09:05Arc with start degree and end degree by 司马
  3. 2016-01-24 21:02:43Draw oval using Python by 阮小七
  4. 2016-03-03 15:22:47Draw a line by 阿明娃儿
  5. 2016-03-20 20:06:28Draw gif image by 张宋付
  6. 2016-10-15 12:07:09Rectangle Border width by 蟋蟀MM
  7. 2013-06-04 13:43:27web.py中自定义jinja2模块 by 赵小全
  8. 2016-01-05 21:28:22Draw oval by 山药
  9. 2016-01-17 16:15:39Draw polygon by 风云轩
  10. 2016-11-14 10:27:46Radiobuttons demonstration set Font in Text by 张宋付
  11. 2016-04-23 09:05:45Checkbutton to set font to bold by 风云轩

发表评论