Last active
December 16, 2015 08:29
-
-
Save geojeff/5406616 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kivy.uix.modalview import ModalView | |
from kivy.uix.listview import ListView | |
from kivy.uix.gridlayout import GridLayout | |
from kivy.lang import Builder | |
from kivy.factory import Factory | |
# Note the special nature of indentation in the adapter declaration, where | |
# the adapter: is on one line, then the value side must be given at one level | |
# of indentation. | |
Builder.load_string(""" | |
#:import label kivy.uix.label | |
#:import sla kivy.adapters.simplelistadapter | |
<ListViewModal>: | |
size_hint: None,None | |
size: 400,400 | |
ListView: | |
size_hint: .8,.8 | |
adapter: sla.SimpleListAdapter(\ | |
data=["Item #{0}".format(i) for i in xrange(100)],\ | |
cls=label.Label) | |
""") | |
class ListViewModal(ModalView): | |
def __init__(self, **kwargs): | |
super(ListViewModal, self).__init__(**kwargs) | |
class MainView(GridLayout): | |
""" | |
Implementation of a ListView using the kv language. | |
""" | |
def __init__(self, **kwargs): | |
kwargs['cols'] = 1 | |
super(MainView, self).__init__(**kwargs) | |
listview_modal = ListViewModal() | |
self.add_widget(listview_modal) | |
if __name__ == '__main__': | |
from kivy.base import runTouchApp | |
runTouchApp(MainView(width=800)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment