button binding isn't triggering event like it's supposed to
mridula
mridula.ccpl at gmail.com
Wed Oct 10 02:13:51 EDT 2007
hi.
i am trying to learn event binding. i have a form with a couple of buttons
for different tags, which all call the same function. the text on the
buttons changes from record to record. this is the problem area:
def showrecords(self):
"""this function updates the form labels to show the current
record"""
global gmax
global gctr
global CurrTitle
global CurrAuthor
global CurrTag1
global CurrTag2
global CurrTag3
global CurrTag4
global CurrTag5
global CurrAbstract
global CurrLocation
global CurrID
global HuntFor
self.Lbn.config(text=gmax)
self.Lbnof.config(text=gctr+1)
self.LbTitle.config(text=CurrTitle, justify=LEFT)
self.LbName.config(text=CurrAuthor)
self.LbPath.config(text=CurrLocation)
self.BtTag1.bind('<Button-1>',self.calltotags(tag=CurrTag1))
self.BtTag1.config(text=CurrTag1)
self.BtTag2.bind('<Button-1>',self.calltotags(tag=CurrTag2))
self.BtTag2.config(text=CurrTag2)
self.BtTag3.bind('<Button-1>',self.calltotags(tag=CurrTag3))
self.BtTag3.config(text=CurrTag3)
self.BtTag4.bind('<Button-1>',self.calltotags(tag=CurrTag4))
self.BtTag4.config(text=CurrTag4)
self.BtTag5.bind('<Button-1>',self.calltotags(tag=CurrTag5))
self.BtTag5.config(text=CurrTag5)
self.LbAbs.config(text=CurrAbstract)
def calltotags(event, tag):
# This function sets the search variable HuntFor value, and calls
the tagwork class.
global HuntFor
global toggle
HuntFor=tag
toggle="Tagcluster"
print HuntFor
tagwork()
when i click on the buttons, none of them call the function. i only see the
huntfor value in the prompt when i load the program. can someone please
enlighten me as to why this happens? (the buttons are loaded on the root
window in an earlier function, and i have the same problem even if i try
binding the events there)
also, can someone suggest a good (and free!) code editor for python please?
thanks in advance.
mridula.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20071010/7cf6e85e/attachment.html>
More information about the Python-list
mailing list