Babber / KivyMD-TimePicker-with-24h-support

The TimePicker widget from KivyMD extended with the option of a 24h (military) clock
MIT License
10 stars 1 forks source link

Error when run test sample #1

Open Dreamer-4pda opened 1 year ago

Dreamer-4pda commented 1 year ago

KivyMD v1.1.1

Code:

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):
        self.theme_cls.theme_style = "Dark"
        self.theme_cls.primary_palette = "Orange"
        return Builder.load_string(KV)

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

        time_dialog = MDTimePicker()
        time_dialog.open()

Test().run()

Result:

Traceback (most recent call last):
   File "d:\Art\Code\First_GUI\guiplayground\src\guiplayground\test.py", line 29, in <module>
     Test().run()
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivy\app.py", line 956, in run
     runTouchApp()
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivy\base.py", line 574, in runTouchApp
     EventLoop.mainloop()
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivy\base.py", line 339, in mainloop
     self.idle()
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivy\base.py", line 383, in idle
     self.dispatch_input()
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivy\base.py", line 334, in dispatch_input
     post_dispatch_input(*pop(0))
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivy\base.py", line 302, in post_dispatch_input       
     wid.dispatch('on_touch_up', me)
   File "kivy\_event.pyx", line 731, in kivy._event.EventDispatcher.dispatch
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivymd\uix\button\button.py", line 1187, in on_touch_up
     return super().on_touch_up(touch)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivymd\uix\behaviors\ripple_behavior.py", line 404, in on_touch_up
     return super().on_touch_up(touch)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivy\uix\behaviors\button.py", line 179, in on_touch_up
     self.dispatch('on_release')
   File "kivy\_event.pyx", line 727, in kivy._event.EventDispatcher.dispatch
   File "kivy\_event.pyx", line 1307, in kivy._event.EventObservers.dispatch
   File "kivy\_event.pyx", line 1191, in kivy._event.EventObservers._dispatch
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivy\lang\builder.py", line 55, in custom_callback    
     exec(__kvlang__.co_value, idmap)
   File "<string>", line 7, in <module>
   File "d:\Art\Code\First_GUI\guiplayground\src\guiplayground\test.py", line 25, in show_time_picker
     time_dialog = MDTimePicker()
                   ^^^^^^^^^^^^^^
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivymd\uix\pickers\timepicker\timepicker.py", line 541, in __init__
     super().__init__(**kwargs)
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivymd\uix\pickers\datepicker\datepicker.py", line 597, in __init__
     super().__init__(**kwargs)
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivymd\theming.py", line 1668, in __init__
     super().__init__(**kwargs)
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivy\uix\modalview.py", line 195, in __init__
     super(ModalView, self).__init__(**kwargs)
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivy\uix\anchorlayout.py", line 68, in __init__       
     super(AnchorLayout, self).__init__(**kwargs)
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivy\uix\layout.py", line 76, in __init__
     super(Layout, self).__init__(**kwargs)
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivymd\uix\behaviors\elevation.py", line 675, in __init__
     super().__init__(**kwargs)
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivy\uix\widget.py", line 366, in __init__
     self.apply_class_lang_rules(
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivy\uix\widget.py", line 470, in apply_class_lang_rules
     Builder.apply(
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivy\lang\builder.py", line 540, in apply
     self._apply_rule(
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivy\lang\builder.py", line 662, in _apply_rule       
     self._apply_rule(
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivy\lang\builder.py", line 660, in _apply_rule       
     child.apply_class_lang_rules(
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivy\uix\widget.py", line 470, in apply_class_lang_rules
     Builder.apply(
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivy\lang\builder.py", line 540, in apply
     self._apply_rule(
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivy\lang\builder.py", line 658, in _apply_rule       
     child = cls(__no_builder=True)
             ^^^^^^^^^^^^^^^^^^^^^^
   File "C:\Users\ddmit\AppData\Local\Programs\Python\Python311\Lib\site-packages\kivymd\uix\pickers\timepicker\timepicker.py", line 172, in __init__
     self.bind(text_color=self.setter("hint_text_color_normal"))    
   File "kivy\_event.pyx", line 452, in kivy._event.EventDispatcher.bind
 KeyError: 'text_color'
Babber commented 1 year ago

Hi @Dreamer-4pda, I assume that the problem will be that my patch is based on KivyMD v0.1.0, while you are trying to run it with KivyMD v1.1.1. At the moment, I cannot tell when I will find time to update the patch, but most probably not in the foreseeable future. I suggest that you compare my patch with the original version that the patch is based on and try to make the same changes in the current v1.1.1. On my part, no extensive changes were needed, so with a bit of luck, you can do this with little effort. If you succeed, a pull request would be very welcome!