0
0 комментариев

Я пытаюсь использовать кириллицу в интерфейсе, но приложение не запускается. Вот код:

main.py

#  -*- coding: utf-8 -*-
 
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
import sys
 
sys.setdefaultencoding('utf-8')
 
class MainScreen(Screen):
    pass
 
class AnotherScreen(Screen):
    pass
 
class ScreenManagement(ScreenManager):
    pass
 
presentation = Builder.load_file("main.kv")
 
class MainApp(App):
    def build(self):
        return presentation
 
MainApp().run()

main.kv

#  -*- coding: utf-8 -*-
 
ScreenManagement:
    MainScreen:
    AnotherScreen:
 
<MainScreen>:
    name: 'main'
 
    Button:
        on_release: app.root.current = 'other'
        text: 'Другой экран'
        font_size: 50
 
<AnotherScreen>:
    name: 'other'
 
    Button:
        on_release: app.root.current = 'main'
        text: 'back to the home screen'
        font_size: 50

Когда я запускаю программу на андроид, получаю:

[INFO ] [Kivy ] v1.9.2-dev0
[INFO ] [Python ] v3.6.2 (default, Oct 29 2017, 05:27:57)
[GCC 7.2.0]
[INFO ] [Factory ] 193 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_gif, img_sdl2 (img_pil, img_ffpyplayer ignored)
Traceback (most recent call last):
File "/storage/emulated/0/Download/TrafficTaxApp/TrafficTaxApp/main.py", line 19, in
presentation = Builder.load_file("main.kv")
File "/data/data/ru.iiec.pydroid3/files/i686-linux-android/lib/python3.6/site-packages/kivy/lang/builder.py", line 290, in load_file
data = fd.read()
File "/data/data/ru.iiec.pydroid3/files/i686-linux-android/lib/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 186: ordinal not in range(128)

На Ubuntu все хорошо, никаких проблем.

Что может быть не так?


Добавить комментарий