[Python-bugs-list] Tkinter: widget.bind('sequence') incorrect (PR#368)
rozen@rgv.hp.com
rozen@rgv.hp.com
Fri, 23 Jun 2000 15:31:21 -0400 (EDT)
Full_Name: Don Rozenberg
Version: 1.5.2
OS: Linux
Submission from: palwebproxy2.core.hp.com (156.153.255.130)
With Tcl/Tk, bind tag sequence returns the string which is the command.
With Python, widget.bind('sequence') seems to return a reference to the
command not the command.
The following reproduces the problem on my machine. Try running the file
and observe the print output. Pretty strange.
#! /usr/bin/env python
from Tkinter import *
root = Tk()
def init():
pass
def greeting(str):
import Dialog
Dialog.Dialog(title="greetings",
text=str,
bitmap="",default=0,strings=("cont",))
class New_Toplevel_1:
def __init__(self, master=None):
self.ent17 = Entry (master)
self.ent17.place(in_=master,x=45,y=50)
self.ent17.configure(background="plum")
self.ent17.configure(font="helvetica 14 bold")
self.ent17.configure(foreground="black")
self.ent17.configure(insertbackground="black")
self.ent17.configure(selectbackground="black")
self.ent17.configure(selectforeground="ivory")
self.hello = StringVar()
self.ent17.configure(textvariable=self.hello)
self.ent17.configure(width="35")
self.ent17.bind('q',lambda e: greeting('q'))
x = self.ent17.bind()
print 'x =', x
x = self.ent17.bind('q')
print 'x =', x
# I expected x to be "lambda e: greeting('q')"
# I actually got the following
# x = set _tkinter_break [135926416<lambda> %# %b %f %h %k %s %t %w %x %y %A %E
%K %N %W %T %X %Y]
# if {"$_tkinter_break" == "break"} break
def vp_start_gui():
global w
root.title('New_Toplevel_1')
root.geometry('500x200+216+41')
root.configure(bg='wheat')
w = New_Toplevel_1 (root)
root.mainloop()
if __name__ == '__main__':
vp_start_gui()