返回顶部

收藏

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-02-25 16:20:21Line with pattern by wubai
  2. 2016-09-24 09:03:03Warning bmp on a Label by jack.chen
  3. 2016-11-05 21:19:18Line color by 山药
  4. 2017-03-05 13:53:41Draw Math Curve by jack.chen
  5. 2015-12-13 11:28:39Set font from Root component by 风云轩
  6. 2016-01-21 16:07:51Draw circle by 张宋付
  7. 2017-03-05 14:15:26Set Button style: font by 风云轩
  8. 2015-12-07 19:24:39Load bitmap into a Canvas by 山药
  9. 2016-01-29 16:07:13Label font by 阮小七
  10. 2016-11-08 09:02:07Draw Rectangle by 阮小七
  11. 2016-10-29 09:05:11Draw rectangle with filled color by jack.chen
相关聚客文章
  1. 博主 发表 2014-08-25 00:00:00 python重命名101 ObjectCategories下图像并移到上一级目录
  2. 博主 发表 2015-05-30 19:08:45 python-map(), reduce(),filter()
  3. 博主 发表 2015-04-02 03:58:28 SUPERVISOR进程管理器配置指南
  4. guanqipan 发表 2014-10-11 06:43:15 DevOp Service in DSP@sina
  5. 妙音 发表 2015-06-06 08:37:00 python动态加载是否影响性能
  6. annhe 发表 2015-06-13 15:02:41 CentOS 6.5安装Python3
  7. akun 发表 2015-06-17 16:09:49 Python 中的 namespace
  8. IT辰逸 发表 2015-06-30 08:00:14 Django Ajax 跨域请求
  9. 博主 发表 2015-07-03 08:52:12 每个Python程序员都要知道的日志实践
  10. zrong 发表 2015-07-07 01:10:12 Python2/3 在Windows 下的共存
  11. 博主 发表 2015-07-12 08:02:46 Python中计算一个整形的位数
  12. exoticknight 发表 2015-07-01 15:16:30 记一次奇怪的爬虫经历

发表评论