Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for military time in MDTimePicker #132

Closed
EsbenLorenzen opened this issue Nov 2, 2019 · 17 comments
Closed

Support for military time in MDTimePicker #132

EsbenLorenzen opened this issue Nov 2, 2019 · 17 comments
Labels
Scope: UIX UI components Type: Enhancement Feature request/Feature implementation

Comments

@EsbenLorenzen
Copy link

EsbenLorenzen commented Nov 2, 2019

Description of the Feature

Are there plans to implement support for military time (24 hour clock) in the circular time picker?

I've looked through the source code of kivy.vendor.circularTimePicker, and it seems like some work has already been done on this feature. There is some code commented out, but it seems to be a bit incomplete.

Any status on this feature? Almost ready to be released, or nowhere near completion?

I would like to offer my help on this functionality, but I am unsure if my python-skills are good enough to pull this off. In any case, any additional information would be helpful.

Below is the code, where I found the commented sections.

Code and Logs

kivymd.vendor.circularTimePicker @ line 503:

class CircularHourPicker(CircularNumberPicker):
    """:class:`CircularNumberPicker` implementation for hours.
    """

    # military = BooleanProperty(False)

    def __init__(self, **kw):
        super().__init__(**kw)
        self.min = 1
        self.max = 13
        # 25 if self.military else 13
        # self.inner_radius_hint = .8 if self.military else .6
        self.multiples_of = 1
        self.number_format_string = "{}"
        self.direction = "cw"
        self.bind(shown_items=self._update_start_angle)
        # self.bind(military=lambda v: setattr(self, "max", 25 if v else 13))
        # self.bind(military=lambda v: setattr(
        #     self, "inner_radius_hint", .8 if self.military else .6))
        # Clock.schedule_once(self._genitems)
        Clock.schedule_once(self._update_start_angle)
        Clock.schedule_once(self.on_selected)

    def _update_start_angle(self, *a):
        self.start_angle = (360.0 / self.shown_items / 2) - 90

Versions

  • OS: Ubuntu 18
  • Python: 3.7+
  • Kivy: 1.11.1
  • KivyMD: 0.102.0
@ArtemSBulgakov
Copy link
Member

I think that 24-hour time picker is very useful feature. We should implement it as two rows of numbers how it did Google.
Time picker
We always welcome if you want to improve KivyMD. You need to read CONTRIBUTING.md before pull request.

@ArtemSBulgakov ArtemSBulgakov added Scope: UIX UI components Type: Enhancement Feature request/Feature implementation labels Nov 2, 2019
@HeaTTheatR
Copy link
Member

If someone is already doing this, let me know, then I will solve other problems.

@EsbenLorenzen
Copy link
Author

@HeaTTheatR
I tried looking into this, but I'm afraid it's a bit outside the range of my Python skills.

I will try to look into other ways of contributing to this project.
Any work that needs to be done, which would fit my intermediate skill level?
If not, I will start working on expanding the documentation, one my schedule clears up next week.

@HeaTTheatR
Copy link
Member

@EsbenLorenzen I can send you draft of this.
888

@EsbenLorenzen
Copy link
Author

@HeaTTheatR
Looks good - I won’t have time to look at at it in about a week, but I’ll be happy to take a look and see what I can come up with.

@HeaTTheatR
Copy link
Member

#712

@Babber
Copy link

Babber commented Jan 26, 2022

Dear All,
could you please illustrate on the basic example below how to turn on this new feature? I just couldn't make it work. Whatever I do, I get the AM/PM layout. I installed https://github.com/kivymd/KivyMD/archive/master.zip
Many thanks for your help in advance!

from kivy.lang import Builder

from kivymd.app import MDApp
from kivymd.uix.pickers import MDTimePicker

KV = '''
MDFloatLayout:

    MDRaisedButton:
        text: "Open time picker"
        pos_hint: {'center_x': .5, 'center_y': .5}
        on_release: app.show_time_picker()
'''


