Help with buttons and entry fields

Steve Holden sholden at
Tue Sep 5 20:13:01 CEST 2000

Assuming you are still using Tkinter, the code below should elucidate.
The button's callback uses the special insert position END to append
something tpo the entry's current value.



Dudek7 wrote:
> Heres a newbie question.  I have a button and an entry field. Does anyone
> know how to get the entry field to display the number "1" whenever i press
> the button?
> Like if i press button 5 times there are 5 ones?
> Please help me.
> thanks

from Tkinter import *

class createStuff:

    def __init__(self, window=None):
        self.button = Button(window, text="Click Me", command=self.addaone)
        self.entry = Entry(window)

    def addaone(self):
        self.entry.insert(END, "1")

def close(self):

if __name__ == "__main__":
    root = Tk()
    win = createStuff(root)

Helping people meet their information needs with training and technology.
703 967 0887      sholden at

More information about the Python-list mailing list