I've done some testing here, including using a .kv file, and everything works perfectly. but I'm on a Unix-like system and you're probably on Windows.
I assume you have certified that your files - either .py source code or .kv files are actually using utf-8
as encoding. Otherwise, configure your programming editor to use utf-8.
If this is not the case, Kivy is trying to open the file in the native system coding, which is Python - and in the case of Windows, it is not "utf-8".
A quick workaround would be to write your .kv file to native (latin1) encoding, but this would mean that operating systems using modern character sets by default, such as MacOS, Linux, Android, and even a future version of Windows, would have a problem with your app.
Well - I've done some searches, and you can see that this is probably the case too:
link
The solution is, instead of letting Kivy load your .kv file automatically, use the "Builder.load_string" and read the file manually, passing the encoding explicitly.
To do this, instead of having the .kv file name equal to the name of your "App" class, as it is necessary for kivy to load the file automatically,
put any other name in the .kv file, and in the .build
method of your app, do:
from kivy.lang.builder import Builder
class MyApp(App):
def build(self):
Builder.load_string(open("meu_arquivo.kv", encoding="utf-8").read(), rulesonly=True)
return MyMainWidget()
Note that using "load_string", the code that reads the .kv file is now under your control, so just use the open
of Python, forcing text encoding to utf-8. >