Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is an example from my understanding you are trying to achieve. It is based on the simplest <a href="http://kivy.org/docs/api-kivy.uix.listview.html" rel="nofollow">ListView example</a>. Please notice that I created an extended JSON version from the example you provided. Also, when you want to use the url, you have to substitute the 2 commented lines. The method for loading the json is <code>load</code> (for io input) and not <code>loads</code> (for string input).</p> <pre><code>from kivy.uix.listview import ListView from kivy.uix.gridlayout import GridLayout import json import urllib2 class MainView(GridLayout): def __init__(self, **kwargs): kwargs['cols'] = 2 super(MainView, self).__init__(**kwargs) the_string_json = '{"meta": {"previous": null, "total_count": 8, "offset": 0, "limit": 20, "next": null}, "objects": [{"id": 1, "page_count": 155, "description": "Cool book", "title": "Kivy book 1"}, {"id": 1, "page_count": 155, "description": "Cool book", "title": "Kivy book 2"}, {"id": 1, "page_count": 155, "description": "Cool book", "title": "Kivy book 3"}]}' the_dict = json.loads(the_string_json) # Substitute the previous two lines for this ones: # the_io_json = urllib2.urlopen('mysite.com/api/books/?format=json') # the_dict = json.load(the_io_json) list_view = ListView( item_strings=[book['title'] for book in the_dict['objects']]) self.add_widget(list_view) if __name__ == '__main__': from kivy.base import runTouchApp runTouchApp(MainView(width=800)) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload