robertlugg / easygui

easygui for Python
http://easygui.readthedocs.org/en/master/
BSD 3-Clause "New" or "Revised" License
455 stars 114 forks source link

Failure when changing language #168

Open acadkins327 opened 4 years ago

acadkins327 commented 4 years ago

My application can popup a box to change my weather application from English to Spanish or the reverse. When I change to Spanish and later go back to change it to English I get the following failure:

File "Weatherb.py", line 190, in Change_Settings reply = multenterbox(msg,title,fieldNames,fieldValues) File "/home/pi/.local/lib/python3.7/site-packages/easygui/boxes/multi_fillable_box.py", line 133, in multenterbox callback=callback) File "/home/pi/.local/lib/python3.7/site-packages/easygui/boxes/multi_fillable_box.py", line 186, in init mask_last, self.callback_ui) File "/home/pi/.local/lib/python3.7/site-packages/easygui/boxes/multi_fillable_box.py", line 274, in init self.create_msg_widget(msg) File "/home/pi/.local/lib/python3.7/site-packages/easygui/boxes/multi_fillable_box.py", line 338, in create_msg_widget self.messageWidget = tk.Message(self.boxRoot, width="4.5i", text=msg) File "/usr/lib/python3.7/tkinter/init.py", line 2970, in init Widget.init(self, master, 'message', cnf, kw) File "/usr/lib/python3.7/tkinter/init.py", line 2299, in init (widgetName, self._w) + extra + self._options(cnf)) _tkinter.TclError: bad screen distance "4.5i"

I am on Raspberry pi with all software current and using 98.1 - this error also happened on the previous version of Easygui.

I change the language by changing the locale setting in my application:

Set Languages - Weatherbit requires Catalan as spanish

if lang == 'es': locale.setlocale(locale.LC_ALL, str('ca_ES@valencia')) # Use language locale or install it (ES_ca/en_GB/en_US) else: locale.setlocale(locale.LC_ALL, str('en_US.UTF-8')) # sudo dpkg-reconfigure locales and select

I fixed my application problem by changing the language setting to English before going into the change box and then I have no failure:

def Change_Settings(city_state,lang,Clock_Hour,disp_units,zip_code,sname,wsource): # Check if user wants to change settings locale.setlocale(locale.LC_ALL, str('en_US.UTF-8')) ## KEEP BOX IN ENGLISH print ("\n" * 100) # Clear the background screen if ynbox("DO YOU WANT TO CHANGE THE SETTINGS?"+ "\n\n Locaton Zip Code: "+zip_code+" - "+city_state.upper()+"\n Station Name: "+sname.upper()+ "\n Select English(en) or Spanish(es): "+lang.upper()+ "\n Change time to 12 or 24 Hour Clock: "+Clock_Hour+" HOUR"+ "\n Change to Metric(C) or Imperial(F): "+disp_units.upper()+"\n Weather Source Weatherbit or Yahoo: "+wsource.upper() ,"Weather Station Setup",choices=('NO','Yes')) == False:

No doubt this is an obscure issue and can be user fixed by keeping the language in English but I thought you might want to be aware of it.

Best regards, Al Adkins