Newbie question

John E. Garrott johnga at
Sat Jun 19 11:47:10 EDT 1999

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,

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!"

def main():
	root = Tk()
	sp = SelectionBox(root)
	root.minsize(1, 1)


More information about the Python-list mailing list