Newbie question - TclError

Bruce Wolk bawolk at ucdavis.edu
Wed May 17 10:45:48 EDT 2000


I'm not sure why the example was written as it is, but it won't run.  Do
the following:

1. Comment out the event.bind(etc...) line.
2.  Change "def evaluate(event):" to def evaluate():"

This will work.  When you have an indirect binding using "command=", the
callback should not have an argument.

Bruce


Simon Brunning wrote:

> I've been looking at the 'Getting started with Python' article at
> sunworld
> (<http://www.sunworld.com/sunworldonline/swol-02-1998/swol-02-python
> _p.html>), and I'm having a problem getting one of the examples
> (calc.py) working. The code is as follows:
>
> from Tkinter import *
> from math import *
>
> def evaluate(event):
>         label['text'] = "Result:  " + str(eval(expression.get()))
>
> frame = Frame(None)
>
> entry = Entry(frame)
> entry['textvariable'] = expression = StringVar()
> entry.bind("", evaluate)
>
> label = Label(frame)
>
> button = Button(frame, text = "Submit", command = evaluate)
>
> frame.pack()
> entry.pack()
> label.pack()
> button.pack()
> frame.mainloop()
>
> I'm getting the error message 'TclError: no events specified in
> binding'. I've had a hunt round the documentation - if there is an
> answer in there, *I* can't find it.
>
> Anyone going to take pity on a frustrated newbie?
>
> --
> Cheers,
> Simon Brunning
> TriSystems Ltd.
> sbrunning at trisystems.co.uk
> The opinions expressed are mine, and are not necessarily those of my
> employer. All comments provided "as is" with no warranties of any
> kind whatsoever.




More information about the Python-list mailing list