Skip to content
Advertisement

Kivy MDDatePicker – TypeError: __init__() missing 1 required positional argument: ‘callback’

https://kivymd.readthedocs.io/en/latest/components/pickers/index.html#mddatepicker

This code is coming from the official presentation page so it may be a Github issue to raise ?

The widget is under testing. Therefore, we would be grateful if you would let us know about the bugs found.

from kivy.lang import Builder

from kivymd.app import MDApp
from kivymd.uix.picker import MDDatePicker

KV = '''
MDFloatLayout:

    MDToolbar:
        title: "MDDatePicker"
        pos_hint: {"top": 1}
        elevation: 10

    MDRaisedButton:
        text: "Open time picker"
        pos_hint: {'center_x': .5, 'center_y': .5}
        on_release: app.show_date_picker()
'''


class Test(MDApp):
    def build(self):
        return Builder.load_string(KV)

    def on_save(self, instance, value, date_range):
        '''
        Events called when the "OK" dialog box button is clicked.

        :type instance: <kivymd.uix.picker.MDDatePicker object>;

        :param value: selected date;
        :type value: <class 'datetime.date'>;

        :param date_range: list of 'datetime.date' objects in the selected range;
        :type date_range: <class 'list'>;
        '''

        print(instance, value, date_range)

    def on_cancel(self, instance, value):
        '''Events called when the "CANCEL" dialog box button is clicked.'''

    def show_date_picker(self):
        date_dialog = MDDatePicker()
        date_dialog.bind(on_save=self.on_save, on_cancel=self.on_cancel)
        date_dialog.open()


Test().run()

TypeError: __init__() missing 1 required positional argument: 'callback'

Advertisement

Answer

The MDDatePicker does not work with kivymd-0.104.1. You must install kivymd-0.104.2.dev0 for it to function.

pip uninstall kivymd
pip install https://github.com/kivymd/KivyMD/archive/master.zip
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement