aegirhall / console-menu

A simple Python menu system for building terminal user interfaces.
MIT License
370 stars 58 forks source link

The example not works in python 2 #30

Open lucasrc opened 5 years ago

lucasrc commented 5 years ago

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 "/usr/local/lib/python2.7/dist-packages/consolemenu/console_menu.py", line 169, in _wrap_start self._main_loop() File "/usr/local/lib/python2.7/dist-packages/consolemenu/console_menu.py", line 225, in _main_loop self.draw() File "/usr/local/lib/python2.7/dist-packages/consolemenu/console_menu.py", line 233, in draw prologue_text=self.prologue_text, epilogue_text=self.epilogue_text)) File "/usr/local/lib/python2.7/dist-packages/consolemenu/screen.py", line 75, in printf print(args, end='') UnicodeEncodeError: 'ascii' codec can't encode characters in position 3-77: ordinal not in range(128)

aegirhall commented 5 years ago

Can you give further details about your environment? (OS, python version, console-menu version, etc. Also, how did you install console-menu - with pip, setup.py, etc?) I'm not seeing any issues with any of the examples; i've verified all examples on Linux, Mac, and Windows, so I'll need your input to try to reproduce the issue.

datatalking commented 4 years ago

Hi Aegirhall,

I'm looking at his thread and it shows he is having range vs xrange issues, isn't this a common python2 vs python3 issue? Similar to print vs print()? Code in python 2 was deprecated in the change to python3 so he would need to change print to print() etc ?

salfredogonzalez commented 3 years ago

I am running inside of a docker container python 2.7.9, a file with the lines:

from import consolemenu import from import consolemenu.items import

menu = ConsoleMenu("Title") menu.show()

And produces the same lines:

Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 763, in run self.target(*self.args, *self.__kwargs) File "/usr/local/lib/python2.7/dist-packages/consolemenu/console_menu.py", line 169, in _wrap_start self._main_loop() File "/usr/local/lib/python2.7/dist-packages/consolemenu/console_menu.py", line 225, in _main_loop self.draw() File "/usr/local/lib/python2.7/dist-packages/consolemenu/console_menu.py", line 233, in draw prologue_text=self.prologue_text, epilogue_text=self.epilogue_text)) File "/usr/local/lib/python2.7/dist-packages/consolemenu/screen.py", line 74, in printf print(args, end='') UnicodeEncodeError: 'ascii' codec can't encode characters in position 3-77: ordinal not in range(128)