Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Date Picker w/ blank year
-
-
@cvp I tried the first version but Pythonista claimed create_objc_class() is missing. There may be some more. I guess I need to sneak into your library and steal them.
-
@osamu my error
from objc_util import *
-
@cvp I got it. Thank you.
-
@cvp This script initializes the year as 2019. If I set;
years = [str(y) for y in range(1605,datetime.now().year+1)] + ['----']
the initial year is set to 1605 and we’re far away from —— and recent years. Can we control this initial value? -
Have you tried reversing the list?
-
@JonB That’s a good idea 👍
-
@cvp one last question.
Can I set the initial year?
The following does not work.class MyUIPickerView(ui.View): def __init__(self, data, horiz=False,myRowHeight=100, myDidSelectRow=None, **kwargs): super().__init__(**kwargs) UIPickerView = ObjCClass('UIPickerView') self._picker_view = UIPickerView.alloc().initWithFrame_(ObjCInstance(self).bounds()).autorelease() ObjCInstance(self).addSubview_(self._picker_view) ... self._picker_view.selectedRow = XXX
Thanks in advance.
-
@osamu selectedRow is not an attribute of UIPickerView but is an user attribute set in the pickerView_didSelectRow_inComponent_ delegate, thus you can't set it.
I think we would need to use kind of
. . . self._picker_view.horiz = horiz xxx = 1 self._picker_view.selectRow_inComponent_animated_(xxx,0,True)
Tested, ok
-
@cvp Yes, it works. Thanks!