总目录
在build()函数中,可以使用Windows.size()函数定义应用窗口大小
测试代码如下:
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.popup import Popup
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.core.window import Window
class CustomWindowApp(App):
def build(self):
# 设置窗口的宽度和高度
Window.size = (400, 600)
self.layout = FloatLayout()
self.button = Button(text='button')
self.button.bind(on_press=self.show_popup)
self.layout.add_widget(self.button)
return self.layout
def show_popup(self, instance):
content = Label(text="this is a popups")
self.popup = Popup(title="标题",
content=content,
size_hint=(None, None),
size=(400, 200))
self.popup.open()
if __name__ == '__main__':
CustomWindowApp().run()