Tkinter listbox question

V

vedran_dekovic

Hi,
I need help about Tkinter listbox widget.I want,when somebody click on
any item(file) in Listbox,then in new Label widget text must be
selected item from server.

my program (wrong example):

import ftputil
import Tkinter
root=Tkinter.Tk()
ftp=ftputil.FTPHost('some imaginary server')

def LabelWidget(event):
a=Tkinter.Label(root,text=) # Text must be only name and file
format,example: sun.gif
a.grid()



b=Tkinter.Listbox(root)
b.insert(Tkinter.END,ftp._dir(''))
b.place()
c=Tkinter.Button(root,text='PRINT THIS FILE IN NEW LABEL WIDGET')
c.bind('<Button-1>',LabelWidget)
c.grid()
root.mainloop()


THANKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
H

Hendrik van Rooyen

| Hi,
| I need help about Tkinter listbox widget.I want,when somebody click on
| any item(file) in Listbox,then in new Label widget text must be
| selected item from server.
|
| my program (wrong example):
|
| import ftputil
| import Tkinter
| root=Tkinter.Tk()
| ftp=ftputil.FTPHost('some imaginary server')
|
| def LabelWidget(event):
| a=Tkinter.Label(root,text=) # Text must be only name and file
| format,example: sun.gif
| a.grid()
|
|
|
| b=Tkinter.Listbox(root)
| b.insert(Tkinter.END,ftp._dir(''))
| b.place()
| c=Tkinter.Button(root,text='PRINT THIS FILE IN NEW LABEL WIDGET')
| c.bind('<Button-1>',LabelWidget)
| c.grid()
| root.mainloop()
|
|
| THANKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


idx = b.curselection() # - tells you which one was clicked
StringValue = b.get(idx) # - returns the text

HTH - Hendrik
 
L

lind

I am looking for an old friend, used to work at a path lab in Pretoria,
dabbled in Scientology and rock climbing? I know this is not
friendster.com, but I really have to get into contact with him.
 
L

lind

Yes, and Du Buisson's and a variety of others. Liked spiders and spent
time at the WNNR?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,610
Members
45,254
Latest member
Top Crypto TwitterChannel

Latest Threads

Top