Implement DateInput and TimeInput for Cocoa, GTK and iOS
What is the problem or limitation you are having?
Currently there is no implementation for showing a calendar. It would be useful for at least 2 reasons and probably more.
1st reason would be allowing the user to select a specific date for the program to use. 2nd reason would be allowing the program to show a custom calender that the user could fill with their own events that may be useful inside a specific app instead of in the built in calender. An example would be a finance app that allows the user to specify when bills or subscriptions get billed easier.
Describe the solution you'd like
For Android there is 2 different widgets that can be used for each reason. For displaying a calender with events I believe that the CalenderView is the option that would be wanted. For selecting a date there is a date picker implementation already.
For Gtk there is only one widget for this. The Gtk.Calender allows for displaying a calendar and has the ability to add custom events as well as the ability to get the selected date. For a date picker implementation a custom window may need to be made similar to the error dialogs and such.
Describe alternatives you've considered
Not having a calender widget and having the user manually type in dates and making a custom view for dates and such.
Additional context
No response
After further looking I did realize that there is already the start of a datepicker implementation, just not documented in on the readthedocs yet.
DatePicker and TimePicker both exist in the Toga API; however, they're only implemented on Windows and Android. The lack of documentation is definitely an oversight; and we'd definitely like to fill this out with GTK, iOS, Cocoa and Web implementations.
I can see about the GTK implementation. My question there is since a custom widget may need to be made, is there anything with GTK already that would be appropriate to take inspiration from to create it?
Also for web I can look into it as well. If shoelace is still the wanted framework it looks like there has been a discussion about an implementation of this so I can go from there for an implementation maybe.
Actually, after looking at it a popover would probably be the best option for a date and time picker for GTK
Adding error that happens when you try to use DatePicker on GTK for search seo.
Traceback (most recent call last):
File "/home/russell/github/beeware/toga/examples/date_and_time/build/date_and_time/pop/jammy/date_and_time-0.0.1/usr/lib/date_and_time/app_packages/toga_gtk/app.py", line 98, in gtk_startup
self.interface.startup()
File "/home/russell/github/beeware/toga/examples/date_and_time/build/date_and_time/pop/jammy/date_and_time-0.0.1/usr/lib/date_and_time/app/date_and_time/app.py", line 21, in startup
toga.DatePicker(
File "/home/russell/github/beeware/toga/examples/date_and_time/build/date_and_time/pop/jammy/date_and_time-0.0.1/usr/lib/date_and_time/app_packages/toga/widgets/datepicker.py", line 43, in __init__
self._impl = self.factory.DatePicker(interface=self)
AttributeError: module 'toga_gtk.factory' has no attribute 'DatePicker'
This error message will be improved in #1992.
And in the next version of Toga:
- DatePicker and TimePicker will be renamed to DateInput and TimeInput, for consistency with the other widgets.
- Both widgets will be documented.
PRs that exist:
- #3483
- #3536
- #3574
- [By someone else] #3647
Issues relating to Date and Time Inputs:
- #3580 (non-working fix at #3581)
- #3660 (this request may be terribly mistaken).
Also: #3574 makes macOS the first backend to have all widgets implemented.
DateInput for iOS merged! Time to start TimeInput for iOS.
TimeInput for iOS started/
There's no need to post comments on an issue when you start and finish a related PR. Just mention the issue number somewhere in the PR, and GitHub will automatically create a reverse link that indicates the PR status using color, as it has above for #3483.
FYI: Comment above for list of PRs edited, iOS users should be aware of the bug.
FWIW, I've linked another PR in the list for posterity; all that's left now is TimeInput on GTK+; this is a non-native-existing widget, and 3 GtkSpinButtons might work (h, m, s...)