tkinter文本显示用户输入 分类: python 小练习 python 2013-06-30 17:17 440人阅读 评论(0) 收藏
2013-06-30 17:17
871 查看
#coding:utf-8
from Tkinter import *
class App:
def __init__(self,root):
#定义帧
frame = Frame(root)
frame.pack()
self.frame = frame
w = Label(frame,text = "calculator")
w.pack()
self.newinput()
#调用回调函数
button1 = Button(frame,text='1',fg="red",command = lambda : self.buttoncb(1))
button1.pack()
button2 = Button(frame,text='2',fg="red",command = lambda : self.buttoncb(2))
button2.pack()
button = Button(frame,text='Quit',fg="red",command = root.quit)
button.pack()
def newinput(self):
v = StringVar()
e = Entry(self.frame,textvariable = v)
self.v = v
e.pack()
#定义回调函数
def buttoncb(self,i):
#print "button"
val = self.v.get()
self.v.set(val+str(i))
root=Tk()
a = App(root)
root.mainloop()
from Tkinter import *
class App:
def __init__(self,root):
#定义帧
frame = Frame(root)
frame.pack()
self.frame = frame
w = Label(frame,text = "calculator")
w.pack()
self.newinput()
#调用回调函数
button1 = Button(frame,text='1',fg="red",command = lambda : self.buttoncb(1))
button1.pack()
button2 = Button(frame,text='2',fg="red",command = lambda : self.buttoncb(2))
button2.pack()
button = Button(frame,text='Quit',fg="red",command = root.quit)
button.pack()
def newinput(self):
v = StringVar()
e = Entry(self.frame,textvariable = v)
self.v = v
e.pack()
#定义回调函数
def buttoncb(self,i):
#print "button"
val = self.v.get()
self.v.set(val+str(i))
root=Tk()
a = App(root)
root.mainloop()
相关文章推荐
- tkinter显示当前时间 分类: python 2013-06-30 17:08 402人阅读 评论(0) 收藏
- tkinter计算字符串的值 分类: python 小练习 python 2013-06-30 17:11 299人阅读 评论(0) 收藏
- 递归调用输出元素 分类: python 小练习 python基础学习 2013-06-30 11:54 278人阅读 评论(0) 收藏
- 用户输入内容长度限制的异常 分类: python异常 2013-06-24 10:48 335人阅读 评论(0) 收藏
- 生成器介绍 分类: python 小练习 python基础学习 divide into python 2013-12-31 21:17 226人阅读 评论(0) 收藏
- #小练习 从多个文件中提取电话号码 分类: python 小练习 正则表达式 2013-05-28 15:40 442人阅读 评论(0) 收藏
- #小练习 pickle模块_分别存储python对象 分类: python Module 2013-09-05 18:07 379人阅读 评论(0) 收藏
- 去除文件中的重复元素后写入文件 分类: python 小练习 open()文件读写 2013-12-03 11:21 356人阅读 评论(0) 收藏
- fileinput模块获取文件的总行数 分类: python 小练习 python Module 2013-12-04 18:19 304人阅读 评论(0) 收藏
- 生成器的应用例子 分类: python 小练习 divide into python python基础学习 2013-12-31 21:32 236人阅读 评论(0) 收藏
- 包导入 分类: python基础学习 python 2013-06-30 11:22 247人阅读 评论(0) 收藏
- 输出文件中不包含指定的多个排除词的行内容(双重遍历) 分类: python 小练习 2013-11-22 15:20 605人阅读 评论(0) 收藏
- #小练习 类与文件对象 分类: python 小练习 2013-11-05 15:39 343人阅读 评论(0) 收藏
- 先执行linux的clear清屏命令,再执行其他操作 分类: python 小练习 2013-09-13 11:23 441人阅读 评论(0) 收藏
- #小练习 异常 分类: python异常 python 小练习 2013-05-14 13:35 452人阅读 评论(0) 收藏
- 使用os.popen/commands.getoutput查询指定端口号的服务 分类: python 小练习 open()文件读写 python基础学习 2013-09-17 17:49 798人阅读 评论(0) 收藏
- 优化程序结构 分类: divide into python python 小练习 2013-12-30 20:53 229人阅读 评论(0) 收藏
- 去除列表中不重复的元素 分类: python 小练习 2013-06-25 14:59 245人阅读 评论(0) 收藏
- 递归函数 分类: python基础学习 python 小练习 2013-12-12 17:51 278人阅读 评论(0) 收藏
- 修改xml中的字段值 分类: xml python 小练习 2014-03-13 12:00 276人阅读 评论(0) 收藏