On Jun 22, 7:21 pm, Anthony Papillion <papill...@gmail.com> wrote: > I've also removed the (event) parameter just in case and tried it and > it makes no difference. What am I doing wrong here?
Well don't remove the event parameter because Tkinter will pass it every time since this is an EVENT! Here is some code to play with. Note: If using Python 3.x use lowercase Tkinter! #-- Start Code --# import Tkinter as tk from Tkconstants import * class MyListbox(tk.Listbox): def __init__(self, master, **kw): tk.Listbox.__init__(self, master, **kw) self.bind("<Double-Button-1>", self.onButtonOneDoubleClick) self.bind("<Button-3>", self.onButtonThreeClick) def onButtonOneDoubleClick(self, event): lineno = self.nearest(event.y) print 'User double clicked line: %s' %(lineno) def onButtonThreeClick(self, event): lineno = self.nearest(event.y) self.activate(lineno) # # You make this next comand a bit smarter # and only clear the selection when user # clicks on a line this is not already selected # (well in multi line mode anyway), but i cannot # do all the work! ;) self.selection_clear(0, END) self.selection_set(lineno) print 'User right clicked line: %s' %(lineno) if __name__ == '__main__': app = tk.Tk() listbox = MyListbox(app, width=10, height=10, bg='white', selectmode=EXTENDED) for x in range(100): listbox.insert(END, x) listbox.pack(fill=BOTH, expand=1) app.mainloop() #-- End Code --# -- http://mail.python.org/mailman/listinfo/python-list