我在custom.kv文件中定义了CustomButton和CustomWidget, 在main.py中定义了空的CustomWidget类,但是当我运行该程序时,窗口全是黑色的,没有按钮。我在做什么错了?
main.py
import kivy
kivy.require('1.10.1')
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.button import Button
class CustomWidget(Widget):
pass
class CustomButton(Button):
pass
class MyApp(App):
def build(self):
return CustomWidget()
application = MyApp()
application.run()
custom.kv
#:kivy 1.10.1
<CustomButton@Button>:
font_size: 32
color: .5, .5, 0, 1
size: 150, 50
background_normal: ''
background_down: 'background.png'
background_color: .88, .88, .88, 1
<CustomWidget>:
CustomButton:
text: 'Random'
pos: root.x, 200
输出: