Comments (6)
Desktop (please complete the following information):
ttkbootstrap Version = 1.10.1 OS: Windows 11 Pro
Describe the bug
When working on a PC with Norwegian locale, DatePickerDialog throws a "local.Error", failing the import of ttkboostrap. Norwegian locale contains non-ASCII characters "å", which is not accepted in setting the locale in line 566 of \ttkbootstrap\dialogs\dialogs.py".
To Reproduce
Set computer region to Norway and import ttkbootstrap.
Expected behavior
No response
Screenshots
No response
Additional context
No response
I tried and tried and figure out, solve it just in a simple way:
-
Just open up the dialogs.py in folder:
"C:\Users"user"\AppData\Local\Programs\Python\Python312\Lib\site-packages\ttkbootstrap\dialogs\dialogs.py", line 566 -
Overwrite this line
locale.setlocale(locale.LC_ALL, locale.setlocale(locale.LC_TIME, ""))
with
"tr_TR.utf8" (but you can overwrite as default with "en_EN.utf8")
locale.setlocale(locale.LC_ALL, locale.setlocale(locale.LC_TIME, "tr_TR.utf8"))
and everything runs without any problem.
from ttkbootstrap.
@Neoakay005's solution works. Thank you very much. However in case I wanna share my project, the receivers would need to execute the same changes in their own local package. This could potentially represent an annoyance. Perhaps it could be worth making a similar change in the repo too.
Thanks!
from ttkbootstrap.
Perhaps it could be worth making a similar change in the repo too.
Then please reopen this issue. Although there isn't much activity on the project lately, it's better to leave unresolved issues open.
from ttkbootstrap.
I'm not sure if my response will help you, but I've had a similar error in the past that had the same root cause as your error, which, in this case, is located in the 'dialogs.py' file at line 566. I believe that if you adapt the solution from that issue to yours, it may resolve your problem.
Based on the given link, do something like this:
set_locale_to_posix()
# Here would be all the code that uses formatting according to your preferred locale
# ....
set_locale_to_system_default()
I recommend creating functions that handle this entire process automatically, avoiding code repetition. Try doing this and then provide some feedback. Good luck! 😸
from ttkbootstrap.
Thank you for your answer, but I believe the solution may not be applicable, because the error occurs exactly the same.
import locale
def set_locale_to_posix():
locale.setlocale(locale.LC_ALL, "C")
def set_locale_to_system_default():
# This part was taken from line 566 of the "dialogs.py" file present in the "ttkbootstrap" library.
locale.setlocale(locale.LC_ALL, locale.setlocale(locale.LC_TIME, "nb_NO"))
set_locale_to_posix()
import ttkbootstrap as ttk
set_locale_to_system_default()
The problem comes from the fact that locale.setlocale(locale.LC_TIME, ""))
in line 566 returns "('Norwegian Bokmål_Norway', '1252')" and the letter "å" can't be passed to locale.setlocale(locale.LC_ALL, "Norwegian Bokmål_Norway")
.
I have been looking into changing the default locale to something of my choice from python, to import ttkbootstrap and reset it to Norwegian at the end of the script.
I don't really have any operation to do with a particular date format, I just need to import the model, but that is when the error is raised.
from ttkbootstrap.
I got the same here and I'm not Norwegian
ttkbootstrap version 1.10.1
(venv) my_project % locale
LANG=""
LC_COLLATE="C"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
test.py
import ttkbootstrap as tb
output :
Traceback (most recent call last):
File "test.py", line 11, in <module>
import ttkbootstrap as tb
File "venv/lib/python3.10/site-packages/ttkbootstrap/__init__.py", line 3, in <module>
from ttkbootstrap.widgets import *
File "venv/lib/python3.10/site-packages/ttkbootstrap/widgets.py", line 14, in <module>
from ttkbootstrap.dialogs import Querybox
File "venv/lib/python3.10/site-packages/ttkbootstrap/dialogs/__init__.py", line 1, in <module>
from ttkbootstrap.dialogs.dialogs import *
File "venv/lib/python3.10/site-packages/ttkbootstrap/dialogs/dialogs.py", line 536, in <module>
class DatePickerDialog:
File "venv/lib/python3.10/site-packages/ttkbootstrap/dialogs/dialogs.py", line 566, in DatePickerDialog
locale.setlocale(locale.LC_ALL, locale.setlocale(locale.LC_TIME, ""))
File ".pyenv/versions/3.10.3/lib/python3.10/locale.py", line 620, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
Platform: Apple M1 - Ventura - 13.6.1 (22G313)
from ttkbootstrap.
Related Issues (20)
- AttributeError: module 'PIL.Image' has no attribute 'CUBIC' HOT 7
- GUI elements not responsive on x86_64 macOS 14 if mouse cursor was under the window region during startup HOT 2
- Menu ugly border HOT 1
- Bug when using the meter widget (related to how the Pillow package handles image resize) HOT 2
- ttkcreator not opening due to wrong attribute HOT 3
- DateEntry configure() doesn't change startdate in DateEntry field HOT 2
- Spinbox: bug when setting a float value as increment HOT 1
- allow for `justify` argument in `tooltip`
- Add height property to ttkbootstrap.Button(height=5) HOT 11
- Issue with ttkbootstrap.Checkbutton after Python 3.12 install HOT 1
- Add selection_changed event to TableView HOT 2
- How can I set the background color for specific rows in Tableview? HOT 1
- Multiple FloodGauge with same bootstyle, all show same mask despite different ones set.
- Destroying a scrolledframe while it is under the cursor gives bad window path
- CUBIC not found in the widgets.py file HOT 1
- kwarg paramter "default" of Messagbox methods is ignored
- Handling of the Enter button is incorrect for Messagebox
- Attribute Error When Executing python -m ttkcreator due to Incompatibility with Pillow - FIXED
- locale.Error: unsupported locale setting HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ttkbootstrap.