Python 3.x KivyMD日期选择器不随屏幕大小调整大小

Python 3.x KivyMD日期选择器不随屏幕大小调整大小,python-3.x,kivy,kivy-language,Python 3.x,Kivy,Kivy Language,我不知道如何根据屏幕大小动态调整MDDatePicker的大小,它不能像标签和按钮那样正确调整,而是不规则地调整 我在KivyMD文档中找不到像Kivy widgets那样的内容 您必须单击选择日期按钮以打开日期选择器 py文件 import kivy from kivy.app import App from kivy.properties import ObjectProperty, StringProperty, NumericProperty, ListProperty from kiv

我不知道如何根据屏幕大小动态调整MDDatePicker的大小,它不能像
标签
按钮那样正确调整,而是不规则地调整

我在KivyMD文档中找不到像Kivy widgets那样的内容

您必须单击选择日期按钮以打开日期选择器

py文件

import kivy
from kivy.app import App
from kivy.properties import ObjectProperty, StringProperty, NumericProperty, ListProperty
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder
from kivy.uix.popup import Popup
from kivy.uix.label import Label
from kivy.core.text import Label as CoreLabel
from kivy.uix.button import Button
from kivy.core.window import Window
from kivymd.theming import ThemeManager
import mysql.connector
from kivymd.uix.picker import MDDatePicker
from kivy.uix.scrollview import ScrollView


Window.clearcolor = (1,1,1,1)

class Information(Screen):

    def select_date(self):
        picker = MDDatePicker(callback=self.got_date)
        picker.open()

    def got_date(self, the_date):
        print(the_date)

class WindowManager(ScreenManager):
    pass


class MyApp(App):
    theme_cls = ThemeManager()

    def build(self):
        kv = Builder.load_file("kivy.kv")
        sm = WindowManager()

        screens = [Information(name="information")]
        for screen in screens:
            sm.add_widget(screen)

        sm.current = "information"
        return sm


if __name__ == '__main__':
    MyApp().run()
kv文件

<Information>:
    name: "information"

    NavigationLayout:
        id: nav_layout
        MDNavigationDrawer:
            NavigationDrawerIconButton:
                text: "Test"
                on_release: app.root.current = "login"

        FloatLayout:
            MDToolbar:
                pos_hint: {'top': 1}
                md_bg_color: 0.2, 0.6, 1, 1
                left_action_items: [['menu', lambda x: root.ids.nav_layout.toggle_nav_drawer()]]

            MDRaisedButton:
                text: "Select date"
                pos_hint: {"x": 0.35, "top": 0.6}
                on_release: root.select_date()
:
名称:“信息”
导航布局:
id:nav_布局
MDNavigationDrawer:
导航抽屉按钮:
文本:“测试”
发布时:app.root.current=“登录”
浮动布局:
MDToolbar:
位置提示:{'top':1}
md_bg_颜色:0.2,0.6,1,1
左_操作_项:[['menu',lambda x:root.ids.nav_布局。切换_nav_抽屉()]
MDRaisedButton:
文本:“选择日期”
pos_提示:{“x”:0.35,“top”:0.6}
发布时:root。选择发布日期()

提前感谢

您可以在
MDRaisedButton
下尝试:

MDRaisedButton:
    size: root.width, root.height
或者在任何需要调整大小的地方。
size
命令格式为
size:x,y
,单位为千伏