pmbarrett314 / curses-menu

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

Cashes after executing CommandItem(...) or FunctionItem(...) #47

Closed AvansRobotics closed 2 years ago

AvansRobotics commented 2 years ago

When I run the exacte example given in the README when I select the menu option with a FunctionItem, it will crash and not execute & return to the menu. this is the error:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/student/.local/lib/python2.7/site-packages/cursesmenu/curses_menu.py", line 133, in _wrap_start
    curses.wrapper(self._main_loop)
  File "/usr/lib/python2.7/curses/wrapper.py", line 43, in wrapper
    return func(stdscr, *args, **kwds)
  File "/home/student/.local/lib/python2.7/site-packages/cursesmenu/curses_menu.py", line 193, in _main_loop
    self.process_user_input()
  File "/home/student/.local/lib/python2.7/site-packages/cursesmenu/curses_menu.py", line 289, in process_user_input
    self.select()
  File "/home/student/.local/lib/python2.7/site-packages/cursesmenu/curses_menu.py", line 328, in select
    self.selected_item.set_up()
  File "/home/student/.local/lib/python2.7/site-packages/cursesmenu/items/external_item.py", line 22, in set_up
    self.menu.pause()
AttributeError: 'NoneType' object has no attribute 'pause'

I'm using Python 2.7.17

my FunctionItem(...) looks like this: function_item_initialize = FunctionItem("Initialize", pub_state_request.publish, [States.INITIALIZE.value])

And this is the function I am trying to call: pub_state_request.publish(2)

Novare commented 2 years ago

You've probably installed the 0.5.0 version using pip. This issue is fixed if you clone the repo, check out the 0.6.0 tag and install that using python setup.py install --user. You might need to install the "deprecated" package using pip before that, but then it should work.

pmbarrett314 commented 2 years ago

This is an old one, I'm closing it because I'm not supporting python2. If it's still a problem, I recommend using python3 and a more recent version of curses-menu.