我刚开始与Kivy合作。我使用以下方法安装了它:
sudo add-apt-repository ppa:kivy-team/kivy
sudo apt-get update
sudo apt-get install kivy
我根据文档尝试了以下示例:
from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
class LoginScreen(GridLayout):
def __init__(self, **kwargs):
super(LoginScreen, self).__init__(**kwargs)
self.cols = 2
self.add_widget(Label(text="User Name"))
self.username = TextInput(mutiline=False)
self.add_widget(self.username)
self.add_widget(Label(text="password"))
self.password = TextInput(multiline=True)
self.add_widget(self.password)
class MyApp(App):
def build(self):
return LoginScreen()
if __name__ == "__main__":
MyApp().run()
当我从终端执行示例时,屏幕上没有任何内容。也没有错误消息。
我正在运行的平台是: