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

thinter笔记

时间:2016-03-05 16:04:42      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:

from tkinter import *
root = Tk()          父实例
w = Label(root,text="hello")  
w.pack()
root.mainloop()

技术分享

from tkinter import *
widget = Label(None,text=hello)   会自动创建TK对象
widget.pack(expand=YES,fill=BOTH)   内容会随着移动,允许标签随着父主件扩展fill=BOTH(水平、垂直),fill=Y(垂直),fill=X(水平)
widget.mainloop()

技术分享

像字典一样进行显示内容

from tkinter import *
widget = Label()
widget[text]="hello world"
widget.pack(side=TOP)   内容显示在窗口的上面
widget.mainloop()

技术分享

form tkinter import *
root = Tk()
widget = Label(root)
widget.config(text="hello !我是配置信息")
widget.pack(side=LEFT,expand=YES,fill=BOTH)
root.title(我是标题)
root.mainloop()

技术分享

添加按钮

from tkinter import *
import sys
root = Tk()
Button(root,text="press",command=sys.exit).pack(side=LEFT)root.mainloop()

技术分享

 

thinter笔记

标签:

原文地址:http://www.cnblogs.com/zhuweiblog/p/5244792.html

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