zoukankan      html  css  js  c++  java
  • tkinter文本显示用户输入 分类: python 小练习 python 2013-06-30 17:17 440人阅读 评论(0) 收藏

    #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()

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    web框架和Django框架的初识
    外键的变种,单表的查询,多表的查询
    数据库的安装与初识
    响应式设计中几个class区别
    Velocity+Java较全教程
    Web开发基础
    AutoCompleteTextView不能使用的问题
    Http中Cookie与Set-Cookie头
    Java Web 乱码
    Karel运行环境配置
  • 原文地址:https://www.cnblogs.com/think1988/p/4628138.html
Copyright © 2011-2022 走看看