Im back...
Sam Garson
peanut.sam at googlemail.com
Thu Jan 3 23:17:39 EST 2008
Hi there same project I am afraid...
I want to put the text from the selection of a listbox into a Label when the
the selection is clicked.
I have it so it is put in, but it is put in when I click on the
*next*selection...as in it defines the variable when I click on the
desired the
selection, but it puts it into the label when i click on the *next* item.
It is best if you have a look. Here is the whole program
[start python code; possibly wrapped by browser]
#!/user/bin/python
from Tkinter import *
def insert():
name = ent.get()
box.insert(0, name)
ent.delete(0, END)
def DeleteCurrent(event):
box.delete(ANCHOR)
def putLabel(event):
selection = box.get(ANCHOR)
v.set(str(selection))
root = Tk()
ent = Entry(root, fg = '#3a3a3a', bg = 'white', relief = 'groove')
ent.grid(row = 0, padx = 3, pady = 3)
button = Button(root, text = "Remember", command = insert, relief =
'groove', fg = '#3a3a3a')
button.grid(row = 0, column = 1, padx = 3, pady = 3)
box = Listbox(root, bg = '#ebe9ed', relief = 'groove', height = 15)
box.selectmode = BROWSE
box.grid(row = 2, columnspan = 2, sticky = W+E, padx = 3)
box.bind("<Double-Button-1>", DeleteCurrent)
box.bind("<Button-1>", putLabel)
v = StringVar()
current = Label(root, textvariable = v)
current.grid(row = 3, columnspan = 2, sticky = W+E, padx = 3)
root.mainloop()
[end python code]
how do i make it so it puts it into the variable *when* i click it? Any help
will be greatly appreciated!
Thanks,
Sam
--
I intend to live forever - so far, so good.
SaM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080104/685922bb/attachment.html>
More information about the Python-list
mailing list