Repository: kivy/kivy

Issue:
Notes tutorial crashes when adding a new note
https://github.com/kivy/kivy/blob/master/examples/tutorials/notes/final/main.py
Related to https://github.com/kivy/kivy/pull/3469.

``` python
 Traceback (most recent call last):
   File "E:\dev\envs\py34_x86\kivy\examples\tutorials\notes\final\main.py", line 158, in <module>
     NoteApp().run()
   File "e:\dev\envs\py34_x86\kivy\kivy\app.py", line 828, in run
     runTouchApp()
   File "e:\dev\envs\py34_x86\kivy\kivy\base.py", line 487, in runTouchApp
     EventLoop.window.mainloop()
   File "e:\dev\envs\py34_x86\kivy\kivy\core\window\window_sdl2.py", line 606, in mainloop
     self._mainloop()
   File "e:\dev\envs\py34_x86\kivy\kivy\core\window\window_sdl2.py", line 361, in _mainloop
     EventLoop.idle()
   File "e:\dev\envs\py34_x86\kivy\kivy\base.py", line 336, in idle
     Clock.tick_draw()
   File "e:\dev\envs\py34_x86\kivy\kivy\clock.py", line 490, in tick_draw
     self._process_events_before_frame()
   File "e:\dev\envs\py34_x86\kivy\kivy\clock.py", line 640, in _process_events_before_frame
     event.tick(self._last_tick, remove)
   File "e:\dev\envs\py34_x86\kivy\kivy\clock.py", line 374, in tick
     ret = callback(self._dt)
   File "e:\dev\envs\py34_x86\kivy\kivy\uix\listview.py", line 950, in _spopulate
     self.populate()
   File "e:\dev\envs\py34_x86\kivy\kivy\uix\listview.py", line 998, in populate
     item_view = self.adapter.get_view(index)
   File "e:\dev\envs\py34_x86\kivy\kivy\adapters\listadapter.py", line 211, in get_view
     item_view = self.create_view(index)
   File "e:\dev\envs\py34_x86\kivy\kivy\adapters\listadapter.py", line 234, in create_view
     view_instance = cls(**item_args)
   File "e:\dev\envs\py34_x86\kivy\kivy\uix\boxlayout.py", line 102, in __init__
     super(BoxLayout, self).__init__(**kwargs)
   File "e:\dev\envs\py34_x86\kivy\kivy\uix\layout.py", line 72, in __init__
     super(Layout, self).__init__(**kwargs)
   File "e:\dev\envs\py34_x86\kivy\kivy\uix\widget.py", line 312, in __init__
     super(Widget, self).__init__(**kwargs)
   File "kivy\_event.pyx", line 253, in kivy._event.EventDispatcher.__init__ (kivy\_event.c:4863)
 TypeError: object.__init__() takes no parameters
```



Discussion:
I'd like to start contributing by solving this issue. No one assigned as I see :)

@xwaffelx go ahead

@xwaffelx :ice_cream: , here's a pointer for what needs to be changed: https://github.com/kivy/kivy/pull/3469#issuecomment-116297905.

Well, it works just fine on my setup with python 2...
It doesn't work on python 3 because of json.load() function not accepting fd. Logs in this issue show the opposite. So should it run on python 3 also?

Hey, is this still open.

@abit2, does it look closed? :ghost: 


Resolving patch:
diff --git a/examples/tutorials/notes/final/main.py b/examples/tutorials/notes/final/main.py
--- a/examples/tutorials/notes/final/main.py
+++ b/examples/tutorials/notes/final/main.py
@@ -36,7 +36,6 @@ def prepare(self, *args):
     def on_touch_down(self, touch):
         if self.collide_point(*touch.pos) and touch.is_double_tap:
             self.edit()
-            return True
         return super(MutableTextInput, self).on_touch_down(touch)
 
     def edit(self):
@@ -63,6 +62,11 @@ class NoteView(Screen):
 
 class NoteListItem(BoxLayout):
 
+    def __init__(self, **kwargs):
+        print(kwargs)
+        del kwargs['index']
+        super(NoteListItem, self).__init__(**kwargs)
+    note_content = StringProperty()
     note_title = StringProperty()
     note_index = NumericProperty()
 
@@ -92,12 +96,12 @@ def build(self):
     def load_notes(self):
         if not exists(self.notes_fn):
             return
-        with open(self.notes_fn, 'rb') as fd:
+        with open(self.notes_fn) as fd:
             data = json.load(fd)
         self.notes.data = data
 
     def save_notes(self):
-        with open(self.notes_fn, 'wb') as fd:
+        with open(self.notes_fn, 'w') as fd:
             json.dump(self.notes.data, fd)
 
     def del_note(self, note_index):


Test patch: