问题
I want to make a gtk SpinButton, but for inputting dates.
- Is there an easier way to input dates into GTK?
- If not, how can I create a SpinButton look-alike, but whose output is text representing dates instead of integers? Ideally I'd re-use the arrows, the clicks, the integration with the adjustment, etc. I really just need the output to look different, as I can even represent dates as integers.
回答1:
The calendar is a bit large, but you can find code putting it in a popup. Personally I use a regular text entry and parse the date.
As for SpinButton, it is based on a text entry, so you might be able to modify its display only by fiddling with inherited signals and returning False. See also the update-policy and numeric properties.
回答2:
Perhaps you could use GtkCalendar?
回答3:
I wrote such a thing for myself:
https://github.com/ilius/starcal/blob/master/scal3/ui_gtk/mywidgets/multi_spin/date.py
来源:https://stackoverflow.com/questions/4404825/gtk-custom-spin-button