返回顶部

收藏

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. 2016-04-23 09:05:45Checkbutton to set font to bold by 风云轩
  2. 2015-12-03 09:40:19Button font: underline italic by 山药
  3. 2016-04-23 09:24:00Draw lines by 蟋蟀MM
  4. 2017-04-01 16:33:01Draw Arc by 阿明娃儿
  5. 2013-06-05 13:21:25python 使用MySQLdb连接mysql by 玉开Sir
  6. 2016-04-23 09:45:22Line width by jack.chen
  7. 2016-02-25 16:20:21Line with pattern by wubai
  8. 2016-09-24 09:03:03Warning bmp on a Label by jack.chen
  9. 2016-11-05 21:19:18Line color by 山药
  10. 2015-12-13 11:28:39Set font from Root component by 风云轩
  11. 2018-03-30 21:56:50java自动识别用户上传的文本文件编码 by Hugh

发表评论