Tkinter problem

Newt newt_e at blueyonder.co.uk
Tue Oct 1 16:23:57 EDT 2002


Hi,

Can anyone explain why the following code runs strangely. When I run it, it
seems as if the setrace routine is called regardless, even before the main
form has been displayed.

Thanks,
Newt

<Code starts here>

from Tkinter import *
from tkMessageBox import *

root = Tk()

Label(root, text="Character Name").grid(row=1,column=1, sticky=E)
charname = Entry(root)
charname.grid(row=1,column=2)

Label(root, text="Clan Name").grid(row=3,column=1,sticky=E)
clanname = Entry(root)
clanname.grid(row=3,column=2)

lblr = Label(root)
lblr.config(text="a")
lblr.grid(row=0,column=4)
sbarr = Scrollbar(root)
listr = Listbox(root, relief=SUNKEN)
sbarr.config(command=listr.yview)
listr.config(yscrollcommand=sbarr.set, yscroll=YES, height=3)
sbarr.grid(row=1,column=5,sticky=NS)
listr.grid(row=1,column=4)
listr.bind('<Button-1>',setrace(root, listr, lblr ))
races = ('Tsolyani','Ahoggya','Hlaka','N\'Luss','Pachi Lei','Pe
Choi','Shen','Tinaliya')
pos = 0
for race in races:
  listr.insert(pos,race)
  pos = pos + 1

root.mainloop()

def display(self):
  Label(self, text = "Newt's Character Generator").grid(row=0)
  Label(self, text = "Version 0.01 Sept 2002").grid(row=2)

def setrace(parent, listb, textb):
  showinfo('setrace','In settrace')
  ix = listb.curselection()
  item = listb.get(ix)
  textb.config(text=item)





More information about the Python-list mailing list