Python 2.3.2 / Tkinter Problem

Gary Richardson garyr at fidalgo.net
Wed Oct 29 22:11:30 EST 2003


I've just switched to Python 2.3.2 and have encountered a problem that
causes a program to crash. The program was working with Python 2.2. The code
below will illustrate the problem. A listbox is created and the mouse
wheel is used to scroll the entries. The program crashes as soon as the
mouse wheel is moved. The program appears to work OK otherwise. The problem
occurs when the program is run within the IDE or from a DOS prompt. I'm
using ActivePython 2.3.2 on Win98SE. Any suggestions?

Thanks,
Gary Richardson
----------------------------------------------------------------------
from Tkinter import *

class MakeListBox:
    def __init__(self, parent ):
        self.lst = Listbox(parent, width=12, bg='lightblue')
        self.lst.pack(side=LEFT, anchor=N, expand=NO)
        self.lst.bind('<ButtonPress-1>', self._onMouseButton)
        self.scroll = Scrollbar(parent, command=self.lst.yview)
        self.lst.configure(yscrollcommand=self.scroll.set)
        self.scroll.pack(side=LEFT, fill=Y)
        parent.bind('<MouseWheel>', self._onMouseWheel)
        for k in range(30):
            self.lst.insert(END, str(k))

    def _onMouseButton(self, event):
        print self.lst.nearest(event.y)

    def _onMouseWheel(self, event):
        print event

root = Tk()
MakeListBox(root )
root.mainloop()














More information about the Python-list mailing list