Using a copy of dialogs, get the following error: “collections has no attribute Sequence” and “collections.abc has no attribute Sequence”.
bosco last edited by bosco
@Appletrain This may help.
# Python 3.10 has put Sequence in collections.abc instead of collections import collections collections.Sequence = collections.abc.Sequence
Thank you, that fixed it.
Also, datepicker is fubar.
cvp last edited by cvp
datepicker is fubar.
If you mean that ui.DatePicker does no more show a wheel, you could try this
import ui from objc_util import ObjCInstance v = ui.View() v.background_color = 'white' dp = ui.DatePicker() objc = ObjCInstance(dp) @on_main_thread def setWheel(): objc.setPreferredDatePickerStyle_(1) setWheel() v.add_subview(dp) v.present()
Thank you. Now I think I understand it. How do I get the result? I assume I have to call action somehow.
@Appletrain yes, action is called each time you change the date
import ui from objc_util import ObjCInstance v = ui.View() v.background_color = 'white' dp = ui.DatePicker() def dp_action(sender): print(sender.date) dp.action = dp_action objc = ObjCInstance(dp) @on_main_thread def setWheel(): objc.setPreferredDatePickerStyle_(1) setWheel() v.add_subview(dp) v.present()
Thus, you need also to close the datepicker to get the final selected date
Great, thank you. I guess I should get familiar with objc.
@Appletrain If you prefer to use
dialogs.date_dialogyou can also monkey patch it with this code
import dialogs from objc_util import ObjCInstance import ui # to change an attribute of the dialog ui.DatePicker, we need # to do it before it is presented # the next mehod is called internally in _DateDialogController # monkey patching of __init__ method, see dialogs.py original_init = dialogs._DateDialogController.__init__ def new_init(self, mode=ui.DATE_PICKER_MODE_DATE, title='', done_button_title='Done'): original_init(self, mode, title, done_button_title) ObjCInstance(self.view).setPreferredDatePickerStyle_(1) dialogs._DateDialogController.__init__ = new_init dt = dialogs.date_dialog() dialogs._DateDialogController.__init__ = original_init # to avoid recursion error print(dt)
@random_soul you could be also interested by previous post.
Thank you. That gives me another piece to the script I’m working on. I
never thought of “monkey patching” as I don’t use it much.