首页 > 代码库 > Tkinter学习笔记-1
Tkinter学习笔记-1
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 object13 14 # frame files all available space15 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 Label21 self.Label1.pack()22 23 self.Label2 = Label( self, text = "Labels with text and bitmap" )24 25 # insert Label against left side of frame26 self.Label2.pack( side = LEFT )27 28 # using default bitmap image as label29 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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。