pmbarrett314 / curses-menu

A simple console menu system in python using the curses library
MIT License
471 stars 55 forks source link

Type Error in curses_menu.py #58

Closed sjohnson-FLL closed 1 year ago

sjohnson-FLL commented 1 year ago

Version

Other (include below)

Operating System

Windows

Environment

Running from VSCode External Terminal

What happened?

After setting up my menu with function items only, things worked as-expected. However, after adding submenu items as well, I get the exception below. The line of my code immediately before getting the exception is main_menu.show().

Exception in thread Thread-20 (_wrap_start):
Traceback (most recent call last):
  File "my_path\Python311\Lib\threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "my_path\Python311\Lib\threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "my_path\Python311\Lib\site-packages\cursesmenu\curses_menu.py", line 272, in _wrap_start
    self._main_loop()
  File "my_path\Python311\Lib\site-packages\cursesmenu\curses_menu.py", line 295, in _main_loop
    self.draw()
  File "my_path\Python311\Lib\site-packages\cursesmenu\curses_menu.py", line 320, in draw
    self.draw_item(index, item)
  File "my_path\Python311\Lib\site-packages\cursesmenu\curses_menu.py", line 359, in draw_item
    item.show(index_text),
    ^^^^^^^^^^^^^^^^^^^^^
TypeError: CursesMenu.show() takes 1 positional argument but 2 were given
Press any key to continue . . .

Nothing in the backtrace references any of my code, which was surprising. Is this most likely a problem with what I am doing, or is something else going on?

Let me know if any other details would be helpful. Thanks!

Python 3.11.1 curses-menu 0.7.1

sjohnson-FLL commented 1 year ago

Discovered the cause of this: I failed to convert my CursesMenu to a SubmenuItem before appending it to the main menu.

Closing this issue, but if there's an opportunity to add type checking for this sort of thing in the future, I think that would be super helpful. I doubt I am the first one to make this mistake.

Nice module by the way, super useful!