kivy-garden / garden.circulardatetimepicker

Android-like date & time picker for Kivy
MIT License
14 stars 7 forks source link

Empty ids when initializing widget #1

Closed dessant closed 8 years ago

dessant commented 8 years ago

Port of https://github.com/kivy/kivy/issues/3714. The solution is to clock schedule a method in init where those binds which reference an id are done. https://github.com/kivy-garden/garden.circulardatetimepicker/blob/master/__init__.py#L572

Original text:

Hi.

I try to use the circulardatetimepicker widget from the garden and I am facing an issue. I think it is related to kivy and not the widget so I am posting it in here.

When trying to run an application with the CircularTimePicker as root widget, the application runs correctly, but when I put the widget as a child of another (like a BoxLayout), the initialisation of the widget fails.

During the initialization phase, the widget attempts to get access to the self.ids dictionary. In the former case, it is filled correctly, in the later case, it is empty.

For instance, use that main.py

from kivy.app import App

class MyApp(App):
    pass

if __name__ == "__main__":
    MyApp().run()

The following my.kv file will work well:

#:kivy 1.0
#:import CircularTimePicker kivy.garden.circulardatetimepicker.CircularTimePicker

CircularTimePicker

While this one raises an error:

#:kivy 1.0
#:import CircularTimePicker kivy.garden.circulardatetimepicker.CircularTimePicker

BoxLayout:
    CircularTimePicker
$ ./main.py 
[INFO   ] [Logger      ] Record log in /home/sam/.kivy/logs/kivy_15-10-21_31.txt
[INFO   ] [Kivy        ] v1.9.0
[INFO   ] [Python      ] v2.7.10+ (default, Oct 10 2015, 09:11:24) 
[GCC 5.2.1 20151003]
[INFO   ] [Factory     ] 173 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_gif, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
[INFO   ] [OSC         ] using <multiprocessing> for socket
[INFO   ] [Window      ] Provider: sdl2(['window_egl_rpi'] ignored)
[INFO   ] [GL          ] OpenGL version <3.3.0 NVIDIA 340.93>
[INFO   ] [GL          ] OpenGL vendor <NVIDIA Corporation>
[INFO   ] [GL          ] OpenGL renderer <GeForce GT 220M/PCIe/SSE2>
[INFO   ] [GL          ] OpenGL parsed version: 3, 3
[INFO   ] [GL          ] Shading version <3.30 NVIDIA via Cg compiler>
[INFO   ] [GL          ] Texture max size <8192>
[INFO   ] [GL          ] Texture max units <32>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
 Traceback (most recent call last):
   File "./main.py", line 10, in <module>
     MyApp().run()
   File "/usr/lib/python2.7/dist-packages/kivy/app.py", line 797, in run
     self.load_kv(filename=self.kv_file)
   File "/usr/lib/python2.7/dist-packages/kivy/app.py", line 594, in load_kv
     root = Builder.load_file(rfilename)
   File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 1749, in load_file
     return self.load_string(data, **kwargs)
   File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 1828, in load_string
     self._apply_rule(widget, parser.root, parser.root)
   File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 1983, in _apply_rule
     child = cls(__no_builder=True)
   File "/home/sam/.kivy/garden/garden.circulardatetimepicker/__init__.py", line 572, in __init__
     self.ids.timelabel.bind(on_ref_press=self.on_ref_press)
   File "kivy/properties.pyx", line 720, in kivy.properties.ObservableDict.__getattr__ (kivy/properties.c:11171)
 AttributeError: 'super' object has no attribute '__getattr__'
depau commented 8 years ago

Fixed with 0d702d9