返回顶部

收藏

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. 2013-06-05 13:21:25python 使用MySQLdb连接mysql by 玉开Sir
  4. 2016-04-23 09:45:22Line width by jack.chen
  5. 2016-02-25 16:20:21Line with pattern by wubai
  6. 2016-09-24 09:03:03Warning bmp on a Label by jack.chen
  7. 2016-11-05 21:19:18Line color by 山药
  8. 2015-12-13 11:28:39Set font from Root component by 风云轩
  9. 2016-01-21 16:07:51Draw circle by 张宋付
  10. 2015-12-07 19:24:39Load bitmap into a Canvas by 山药
  11. 2016-01-29 16:07:13Label font by 阮小七
相关聚客文章
  1. 丸子 发表 2013-11-01 08:02:46 centos下搭建npm镜像
  2. amaozhao@gmail.com ( 发表 2014-12-24 07:21:50 Python 中的进程、线程、协程、同步、异步和回调
  3. tdoly 发表 2015-03-10 11:54:36 django根据User-Agent自动切换手机版和电脑版
  4. 吴遥 发表 2013-10-21 14:50:00 骨折
  5. jack.zh 发表 2015-02-06 22:54:00 Python SocketServer聊天室
  6. 博主 发表 2014-02-27 08:23:39 利用dropbox自动备份网站数据
  7. 博主 发表 2014-08-17 06:19:00 Python基础01 Hello World!
  8. 博主 发表 2013-06-22 07:00:00 使用virtualenv[wrapper]管理python多版本和开发环境
  9. Rex Zhang 发表 2014-11-10 10:35:08 convert python datetime unix timestamp
  10. 奈何col 发表 2015-05-01 05:32:05 quokka-plugins
  11. ashione 发表 2015-04-17 16:06:56 python argumentParser objects
  12. Harrison Feng 发表 2014-06-05 22:00:00 Lists in Python

发表评论