返回顶部

收藏

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-12-03 09:40:19Button font: underline italic by 山药
  2. 2016-04-23 09:24:00Draw lines by 蟋蟀MM
  3. 2017-04-01 16:33:01Draw Arc by 阿明娃儿
  4. 2013-06-05 13:21:25python 使用MySQLdb连接mysql by 玉开Sir
  5. 2016-04-23 09:45:22Line width by jack.chen
  6. 2016-02-25 16:20:21Line with pattern by wubai
  7. 2016-09-24 09:03:03Warning bmp on a Label by jack.chen
  8. 2016-11-05 21:19:18Line color by 山药
  9. 2015-12-13 11:28:39Set font from Root component by 风云轩
  10. 2016-01-21 16:07:51Draw circle by 张宋付
  11. 2017-03-05 13:53:41Draw Math Curve by jack.chen
相关聚客文章
  1. wklken 发表 2013-08-19 16:00:00 Python-进阶-itertools模块小结
  2. wklken 发表 2014-08-09 16:00:00 Python 源码阅读 - list
  3. adieu 发表 2010-12-16 02:29:12 使用Python导出WordPress数据
  4. 管理员 发表 2014-11-14 06:49:00 用Python解析XMind
  5. admin 发表 2015-04-14 07:39:56 hasattr() getattr() setattr() delattr()
  6. xingzhi 发表 2014-09-18 15:23:55 pyparsing 简介
  7. 博主 发表 2009-06-19 00:18:48 XNA教程-2D游戏-目录索引
  8. Lok 发表 2015-04-13 11:28:50 Python字符串快速反转(str reverse)
  9. 博主 发表 2014-01-12 00:00:00 Python多进程模块Multiprocessing介绍
  10. 博主 发表 2014-06-29 06:16:46 跟python有关的东西
  11. 秋水逸冰 发表 2013-05-29 15:47:29 CentOS 6.4安装Python2.7.5
  12. Kevin Tong 发表 2012-09-16 08:14:55 Adobe HTTP Dynamic Streaming Tutorial

发表评论