-
-
Save abishur/2482046 to your computer and use it in GitHub Desktop.
Hello,
I'm trying to create sub-menu with 12 entries. First, the result was a strange behavior so I added the code from pablogsal to raise an exception.
Now, I get this error message when I try to get into this sub-menu:
Traceback (most recent call last):
File "./myscript.py", line 174, in <module>
processmenu(menu_data)
File "./myscript.py", line 150, in processmenu
getin = runmenu(menu, parent)
File "./myscript.py", line 131, in runmenu
if x >= ord('1') and x <= ord(str(optioncount+1)):
TypeError: ord() expected a character, but string of length 2 found
I see what the problem is but I can't find any solution.
Anyone could help me with that?
Thanks in advance.
Hello idItknow, look at 3 posts before your post (ebelliveau commented on Dec 5, 2014). It has the solution to your problem.
I'm facing a different problem. My menu's can be larger then 1 screen so it crashes with this error:
_curses.error: addstr() returned ERR
It is because curses tries to draw beyond the boundries of the screen. I'm still searching for a proper solution that also scrolls to the content.
If anyone is interested, I used this in a couple of classes and decided I'd like to take it a bit further, so I made it into a library that abstracts it into a bunch of different classes. This makes it a bit more extendable and flexible, and also easier to use. Check it out on github. Or see the docs here. Or pip install curses-menu. And let me know if you have feedback!
When Launched from a Windows putty it don't draw the borders correctly, it replaces it with x, y
Why is this, and how can I get putty to display the boarders correctly ?
@AppelonD For your PuTTY connection settings, go to Window, then Translation. Change the 'Remote character set' to 'ISO-8859-1:1998 (Latin-1, West Europe)'
I have a similar but simpler cross-platform menu creator class! And it has a unique interactive design!
It lets you go though the alternatives with an arrow using the arrow keys to move up and down!
If you're interested you can check it out here:
https://github.com/SngLol/PythonMenuSetup
what version of python is #!/usr/bin/env python exaclty? im getting error
Traceback (most recent call last):
File "/home/jay/Documents/Scripts/Menus/Python/new_menu.py", line 31, in
import commands
ModuleNotFoundError: No module named 'commands'
works fine on last mint but mint 21 nope!!!
dw i fixed it with this command
pip install virtualenv
If anyone wants something similar to this that abstracts everything to its own class, I took some time to refactor this a bit.
https://gist.github.com/etkirsch/53505478f53aeeac24a5