Python 图形Tkinter Button
来源:互联网 发布:网络主页版式规范 编辑:程序博客网 时间:2024/05/22 02:56
#coding=utf-8'''第一个button 例子'''#command:指定时间处理函数from Tkinter import *#定义Button的时间处理函数def helloButton(): print 'hello Button'root = Tk()#通过 command 属性来指定Button的事件处理函数Button(root, text='点击一次控制台打印一句 hello Button', command=helloButton ).pack()root.mainloop()#coding=utf-8'''Button 的外观效果'''from Tkinter import *root = Tk()#flat, groove, raised, ridge, solid, or sunkenButton(root, text='hello button', relief=FLAT ).pack()Button(root, text='hello button', relief=GROOVE ).pack()Button(root, text='hello button', relief=RAISED ).pack()Button(root, text='hello button', relief=SOLID ).pack()Button(root, text='hello button', relief=SUNKEN ).pack()#root.mainloop()#图像居下,居上,居右,居左,文字位于图像之上#root = Tk()Button(root, text = 'botton', compound = 'bottom', bitmap = 'error' ).pack()Button(root, text = 'top', compound = 'top', bitmap = 'error' ).pack()Button(root, text = 'right', compound = 'right', bitmap = 'error' ).pack()Button(root, text = 'left', compound = 'left', bitmap = 'error').pack()Button(root, text = 'center', compound = 'center', bitmap = 'error' ).pack()#root.mainloop()'''Button 的焦点'''# focus_set:设置当前组件得到焦点#创建三个 Button,各自对应回调函数;# 将第二个 Button 设置焦点,程序运行是按“Enter”,# 判断程序的打印结果def cb1(): print 'button1 clicked'def cb2(event): print 'button2 clicked'def cb3(): print 'button3 clicked'#root = Tk()b1 = Button(root,text = 'Button1',command = cb1)b2 = Button(root,text = 'Button2')b2.bind("<Return>",cb2)b3 = Button(root,text = 'Button3',command = cb3)b1.pack()b2.pack()b3.pack()b2.focus_set()root.mainloop()
阅读全文
0 0
- Python 图形Tkinter Button
- Python 图形编辑 Tkinter Button (二)
- python Tkinter图形用户界面组件(Entry,Button)一
- python Tkinter之Button
- Python Tkinter 图形用户界面
- python中的tkinter button案例
- Python图形用户界面-Tkinter
- Python--Tkinter之 Button()/Checkbutton()/Radiobutton()
- Python tkinter 用例 含button label Entry
- python Tkinter图形用户界面组件(布局管理器) 二
- python Tkinter图形用户界面组件(布局管理器) 三
- python Tkinter图形用户界面组件(鼠标、键盘事件)
- python——Tkinter图形化界面及threading多线程
- Python Tkinter Hello,Tkinter
- Tkinter中的button使用
- Tkinter:Button(1)
- Tkinter:Button(2)
- 小白学tkinter(按钮Button)
- Linux相关的小知识点
- Prime Ring Problem(DFS)
- SpringMVC 拦截器
- c语言和c++中的&修饰符的区别
- css 实现内凹圆角
- Python 图形Tkinter Button
- 使用TouchDelegate扩大View的点击区域
- Shiro入门—授权
- Linux学习笔记:权限管理
- 全栈工程师之路-中级篇之小程序开发-第二章第三节小程序豆瓣评分主页
- Spring+hibernate 配置文件
- 23个MySQL常用查询语句
- Python学习
- C++栈的基本操作和应用