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.
JavaScript
x
50
50
1
from kivy.lang import Builder
2
3
from kivymd.app import MDApp
4
from kivymd.uix.picker import MDDatePicker
5
6
KV = '''
7
MDFloatLayout:
8
9
MDToolbar:
10
title: "MDDatePicker"
11
pos_hint: {"top": 1}
12
elevation: 10
13
14
MDRaisedButton:
15
text: "Open time picker"
16
pos_hint: {'center_x': .5, 'center_y': .5}
17
on_release: app.show_date_picker()
18
'''
19
20
21
class Test(MDApp):
22
def build(self):
23
return Builder.load_string(KV)
24
25
def on_save(self, instance, value, date_range):
26
'''
27
Events called when the "OK" dialog box button is clicked.
28
29
:type instance: <kivymd.uix.picker.MDDatePicker object>;
30
31
:param value: selected date;
32
:type value: <class 'datetime.date'>;
33
34
:param date_range: list of 'datetime.date' objects in the selected range;
35
:type date_range: <class 'list'>;
36
'''
37
38
print(instance, value, date_range)
39
40
def on_cancel(self, instance, value):
41
'''Events called when the "CANCEL" dialog box button is clicked.'''
42
43
def show_date_picker(self):
44
date_dialog = MDDatePicker()
45
date_dialog.bind(on_save=self.on_save, on_cancel=self.on_cancel)
46
date_dialog.open()
47
48
49
Test().run()
50
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.
JavaScript
1
3
1
pip uninstall kivymd
2
pip install https://github.com/kivymd/KivyMD/archive/master.zip
3