Skip to content Skip to sidebar Skip to footer

Kivy Date Picker Widget

[SOLVED] Please see below for application of accepted answer and source code for functioning kivy DatePicker widget. I've been learning Kivy and decided to make a date picker widge

Solution 1:

you do a small mistake in your binding, you call the method instead of passing it (thus, you pass the result of self.set_date(date_cursor.day), but calling self.set_date calls self.populate_body too, so you get in an infinite recursion, only stopped by python recursion limit.

What you want to do is bind the method but with date_cursor.day as a first parameter, for this the partial function, from functools is perfect.

self.date_label.bind(on_touch_down=partial(self.set_date, date_cursor.day))

Creates a new fonction, that is just like self.set_date, but with date_cursor.day preloaded as a first argument.

edit: also, when your partial function is called by the event binding, it will recieve other arguments, so it's a good habit to add **args at the end of your arguments in functions/methods you use ass callbacks (here set_date).

Post a Comment for "Kivy Date Picker Widget"