On Wed, Nov 19, 2008 at 4:57 AM, Eric Brunel <[EMAIL PROTECTED]> wrote:

> Hello all,
>
> I'm trying out Python 2.6 and I found what might be a bug in the Tkinter
> module. How can I report it?
>
> The possible bug is a traceback when trying to delete a menu item in a menu
> where no items have associated commands.
>
> For example:
> ------------------------------
> from Tkinter import *
>
> root = Tk()
>
> mb = Menu(root)
> root.configure(menu=mb)
>
> fm = Menu(mb)
> mb.add_cascade(label='File', menu=fm)
>
> fm.add_command(label='Open')
> fm.add_command(label='Quit')
>
> def remove_menu_item():
>  fm.delete(1)
>
> Button(root, text='Remove menu item',
> command=remove_menu_item).pack(padx=12, pady=24)
>
> root.mainloop()
> ------------------------------
>
> Clicking on the button should remove the 'Open' item in the 'File' menu,
> but ends up in a traceback:
>  File "/opt/Python2.6+Tk8.5/bin/Linux/lib/python2.6/lib-tk/Tkinter.py",
> line 1410, in __call__
>    return self.func(*args)
>  File "menu.py", line 15, in remove_menu_item
>    fm.delete(1)
>  File "/opt/Python2.6+Tk8.5/bin/Linux/lib/python2.6/lib-tk/Tkinter.py",
> line 2670, in delete
>    if c in self._tclCommands:
>
> It just seems the _tclCommands attribute on menus is initialized to None
> and never changed if none of the items actually have a command.
>
> Thanks!
> --
> python -c "print ''.join([chr(154 - ord(c)) for c in
> 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"
> --
> http://mail.python.org/mailman/listinfo/python-list
>


I can confirm this behavior in 2.6: Full traceback (as Eric's is missing the
last line)

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/lib-tk/Tkinter.py", line 1410, in __call__
    return self.func(*args)
  File "<stdin>", line 2, in remove_menu_item
  File "/usr/local/lib/python2.6/lib-tk/Tkinter.py", line 2670, in delete
    if c in self._tclCommands:
TypeError: argument of type 'NoneType' is not iterable


The example code works "as expected" under 2.5.

I don't know enough about Tkinter to know whether or not this is actually a
bug, or intended behavior, but it certainly strikes me as being a bug.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to