码迷,mamicode.com
首页 > 其他好文 > 详细

Tkinter学习笔记-1

时间:2014-12-14 00:42:48      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   ar   color   sp   strong   on   div   

Tkinter

python标准GUI包,提供了Tk GUI工具箱的OO接口

每个组件继承自Widget

GUI由包含子组件的顶层组件构成

Frame类作为顶层组件

 

标签

显示文本、图片、提示信息

通过Label类创建

 1 # SimpleLabel.py
 2 # Label demonstration
 3 
 4 from Tkinter import *
 5 
 6 class LabelDemo( Frame ):
 7     """ Demonstrate Labels"""
 8 
 9     def __init__(self):
10         """ Create three Labels and pack them """
11 
12         Frame.__init__( self )  # initialize Frame object
13 
14         # frame files all available space
15         self.pack( expand = YES, fill = BOTH)
16         self.master.title( "Labels" )
17 
18         self.Label1 = Label( self, text = "Label with text" )
19 
20         # resize frame to accommodate Label
21         self.Label1.pack()
22 
23         self.Label2 = Label( self, text = "Labels with text and bitmap" )
24 
25         # insert Label against left side of frame
26         self.Label2.pack( side = LEFT )
27 
28         # using default bitmap image as label
29         self.Label3 = Label( self, bitmap = "warning" )
30         self.Label3.pack( side = LEFT )
31 
32 
33 demo = LabelDemo()
34 
35 demo.mainloop()   # starts event loop

 

Tkinter学习笔记-1

标签:style   blog   io   ar   color   sp   strong   on   div   

原文地址:http://www.cnblogs.com/tmmuyb/p/4162070.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!