我的python版本是3.6
如果我在.kv文件中写韩语
并输入python
Builder.load_file("Bus_Information.kv")
..它不起作用。
然后我在下面找到了这样的解决方案
with open('Bus_Information.kv', encoding='utf-8') as f:
Builder.load_string(f.read())
我该如何解决?谢谢您的阅读。
py文件
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.image import Image
from kivy.uix.label import Label
from kivy.animation import Animation
from kivy.clock import Clock
#from kivy.config import Config
#Config.set('graphics', 'resizable', 0)
from kivy.core.window import Window
Window.size = (486, 650)
class Loading_Screen(Screen):
def __init__(self, **kwargs):
super(Loading_Screen, self).__init__(**kwargs)
Clock.schedule_once(self.callNext, 2)
def callNext(self,dt):
self.manager.current = 'Before_First_Screen'
class Load_BusInfo():
pass
class Before_First_Screen(Screen):
pass
class First_Screen(Screen):
pass
class Test_Screen(Screen):
pass
class DTN_TECHNOPARK(Screen):
pass
class DTN_BITZONE(Screen):
pass
class DTN_INUSTATION(Screen):
pass
class Bus_Information(Screen): ####<---Here is the problem.####
with open('Bus_Information.kv', encoding='utf-8') as f:
Builder.load_string(f.read())
#Builder.load_file("Bus_Information.kv")
class ScreenManagement(ScreenManager):
pass
presentation = Builder.load_file("main.kv")
class TubucApp(App):
def build(self):
return presentation
TubucApp().run()
这是.kv文件
<Bus_Information>:
name: 'Bus_Information'
canvas:
Rectangle:
pos: self.pos
size: self.size
source: 'image/destination/a.png' #backgroundimage
Label:
text_size: cm(6), cm(4)
#halign: 'right'
#valign: 'middle'
pos: [1, 1]
id: my_custom_label
text: '가나다라마바사' ##here is broken letters..##
color: [255,255,255,1]
我尝试过
u'가나다라마바사'
# -*- coding: utf-8 -*-