Newbie question
Hans Nowak
ivnowa at hvision.nl
Sat Jun 19 15:30:11 EDT 1999
On 19 Jun 99, John E. Garrott wrote:
> I am have a problem with the program below.
> The intent is, eventually, to get a list and display it,
> in a list box, then print the selected row
> from the listbox, but I can't get the callback
> to work.
>
> The function dbs.databases() works, putting,
> in this case, the databases owned by myself
> into the listbox. When I click on the listbox
> items they highlight as expected, but, apparently,
> list_cb() is never called.
>
> I've read all the available literature on
> binding and signals, tried numerous variations
> on what is here. No results. This program
> shows no errors, so is syntactically(sp?)
> correct. Just doesn't work.
>
> What am I doing wrong?
>
> Thanks in advance,
>
> John
> --------------------------------------------------------
> import dbs
> import string
> from Tkinter import *
>
> class SelectionBox:
>
> def __init__(self, master=None):
> self.frame = Frame(master, name="frame")
> self.frame.pack(expand=1, fill=BOTH)
>
> self.frame.listbox = Listbox(self.frame, name='listbox')
> self.frame.listbox.pack(expand=1, fill=BOTH)
> self.frame.listbox.bind('Button-1', self.list_cb)
>
> for item in dbs.databases():
> self.frame.listbox.insert(END, item)
>
> def list_cb(event):
> print "Here we are!"
I don't know for sure, but shouldn't this be
def list_cb(self, event):
?
I don't know if that's the solution for your problem, though... It's
not like *I* know much about Tkinter. :o)
Veel liefs,
--Hans Nowak (ivnowa at hvision.nl)
Homepage: http://fly.to/zephyrfalcon
More information about the Python-list
mailing list