3

I'm not sure how to dynamically resize the MDDatePicker with the screen size, it doesn't adjust correctly like Labels and Buttons but rather adjusts erratically.

I couldn't find much on KivyMD documentation like there in on Kivy widgets.

You've got to click the Select Date button to open the Date Picker

py file

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 file

<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()

Thanks in advance

Callum
  • 195
  • 2
  • 22

1 Answers1

0

you could try under MDRaisedButton putting this:

MDRaisedButton:
    size: root.width, root.height

or where ever you need to resize. The size commands format is size: x, y in kv lang