[Pythonmac-SIG] Question about Tkinter listbox

Laurent Pierron Laurent.Pierron@loria.fr
Thu, 31 May 2001 09:51:58 +0200


Hi,

Debugging Python/Tk programs on Mac is not as cool as on Unix and
Windows, because when you are running Tk you cannot use Python Console,
and the best thing to debug Tk programs is to have a console. 

So, if you want a double click on the mouse button, replace the line :
	namelist.bind('<Double-1>',sendname)
by
	namelist.bind('<Double-Button-1>',sendname)
and try again.

If you develop this application for the Mac, it's better to use the Mac
W widget library. You can use and test the library in Mac Python IDE,
see an example below.

You can find the documentation at :
http://www.nevada.edu/~cwebster/Python/WWidgets/

Good luck
--
Laurent Pierron

Josh English a écrit :
> 
> I am new to python and I am using MacPython 2.1 and Tk 8.9 on Mac OS
> 9.0. I am having difficulty figuring out how to get the selected item in
> a listbox into an entry data field. I have tried the following code
> after lots of failed experiments:
>
> etc...

--------------------------------------
The same application with Mac W widget
You can test it directly in Mac Python IDE, Great !!!
--------------------------------------
import W

names = ['Josh','Steph']

def sendname(point,mod):
    "TODO : check value of mod to know if it was a double click"
    index = root.namelist.getselection()   
    print index                       
    label = root.namelist.getselectedobjects()    
    print label
    return 1                    

root = W.Window((600, 400), "Hello!", minsize = (240, 200))
root.namelist = W.Listbox((20,20,100,300),names)
root.namelist.bind('<click>',sendname)

root.nameentry = W.EditText((20,140,100,20))

root.open()