Hi
System:         Linux,
Python Version: 3.6.7

I am trying to learn how to bind to a widget, and process the contents of the bound widget

here is my attempt at code:

#! /usr/bin/python3
from tkinter import *
import datetime

def NewAge(start):
    print(start)
    futureAge = start + 5
    calculated.delete(0,END)
    calculated.insert(0,futureAge)


master=Tk()
Label(master, text='present age').grid(row=0, column=0)
Label(master, text='age in 5 years').grid(row=1, column=0)
first=Entry(master)
first.grid(row=0, column=1)
calculated = Entry(master)
calculated.grid(row=1, column=1)
first.bind("<Return>", NewAge(first.get()))

Button(master, text='exit', command=master.destroy).grid(row=3, column=0)

master.mainloop()

I get the following traceback:

Traceback (most recent call last):
  File "./bind.py", line 19, in <module>
    first.bind("<Return>", NewAge(first.get()))
  File "./bind.py", line 7, in NewAge
    futureAge = start + 5
TypeError: must be str, not int

All hints & help greatly appreciated.


regards,
Chris Roy-Smith

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to