toga icon indicating copy to clipboard operation
toga copied to clipboard

Implement DateInput and TimeInput for Cocoa, GTK and iOS

Open LunaMeadows opened this issue 2 years ago • 12 comments

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

LunaMeadows avatar May 11 '23 11:05 LunaMeadows

After further looking I did realize that there is already the start of a datepicker implementation, just not documented in on the readthedocs yet.

LunaMeadows avatar May 11 '23 11:05 LunaMeadows

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.

freakboy3742 avatar May 12 '23 05:05 freakboy3742

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.

LunaMeadows avatar May 12 '23 06:05 LunaMeadows

Actually, after looking at it a popover would probably be the best option for a date and time picker for GTK

LunaMeadows avatar May 12 '23 08:05 LunaMeadows

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'

rmartin16 avatar Jun 18 '23 20:06 rmartin16

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.

mhsmith avatar Jun 19 '23 09:06 mhsmith

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.

johnzhou721 avatar May 22 '25 22:05 johnzhou721

DateInput for iOS merged! Time to start TimeInput for iOS.

johnzhou721 avatar Jun 06 '25 01:06 johnzhou721

TimeInput for iOS started/

johnzhou721 avatar Jun 06 '25 20:06 johnzhou721

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.

mhsmith avatar Jun 09 '25 08:06 mhsmith

FYI: Comment above for list of PRs edited, iOS users should be aware of the bug.

johnzhou721 avatar Jun 26 '25 01:06 johnzhou721

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...)

johnzhou721 avatar Jul 25 '25 23:07 johnzhou721