我有两个带有一个kv文件的应用程序。两个应用程序之间仅在app类名称中有所不同。应用A给出了良好的结果,但应用B是坏的。哪里有问题?
申请A:
import kivy
kivy.require('1.0.5')
from kivy.lang.builder import Builder
from kivy.uix.button import Button
from kivy.uix.gridlayout import GridLayout
from kivy.app import App
class MyW(GridLayout):
pass
class ShowApp(App):
def build(self):
Builder.load_file('d:\\MyPgm\\Python\\kivy\\ControlShow \\ControlShow.kv')
return MyW()
if __name__ == '__main__':
ShowApp().run()
申请B:
import kivy
kivy.require('1.0.5')
from kivy.lang.builder import Builder
from kivy.uix.button import Button
from kivy.uix.gridlayout import GridLayout
from kivy.app import App
class MyW(GridLayout):
pass
class ControlShowApp(App):
def build(self):
Builder.load_file('d:\\MyPgm\\Python\\kivy\\ControlShow \\ControlShow.kv')
return MyW()
if __name__ == '__main__':
ControlShowApp().run()
KV档案:
<MyW>
cols: 2
rows: 2
Button:
id: label1
text: 'B1'
Button:
id: label2
text: 'B2'
Button:
id: label3
text: 'B3'
Button:
id: label4
text: 'B4'
答案 0 :(得分:1)
问题如下:
#:kivy 1.10.0
<MyW>:
cols: 2
rows: 2
Button:
id: label1
text: 'B1'
Button:
id: label2
text: 'B2'
Button:
id: label3
text: 'B3'
Button:
id: label4
text: 'B4'
from kivy.lang.builder import Builder
from kivy.uix.gridlayout import GridLayout
from kivy.app import App
class MyW(GridLayout):
pass
class ShowApp(App):
def build(self):
Builder.load_file('d:\\MyPgm\\Python\\kivy\\ControlShow \\ControlShow.kv')
return MyW()
if __name__ == '__main__':
ShowApp().run()
from kivy.lang.builder import Builder
from kivy.uix.gridlayout import GridLayout
from kivy.app import App
class MyW(GridLayout):
pass
class ControlShowApp(App):
def build(self):
Builder.load_file('d:\\MyPgm\\Python\\kivy\\ControlShow \\ControlShow.kv')
return MyW()
if __name__ == '__main__':
ControlShowApp().run()