class Test(MDApp):
    def build(self):
        return Builder.load_string(KV)

    def show_time_picker(self):
        '''Open time picker dialog.'''

        time_dialog = MDTimePicker()
        time_dialog.open()


Test().run()

@Babber
Copy link

Babber commented Feb 14, 2022

OK, as I see now, this is not included at all in the current master branch. Too bad, this feature would be very welcome. Are there still plans to make this work?..

@HeaTTheatR
Copy link
Member

@Babber We removed this functionality as unnecessary.

@Babber
Copy link

Babber commented Feb 14, 2022

Thanks for the answer @HeaTTheatR. Although I don't quite get it. According to Wikipedia:

The 12-hour time convention is common in several English-speaking nations and former British colonies, as well as a few other countries. ... In most countries, however, the 24-hour clock is the standard system used, especially in writing.

This means that there are a few billions of people (apparently the majority of humanity) whose preference is deemed unnecessary to consider here, even as an optional feature?.. To be honest, I find this rather disappointing.

@HeaTTheatR
Copy link
Member

@Babber
Снимок экрана 2022-02-14 в 23 01 01

@Babber
Copy link

Babber commented Feb 14, 2022

@HeaTTheatR
I know that the military time support is apparently not part of this rather exclusive specification (I assume, this is what you would like to say with this image), but adding a militaryTimePicker.py file to the repo doesn't have to ruin this design at all. Or just another class in the same file, or another method to the same class, which is called with a mode=military option, I don't really mind. None of the time pickers have to have a button to switch between the two. Keeping the above design exactly as it is and also offering the military time picker are not mutually exclusive. I think it's rather obvious that there is a demand for the military option (see Wikipedia), and I don't see the arguments against it. Apparently it has even been implemented once already, although I am not sure why eventually it failed to get released. Is there now nobody to code it again? I would get that. A bounty is missing? How much? I am seriously considering sponsoring this specific feature. As I see, there was a $20 bounty on adding support for military time in MDTimePicker. I am willing to give more than that if a working implementation of this gets released in the master branch. Details can be discussed later if someone is interested.

@HeaTTheatR
Copy link
Member

@Babber I don't think we will include this functionality in the library again. At the developer level, you can easily transform the time into any format depending on the AM/PM values. But in any case, no one bothers you to assign a reward for adding this functionality.

@Babber
Copy link

Babber commented Feb 14, 2022

@HeaTTheatR
I see. Yeah, thanks, I know how to convert between the two systems.
Finally, just to be clear: even if I implement it myself, you won't add it to the library? If I have some free time, and I may actually do it anyway and host it on my own, but of course, it would give me more motivation if I could add it as a contribution to the KivyMD library.

@HeaTTheatR
Copy link
Member

@Babber
KivyMD library packages of the kivymd.uix.ickers type currently have functionality and design consistent with Google Material Design. You must understand how difficult it is to add the functionality that you describe here to the functionality that currently exists. Moreover, we consciously got rid of the functionality that you describe.

@Babber
Copy link

Babber commented Feb 14, 2022

@HeaTTheatR
Alright. I get it.
Just for the record, even on Material.io, they also show the 24h time picker (although a less sophisticated version of it) if you click on "Implementation":
image
Here, selection of hours is basically the same as the selection of minutes, but with less numbers, so this should be rather easy to implement. Although admittedly, this is the less desirable version.
Meanwhile elsewhere, in js, supposedly also following Material Design, the one that I also have on my own Android, like I guess on most of the mobile devices (although I don't know this for a fact, just judging by the overall popularity of the 24h system in the world):
image

But anyway, I don't want to pester you any more with this. You're the core developer here and I respect your decisions of course. KivyMD is still a great project, I do like it and I do appreciate your work! Thank you for this and many thanks for the discussion too.

@Babber
Copy link

Babber commented Feb 25, 2022

For anyone who's interested in the same TimePicker extended with the 24-hour clock:
https://github.com/Babber/KivyMD-TimePicker-with-24h-support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: UIX UI components Type: Enhancement Feature request/Feature implementation
Projects
None yet
Development

No branches or pull requests

4 participants