一个最基本的kivy程序:
from kivy.app import App
from kivy.uix.button import Button
class TestApp(App):
def build(self):
return Button(text='Hell')
TestApp().run()
§1 kivy的两种形式
py文件内直接引用
kv文件配合py文件
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout
class IndexPage(BoxLayout):
def init(self,kwargs):
super().init(kwargs)
self.join = Button(text='Hello world')
self.add_widget(self.join)
class TestApp(App):
def build(self):
return IndexPage()
if name == "main":
test = TestApp()
test.run()