开发者

ToscaWidgets CalendarDatePicker pylons

How does one set the date on the CalendarDatePicker. i.e. it defaults to current date and I want to display it with another date which I will set from my controller.

I am displaying the CalendarDatePicker widget in a TableForm from tw.form. I have looked at this for a few hours and can't work out how to do this so any pointers greatly appreciated.

impo开发者_如何学编程rt tw.forms as twf

form = twf.TableForm('dateSel', action='changeDate', children=[ twf.CalendarDatePicker('StartDate', date_format = "%d/%m/%Y"), twf.CalendarDatePicker('EndDate', date_format = "%d/%m/%Y" ) ])


I don't have a copy of twforms laying around, but based on their sample code, it looks like you might want to do something like:

from datetime import datetime

start = twf.CalendarDatePicker('StartDate', date_format = "%d/%m/%Y")
start.default = datetime.now() # or any valid datetime object

end = twf.CalendarDatePicker('EndDate', date_format = "%d/%m/%Y" )
start.default = datetime.now() # or any valid datetime object

form = twf.TableForm('dateSel', action='changeDate', children=[start, end])
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