예제 #1
0
파일: k_lex.py 프로젝트: alex-me/py_master
 def __init__(self):
     super(Widg, self).__init__(orientation='vertical', spacing=20)
     self.s = ""
     self.txt = TextInput(multiline=False, font_size=24)
     self.bsel = Button(text='select files',
                        font_size=24,
                        background_color=[0.8, 0.2, 0.1, 1])
     self.bfrq = Button(text='compute frequency',
                        font_size=24,
                        background_color=[0.2, 0.8, 0.1, 1])
     self.lsel = ListView(item_strings=[""])
     self.lles = ListView(item_strings=[""])
     self.lmos = ListView(item_strings=[""])
     self.f = FileChooserListView(path=path,
                                  filters=['*.txt'],
                                  multiselect=True)
     self.bsel.bind(on_release=self.on_files)
     self.bfrq.bind(on_release=self.on_conv)
     self.bb = BoxLayout(size_hint=(1, 0.2))
     self.ff = BoxLayout()
     self.lm = BoxLayout(size_hint=(1, 0.6))
     self.ff.add_widget(self.f)
     self.ff.add_widget(self.lsel)
     self.bb.add_widget(self.bsel)
     self.bb.add_widget(self.bfrq)
     self.lm.add_widget(self.lles)
     self.lm.add_widget(self.lmos)
     self.add_widget(self.lm)
     self.add_widget(self.bb)
     self.add_widget(self.ff)
예제 #2
0
    def test_dict_adapter_selection_cascade(self):

        # Categories of fruits:
        #
        categories = sorted(fruit_categories.keys())
        categories_dict_adapter = \
            DictAdapter(sorted_keys=categories,
                        data=fruit_categories,
                        args_converter=self.args_converter,
                        selection_mode='single',
                        allow_empty_selection=False,
                        cls=ListItemButton)

        fruit_categories_list_view = \
            ListView(adapter=categories_dict_adapter,
                     size_hint=(.2, 1.0))

        # Fruits, for a given category, are shown based on the fruit category
        # selected in the first categories list above. The selected item in
        # the first list is used as the key into a dict of lists of list
        # items to reset the data in FruitsDictAdapter's
        # fruit_category_changed() method.
        #
        # data is initially set to the first list of list items.
        #
        fruits_dict_adapter = \
                FruitsDictAdapter(
                    sorted_keys=fruit_categories[categories[0]]['fruits'],
                    data=fruit_data,
                    args_converter=self.args_converter,
                    selection_mode='single',
                    allow_empty_selection=False,
                    cls=ListItemButton)

        categories_dict_adapter.bind(
            on_selection_change=fruits_dict_adapter.fruit_category_changed)

        fruits_list_view = ListView(adapter=fruits_dict_adapter,
                                    size_hint=(.2, 1.0))

        # List views should have adapters set.
        self.assertEqual(fruit_categories_list_view.adapter,
                         categories_dict_adapter)
        self.assertEqual(fruits_list_view.adapter, fruits_dict_adapter)

        # Each list adapter has allow_empty_selection=False, so each should
        # have one selected item.
        self.assertEqual(len(categories_dict_adapter.selection), 1)
        self.assertEqual(len(fruits_dict_adapter.selection), 1)

        # The selected list items should show is_selected True.
        self.assertEqual(categories_dict_adapter.selection[0].is_selected,
                         True)
        self.assertEqual(fruits_dict_adapter.selection[0].is_selected, True)

        # And they should be red, for background_color.
        self.assertEqual(categories_dict_adapter.selection[0].background_color,
                         [1.0, 0., 0., 1.0])
        self.assertEqual(fruits_dict_adapter.selection[0].background_color,
                         [1.0, 0., 0., 1.0])
예제 #3
0
파일: LabpiLoad.py 프로젝트: quydau35/vilas
    def __init__(self, *args, **kwargs):
        super(LoadScreen, self).__init__(*args, **kwargs)

        list_item_args_converter = lambda row_index, obj: {
            'root_path': obj.root_path,
            'item_id': obj.item_id,
            'text': obj.text,
            'pdbFile': obj.pdbFile,
            'remove_item': obj.remove_item,
            'zoom_item': obj.zoom_item,
            'list_id': obj.list_id
        }

        self.list_adapter_receptor = LoadAdapter(
            data=[],
            args_converter=list_item_args_converter,
            template='LoadListItem')
        pdb_list_1 = ListView(adapter=self.list_adapter_receptor,
                              divider_height=1,
                              id='pdb_list_1')
        self.boxlist_1.add_widget(pdb_list_1)

        self.list_adapter_ligand = LoadAdapter(
            data=[],
            args_converter=list_item_args_converter,
            template='LoadListItem')
        pdb_list_2 = ListView(adapter=self.list_adapter_ligand,
                              divider_height=1,
                              id='pdb_list_2')
        self.boxlist_2.add_widget(pdb_list_2)
예제 #4
0
파일: GUIMenu.py 프로젝트: renatotnk/UDESC
    def listaCaes(self, a):
        box = GridLayout(cols=1, rows=5, spacing=[0, 10])

        nao_adotados = self.dados.getDoguinhosNaoAdotados()

        adotados = self.dados.getDoguinhosAdotados()
        box.add_widget(Label(text='Cães Não Adotados', size_hint_y=0.15))
        dados_nao_adotados = []
        for dog in nao_adotados:
            dog_infos = dog.getInfos()
            dados_nao_adotados.append("ID: {0}     Nome: {1}".format(
                dog_infos[0], dog_infos[1]))
            dados_nao_adotados.append("Raça: {0}     Sexo: {1}".format(
                dog_infos[2], dog_infos[3]))
            dados_nao_adotados.append("Porte: {0}     Idade: {1}".format(
                dog_infos[4], dog_infos[5]))
            if dog_infos[6] == "1":
                stat = "Apto para adoção."
            else:
                stat = "Inapto para adoção."
            dados_nao_adotados.append("Status: {0}".format(stat))
            dados_nao_adotados.append("{0}".format(dog_infos[7]))
            dados_nao_adotados.append('')
            dados_nao_adotados.append('')

        simple_list_adapter = SimpleListAdapter(data=dados_nao_adotados,
                                                cls=Label)
        list_view1 = ListView(adapter=simple_list_adapter)
        box.add_widget(list_view1)

        box.add_widget(Label(text='Cães Adotados', size_hint_y=0.15))

        dados_adotados = []
        for dog in adotados:
            dog_infos = dog.getInfos()
            dados_adotados.append("ID: {0}     Nome: {1}".format(
                dog_infos[0], dog_infos[1]))
            dados_adotados.append("Raça: {0}     Sexo: {1}".format(
                dog_infos[2], dog_infos[3]))
            dados_adotados.append("Porte: {0}     Idade: {1}".format(
                dog_infos[4], dog_infos[5]))
            dados_adotados.append("{0}".format(dog_infos[7]))
            dados_adotados.append('')
            dados_adotados.append('')

        simple_list_adapter2 = SimpleListAdapter(data=dados_adotados,
                                                 cls=Label)
        list_view2 = ListView(adapter=simple_list_adapter2)
        box.add_widget(list_view2)

        fechar_botao = Button(text='Fechar', size_hint_y=0.2)
        box.add_widget(fechar_botao)
        self.popupListaCaes = Popup(title='Lista de Cães',
                                    content=box,
                                    size_hint=(None, None),
                                    size=(600, 600))
        fechar_botao.bind(on_press=self.popupListaCaes.dismiss)

        self.popupListaCaes.open()
    def __init__(self, **kwargs):
        kwargs['cols'] = 3
        super(CascadingView, self).__init__(**kwargs)

        list_item_args_converter = \
                lambda row_index, rec: {'text': rec['name'],
                                        'size_hint_y': None,
                                        'height': 25}

        # Fruit categories list on the left:
        #
        categories = sorted(fruit_categories.keys())
        fruit_categories_list_adapter = \
            DictAdapter(
                    sorted_keys=categories,
                    data=fruit_categories,
                    args_converter=list_item_args_converter,
                    selection_mode='single',
                    allow_empty_selection=False,
                    cls=ListItemButton)
        fruit_categories_list_view = \
                ListView(adapter=fruit_categories_list_adapter,
                        size_hint=(.2, 1.0))
        self.add_widget(fruit_categories_list_view)

        # Fruits, for a given category, in the middle:
        #
        image_list_item_args_converter = \
                lambda row_index, rec: {'text': rec['name'],
                                        'size_hint_y': None,
                                        'height': 32}
        fruits_list_adapter = \
                FruitsDictAdapter(
                    sorted_keys=fruit_categories[categories[0]]['fruits'],
                    data=fruit_data,
                    args_converter=image_list_item_args_converter,
                    selection_mode='single',
                    allow_empty_selection=False,
                    template='ThumbnailedListItem')
        fruits_list_view = \
                ListView(adapter=fruits_list_adapter,
                    size_hint=(.2, 1.0))

        fruit_categories_list_adapter.bind(
                on_selection_change=fruits_list_adapter.fruit_category_changed)

        self.add_widget(fruits_list_view)

        # Detail view, for a given fruit, on the right:
        #
        detail_view = FruitImageDetailView(
                fruit_name=fruits_list_adapter.selection[0].fruit_name,
                size_hint=(.6, 1.0))

        fruits_list_adapter.bind(
                on_selection_change=detail_view.fruit_changed)
        self.add_widget(detail_view)
    def __init__(self, **kwargs):
        super(MainLayout, self).__init__(**kwargs)

        self.args_converter = lambda row_index, rec: \
        {'size_hint_y': None,
        'height': 30,
         'spacing':8,
        'is_selected':False,
        'cls_dicts': [{'cls':ListItemLabel,
                        'kwargs': {'text': rec['firstname'],'size_hint_x': .2,'size_hint_y': None,'height': 25, 'font_size': '12sp'}},
                      {'cls': ListItemLabel,
                        'kwargs': {'text': rec['lastname'],'size_hint_x': .2,'size_hint_y': None,'height': 25,'font_size': '12sp'}},
                      {'cls': ListItemLabel,
                        'kwargs': {'text': rec['role'],'size_hint_x': .2,'size_hint_y': None,'height': 25,'font_size': '12sp'}},
                      {'cls': MyListItemButton,
                        'kwargs': {'text': u'edit','size_hint_x': .2,'size_hint_y': None,'height': 25,'font_size': '12sp', 'disabled': False,
                                  'on_press':self.find_user}},
                      {'cls': MyListItemButton,
                        'kwargs': {'text': u'delete','size_hint_x': .2,'size_hint_y': None,'height': 25,'font_size': '12sp','disabled': False,
                                  'on_press':self.delete_user}},
                      ]}

        self.list_adapter = ListAdapter(data=[],
                                        args_converter=self.args_converter,
                                        selection_mode='none',
                                        allow_empty_selection=True,
                                        cls=CompositeListItem)

        list_view = ListView(adapter=self.list_adapter)
        self.lv_users_box.add_widget(list_view)

        self.args_converter_order = lambda row_index, rec: \
        {'size_hint_y': None,
        'height': 30,
         'spacing':8,
        'is_selected':False,
        'cls_dicts': [{'cls':ListItemLabel,
                        'kwargs': {'text': str(row_index+1),'size_hint_x': .2,'size_hint_y': None,'height': 25, 'font_size': '12sp'}},
                      {'cls': ListItemLabel,
                        'kwargs': {'text': rec['table'],'size_hint_x': .2,'size_hint_y': None,'height': 25,'font_size': '12sp'}},
                      {'cls': ListItemLabel,
                        'kwargs': {'text': rec['status'],'size_hint_x': .2,'size_hint_y': None,'height': 25,'font_size': '12sp'}},
                      {'cls': ListItemLabel,
                        'kwargs': {'text': str(rec['total']),'size_hint_x': .2,'size_hint_y': None,'height': 25,'font_size': '12sp'}},
                      ]}

        self.order_adapter = ListAdapter(
            data=[],
            args_converter=self.args_converter_order,
            selection_mode='none',
            allow_empty_selection=True,
            cls=CompositeListItem)

        self.list_view_order = ListView(adapter=self.order_adapter)
        self.lv_orders_box.add_widget(self.list_view_order)

        self.choice_role_user()  #dropdown
예제 #7
0
    def enter_state(self, context=None):
        print 'ShowingListsScreen/enter_state'

        if not 'Lists' in self.statechart.app.sm.screen_names:

            # Convenience references:
            self.app = self.statechart.app

            view = BoxLayout(orientation='vertical', spacing=10)

            toolbar = BoxLayout(size_hint=(1.0, None), height=50)

            label = Label(text='Lists', color=[.8, .8, .8, .8], bold=True)
            toolbar.add_widget(label)

            button = Button(text='Search')
            button.bind(on_press=self.go_to_search)
            toolbar.add_widget(button)

            button = Button(text='Data')
            button.bind(on_press=self.go_to_data)
            toolbar.add_widget(button)

            button = Button(text='Detail')
            button.bind(on_press=self.go_to_detail)
            toolbar.add_widget(button)

            view.add_widget(toolbar)

            lists_view = GridLayout(cols=3, size_hint=(1.0, 1.0))

            lists_view.add_widget(
                ListView(adapter=self.statechart.fruit_categories_dict_adapter,
                         size_hint=(.2, 1.0)))

            lists_view.add_widget(
                ListView(adapter=self.statechart.fruits_dict_adapter,
                         size_hint=(.2, 1.0)))

            selected_fruit = \
                    self.statechart.fruits_dict_adapter.selection[0].text
            self.detail_view = FruitDetailView(fruit_name=selected_fruit,
                                               size_hint=(.6, 1.0))

            lists_view.add_widget(self.detail_view)

            view.add_widget(lists_view)

            self.create_adapter_bindings()

            screen = Screen(name='Lists')
            screen.add_widget(view)
            self.app.sm.add_widget(screen)

        if self.app.sm.current != 'Lists':
            self.app.sm.current = 'Lists'
예제 #8
0
    def connect_popup(self):
        popup = Popup(title='Connecter deux sommets',
                      size_hint=(0.9, 0.9),
                      auto_dismiss=False)
        bl = BoxLayout(orientation='vertical')

        confirm_button = Button(text="Confirmer")
        confirm_button.disabled = True

        gl_inputs = GridLayout(cols=2)

        gl_inputs.add_widget(Label(text="Sommet 1"))
        gl_inputs.add_widget(Label(text="Sommet 2"))

        list_adapter1 = ListAdapter(data=[
            str(i + 1) + "- " + self.g.get_sommets()[i].nom
            for i in range(len(self.g.get_sommets()))
        ],
                                    cls=ListItemButton,
                                    sorted_keys=[])
        list_adapter1.bind(on_selection_change=lambda a: self.selection_change(
            list_adapter1, 0, list_adapter2, confirm_button))
        list_view1 = ListView(adapter=list_adapter1)

        gl_inputs.add_widget(list_view1)

        list_adapter2 = ListAdapter(data=[
            str(i + 1) + "- " + self.g.get_sommets()[i].nom
            for i in range(len(self.g.get_sommets()))
        ],
                                    cls=ListItemButton,
                                    sorted_keys=[])
        list_adapter2.bind(on_selection_change=lambda a: self.selection_change(
            list_adapter2, 1, list_adapter1, confirm_button))
        list_view2 = ListView(adapter=list_adapter2)

        gl_inputs.add_widget(list_view2)

        bl.add_widget(gl_inputs)

        confirm_button.bind(on_press=lambda a: self.connect(popup))
        cancel_button = Button(text="Annuler")
        cancel_button.bind(on_press=lambda a: popup.dismiss())
        bl.add_widget(confirm_button)
        bl.add_widget(cancel_button)

        popup.content = bl
        popup.open()
예제 #9
0
파일: gzuro.py 프로젝트: dduong42/gzuro
    def __init__(self, *, choices, default):
        self._selection_callbacks = []

        class _ListAdapter(ListAdapter):
            selected = StringProperty('')

            def on_selection(_self, item, value):
                if value:
                    _self.selected = value[0].text
                    for callback in self._selection_callbacks:
                        callback()

            def select(self, choice):
                v = self.get_view(self.data.index(choice))
                if v is not None:
                    self.handle_selection(v)

        self._adapter = _ListAdapter(
            data=choices,
            args_converter=_args_converter,
            cls=ListItemButton,
            selection_mode='single',
            allow_empty_selection=False,
        )
        self._element = ListView(adapter=self._adapter)
        self._adapter.select(default)
예제 #10
0
파일: plist.py 프로젝트: wushin/manachat
    def __init__(self, **kwargs):
        super(PlayersList, self).__init__(**kwargs)

        player_args_coverter = lambda row_index, nick: {
            "nick": nick,
            "size_hint_y": None,
            "height": "30dp",
            "pos_hint_y": 0.9
        }

        list_adapter = ListAdapter(data=["Ginaria", "Celestia"],
                                   args_converter=player_args_coverter,
                                   selection_mode='single',
                                   allow_empty_selection=True,
                                   cls=PlayersListItem)

        list_view = ListView(adapter=list_adapter,
                             size_hint=(1.0, 1.0),
                             pos_hint={'center_x': 0.5})

        def data_changed(instance, value):
            list_adapter.data = value

        self.bind(items=data_changed)

        self.add_widget(list_view)
예제 #11
0
    def __init__(self, screen, **kwargs):
        super(SevenTest, self).__init__(screen, **kwargs)
        self.desc = "Odečítání sedmiček"
        self.instruction = "Odečtěte od čísla 100 číslo 7 a pak pokračujte v odčítání 7."
        self.instruction_audio = "sounds/ins7.mp3"
        self.points = 0
        self.pomoc1 = 0
        self.pomoc2 = 0
        self.pomoc3 = 0
        self.pomoc4 = 0
        self.pomoc5 = 0
        self.test_field = GridLayout(cols=1,
                                     size_hint=(.2, .8),
                                     pos_hint={"x": .4})
        self.prvni = TextInput(hint=u"první", font_size="60px", size_hint_y=.6)
        self.druhy = TextInput(hint=u"druhy", font_size="60px", size_hint_y=.6)
        self.treti = TextInput(hint=u"třetí", font_size="60px", size_hint_y=.6)
        self.ctvrty = TextInput(hint=u"čtvrtý",
                                font_size="60px",
                                size_hint_y=.6)
        self.paty = TextInput(hint=u"pátý", font_size="60px", size_hint_y=.6)
        self.number_list = ListView(item_strings=[])

        self.prvni.bind(text=self.prvni_callback)
        self.druhy.bind(text=self.druhy_callback)
        self.treti.bind(text=self.treti_callback)
        self.ctvrty.bind(text=self.ctvrty_callback)
        self.paty.bind(text=self.paty_callback)

        with self.canvas.before:
            Color(0, 0, 0, 1)
            self.rec = Rectangle(size=Window.size)
예제 #12
0
    def __init__(self, **kwargs):

        def items_args_converter(row_index, rec):
            return {
                'text': rec.name,
                'value': str(rec.value),
                'unit': rec.unit,
                'size_hint_y': None, 'height': 20,
                'cls_dicts': [{
                    'cls': ListItemButton,
                    'kwargs': {
                        'text': rec.name,
                        'size_hint_x': 0.6,
                        'is_representing_cls': True}},
                    {'cls': ListItemLabel,
                     'kwargs': {'text': str(rec.value)[:6], 'size_hint_x': 0.3}},
                    {'cls': ListItemLabel,
                     'kwargs': {'text': rec.unit, 'size_hint_x': 0.1}}]}

        self.list_adapter = ListAdapter(
            data={},
            args_converter=items_args_converter,
            selection_mode='single',
            allow_empty_selection=True,
            propagate_selection_to_data=True,
            cls=CompositeListItem)
        self.list_adapter.bind(on_selection_change=self.reg_selection_changed)
        super(RegDictView, self).__init__(**kwargs)
        self.add_widget(ListView(adapter=self.list_adapter))
        self.slider_view = RegSliderView(reg_index=0, list_adapter=self.list_adapter)
        self.add_widget(self.slider_view)
예제 #13
0
 def __init__(self, manager, **kwargs):
     super(BoxLayoutEnterSectionName, self).__init__(**kwargs)
     # GUI for first screen where song name is entered
     self.orientation = "horizontal"
     self.pos_hint = {"y": .85}
     self.textinput_song_name = TextInput(
         text="Enter Song Section Name (Make each name unique)",
         size_hint=(.333, .15),
         pos_hint={
             'center_x': .3,
             "y": 0
         })
     self.button_confirm_section_name = custom_button.EloButton(
         text="Confirm Section Name",
         size_hint=(.333, .15),
         pos_hint={
             'center_x': .6,
             "y": 0
         },
         text_size=(180, 50),
         valign="middle")
     self.button_confirm_section_name.bind(
         on_release=self.confirm_section_name)
     self.array_created_section = ["Created Sections"]
     self.listview_created_section = ListView(
         item_strings=self.array_created_section,
         size_hint=(.333, .15),
         pos_hint={
             'center_x': .8,
             "y": 0
         })
     self.add_widget(self.textinput_song_name)
     self.add_widget(self.button_confirm_section_name)
     self.add_widget(self.listview_created_section)
     self.manager = manager
예제 #14
0
    def init(self, simulate=False, time_interval=1, **kwargs):
        """
        Initializes Datamodel

        """
        self.minval = kwargs.get("minval", self.minval)
        self.maxval = kwargs.get("maxval", self.maxval)
        self.blockname = kwargs.get("blockname", self.blockname)
        self.clear_widgets()
        self.simulate = simulate
        self.time_interval = time_interval
        dict_adapter = DictAdapter(data={},
                                   args_converter=self.arg_converter,
                                   selection_mode='single',
                                   allow_empty_selection=True,
                                   cls=CompositeListItem
                                   )

        # Use the adapter in our ListView:
        self.list_view = ListView(adapter=dict_adapter)
        self.add_widget(self.list_view)
        self.dispatcher = UpdateEventDispatcher()
        self._parent = kwargs.get('_parent', None)
        self.simulate_timer = BackgroundJob(
            "simulation",
            self.time_interval,
            self._simulate_block_values
        )
예제 #15
0
    def __init__(self, *args, **kwargs):
        super(EditProducts, self).__init__(*args, **kwargs)
        args_converter_edit = lambda row_index, rec: \
        {'size_hint_y': None,
        'height': 30,
        'spacing':8,
        'is_selected':True,
        'text':rec['text'],
        'active':rec['active'],

        'cls_dicts':
                 [{'cls':ListItemLabel,
                    'kwargs': {'text':rec['text'],
                               'color': [0,0,0, 0.95],
                               'size_hint_x': .2,'size_hint_y': None,'height': 25, 'font_size': '12sp'}},
                 {'cls':MyCheckBox,
                   'kwargs': {'active':rec['active'],
                              'size_hint_x': .2,'size_hint_y': None,'height': 25, 'font_size': '12sp',
                              'on_press': self.on_active}}
        ]}
        self.choices_adapter = ListAdapter(
            data=[],  #edit_adapter
            args_converter=args_converter_edit,
            selection_mode='none',
            allow_empty_selection=True,
            cls=CompositeListItem)
        self.list_view_choices = ListView(adapter=self.choices_adapter)
        self.choices_oprop.add_widget(self.list_view_choices)
예제 #16
0
    def test_list_adapter_selection_mode_single(self):
        list_adapter = ListAdapter(data=fruit_data_items,
                                   args_converter=self.args_converter,
                                   selection_mode='single',
                                   propagate_selection_to_data=True,
                                   allow_empty_selection=True,
                                   cls=ListItemButton)
        list_view = ListView(adapter=list_adapter)

        # The reason why len(selection) == 0 here is because ListView,
        # at the end of its __init__(), calls check_for_empty_selection()
        # and does NOT trigger the initial selection, because we set
        # allow_empty_selection = True.
        self.assertEqual(len(list_adapter.selection), 0)
        list_adapter.check_for_empty_selection()

        # Nothing should have changed by that call, because still we have
        # allow_empty_selection = True, so no action in that check.
        self.assertEqual(len(list_adapter.selection), 0)

        # Still no selection, but triggering a selection should make len = 1.
        # So, first we need to select the associated data item.
        self.assertEqual(fruit_data_items[0].name, 'Apple')
        fruit_data_items[0].is_selected = True
        apple = list_view.adapter.get_view(0)
        self.assertEqual(apple.text, 'Apple')
        self.assertTrue(apple.is_selected)
        self.assertEqual(len(list_adapter.selection), 1)
예제 #17
0
    def build(self):
        args_converter = lambda row_index, rec: \
            {'text': rec['text'],
            'size_hint_y': None,
            'height': 25,
            'cls_dicts': [{'cls': ListItemButton,
                            'kwargs': {'text': rec['text']}},
                        {'cls': ListItemLabel,
                            'kwargs': {'text': "Middle-{0}".format(rec['text']),
                                    'is_representing_cls': True}},
                        {'cls': ListItemButton,
                            'kwargs': {'text': rec['text']}}]}

        item_strings = ["{0}".format(index) for index in range(100)]

        integers_dict = \
            {str(i): {'text': str(i), 'is_selected': False} for i in range(100)}

        dict_adapter = DictAdapter(sorted_keys=item_strings,
                                   data=integers_dict,
                                   args_converter=args_converter,
                                   selection_mode='single',
                                   allow_empty_selection=False,
                                   cls=CompositeListItem)

        list_view = ListView(adapter=dict_adapter)
        return list_view
예제 #18
0
def lookup_item(self, item):

    if not item or not item.get('uri'):
        return

    uri = item['uri']
    logger.debug('Browsing on URI: %s', uri)

    info = self.mopidy.library.browse(uri=uri, timeout=40)
    info_tracks = format_nice(info, format='browse').split('\n')

    title = '[%s] %s  (%d items)' % (item['type'], item['name'], len(info_tracks))

    lv = ListView(item_strings=info_tracks, halign='left')
    btn = Button(text='Close', size_hint_y=None, height=50)
    cnt = BoxLayout(orientation='vertical')
    cnt.add_widget(lv)
    cnt.add_widget(btn)

    popup = Popup(title=title,
                    content=cnt,
                    size_hint=(0.8, 0.8),
                    title_size=22,)

    btn.bind(on_press=popup.dismiss)
    popup.open()
예제 #19
0
def videoArchiveBtnCallback(self):
        setDisplaySleepTime(9999,1)
        data = getVideoList()
        listData = []
        for d in data:
                listData.append(d.id + "  " + d.time.strftime('%d. %b - %H:%M:%S'))

        list_adapter = ListAdapter(data=listData,
                           cls=VideoListItemButton,
                           selection_mode='single',
                           allow_empty_selection=False)
        player = VideoPlayer(source=data[0].path, state='play', options={'allow_stretch': True})
        root = GridLayout(cols=2)
        popup = Popup(title='Video archív  -  '+data[0].time.strftime('%d. %b - %H:%M:%S'),
                    content=root,
                    size_hint=(1, 1))
        list_adapter.bind(on_selection_change=partial(videoArchiveItemSelected,player, popup))
        
        
        layout1 = BoxLayout(orientation='vertical')
        layout2 = BoxLayout(orientation='vertical')
        videoList = ListView(adapter=list_adapter)
        btn = Button(text='Zatvoriť', size_hint_y=0.2)
        layout1.add_widget(videoList)
        layout2.add_widget(player)
        layout2.add_widget(btn)
        root.add_widget(layout1)
        root.add_widget(layout2)
        
        btn.bind(on_press=partial(videoArchiveExitBtnCallback,popup))
        popup.open()
예제 #20
0
파일: GUIMenu.py 프로젝트: renatotnk/UDESC
    def listaAdoc(self, a):
        box = GridLayout(cols=1, rows=3)
        box.add_widget(Label(text='Lista de Adoções', size_hint_y=0.15))
        adocoes = self.dados.getAdocoes()
        dados = []
        for ad in adocoes:
            adInfos = ad.getInfos()
            for dog in self.dados.doguinhos:
                if dog.getId() == adInfos[0]:
                    nome = dog.getNome()
            for tutor in self.dados.tutores:
                if tutor.getId() == adInfos[1]:
                    nome_tutor = tutor.getNome()
            dados.append("ID do cão: {0}   Nome do cão: {1}".format(
                adInfos[0], nome))
            dados.append("ID do tutor: {0}   Nome do tutor: {1}".format(
                adInfos[1], nome_tutor))
            dados.append("Data de adoção: {0}".format(adInfos[2]))
            dados.append('')
            dados.append('')

        simple_list_adapter = SimpleListAdapter(data=dados, cls=Label)
        list_view1 = ListView(adapter=simple_list_adapter)
        box.add_widget(list_view1)
        botao = Button(text='Fechar', size_hint_y=0.2)
        box.add_widget(botao)
        self.popupListaAdoc = Popup(title='Lista de Adoções',
                                    content=box,
                                    size_hint=(None, None),
                                    size=(600, 600))
        botao.bind(on_press=self.popupListaAdoc.dismiss)

        self.popupListaAdoc.open()
예제 #21
0
파일: GUIMenu.py 프로젝트: renatotnk/UDESC
    def listaTut(self, a):
        box = GridLayout(cols=1, rows=3)
        box.add_widget(Label(text='Lista de Tutores', size_hint_y=0.15))
        tutores = self.dados.getTutores()
        dados = []
        for tut in tutores:
            tutInfos = tut.getInfos()
            dados.append("ID: {0}   Nome: {1}   CPF: {2}".format(
                tutInfos[0], tutInfos[1], tutInfos[3]))
            telefone = tutInfos[4]
            telefone = telefone[:-4] + "-" + telefone[-4:]
            dados.append("Endereço: {0}   Telefone: {1}".format(
                tutInfos[2], telefone))
            dados.append('')
            dados.append('')

        simple_list_adapter = SimpleListAdapter(data=dados, cls=Label)
        list_view1 = ListView(adapter=simple_list_adapter)
        box.add_widget(list_view1)
        botao = Button(text='Fechar', size_hint_y=0.2)
        box.add_widget(botao)
        self.popupListaTutores = Popup(title='Lista de Tutores',
                                       content=box,
                                       size_hint=(None, None),
                                       size=(600, 600))
        botao.bind(on_press=self.popupListaTutores.dismiss)

        self.popupListaTutores.open()
예제 #22
0
    def __init__(self, **kwargs):
        super(MapChoice, self).__init__(**kwargs)

        self.root = Builder.load_string(kv)
        self.map_items = kwargs.get('map_items', [])

        list_item_args_converter = \
                lambda row_index, selectable: {'name': selectable.name,
                                               'max_zoom': selectable.max_zoom,
                                               'description': selectable.description,
                                               'size_hint_y': None,
                                               'is_selected': selectable.is_selected,
                                               'select_change_callback': selectable.on_selection_change,
                                               'calibration_callback': selectable.on_calibration,
                                               'index': row_index}

        map_list_adapter = \
            ListAdapter(data=self.map_items,
                        args_converter=list_item_args_converter,
                        selection_mode='single',
                        allow_empty_selection=False,
                        template='CustomListItem')

        list_view = ListView(adapter=map_list_adapter)

        # map_list_adapter.bind(on_selection_change=self.callback_function)

        self.add_widget(list_view)
예제 #23
0
    def on_pre_enter(self, *args):
        members = list(self.network.hashgraph.known_members.values())
        members.sort(key=lambda x: x.formatted_name)
        self.data = [{'member': m, 'is_selected': False} for m in members if m != self.network.me]

        def args_converter(row_index, rec):
            return {
                'text': rec['member'].formatted_name,
                'height': 40
            }

        list_adapter = ListAdapter(data=self.data,
                                   args_converter=args_converter,
                                   cls=self.MemberListItemButton,
                                   selection_mode='single',
                                   propagate_selection_to_data=True,
                                   allow_empty_selection=True)

        def selection_change_callback(adapter):
            if len(adapter.selection) == 1:
                self.ids.send_button.disabled = False

        list_adapter.bind(on_selection_change=selection_change_callback)

        self.list_view = ListView(adapter=list_adapter, size_hint_x=0.8)

        self.ids.receiver_layout.add_widget(self.list_view)
예제 #24
0
    def __init__(self, **kwargs):
        kwargs['cols'] = 2
        super(MainView, self).__init__(**kwargs)

        list_view = ListView(item_strings=[str(index) for index in range(100)])

        self.add_widget(list_view)
    def __init__(self, **kwargs):
        super(MainView, self).__init__(**kwargs)

        data_items = []
        data_items.append(DataItem())
        data_items.append(DataItem())
        data_items.append(DataItem())

        list_item_args_converter = lambda row_index, obj: {
            'text': obj.name,
            'size_hint_y': None,
            'height': 25
        }

        self.list_adapter = \
                ListAdapter(data=data_items,
                            args_converter=list_item_args_converter,
                            selection_mode='single',
                            propagate_selection_to_data=False,
                            allow_empty_selection=False,
                            cls=ListItemButton)

        self.list_view = ListView(adapter=self.list_adapter)

        self.add_widget(self.list_view)

        self.toggle = 'adding'

        Clock.schedule_interval(self.update_list_data, 1)
예제 #26
0
    def __init__(self, items, **kwargs):
        kwargs['cols'] = 2
        kwargs['size_hint'] = (1.0, 1.0)
        super(MasterDetailView, self).__init__(**kwargs)

        list_item_args_converter = \
                lambda row_index, rec: {'text': rec['name'],
                                        'size_hint_y': None,
                                        'height': 25}

        dict_adapter = DictAdapter(sorted_keys=sorted(fruit_data.keys()),
                                   data=fruit_data,
                                   args_converter=list_item_args_converter,
                                   selection_mode='single',
                                   allow_empty_selection=False,
                                   cls=ListItemButton)

        master_list_view = ListView(adapter=dict_adapter, size_hint=(.3, 1.0))

        self.add_widget(master_list_view)

        detail_view = FruitDetailView(
            fruit_name=dict_adapter.selection[0].text, size_hint=(.7, 1.0))

        dict_adapter.bind(on_selection_change=detail_view.fruit_changed)
        self.add_widget(detail_view)
    def build(self):
        # screen manager steup
        sm = ScreenManager()

        # main menu setup
        main_menu = 

        # define Spell screen
        spell_layout = BoxLayout()
        # add big_layout to ScreenManger
        sm.add_widget(spell_layout)
        left_box = BoxLayout(orientation='vertical', spacing=10, size_hint=(.3, 1))
        right_box = StackLayout(size_hint=(.7, 1))
        left_top_box = ListView(size_hint=(1, .8))
        left_bottom_box = BoxLayout(size_hint=(1, .2))

        rb = Label(text='right box')
        ltb = Label(text='left top box')
        btn_rest = Button(text='Rest')
        btn_main = Button(text='Main Menu')
        btn_quit = Button(text='Quit')

        spell_layout.add_widget(left_box)
        spell_layout.add_widget(right_box)

        left_box.add_widget(left_top_box)
        left_box.add_widget(left_bottom_box)

        right_box.add_widget(rb)
        left_top_box.add_widget(ltb)
        left_bottom_box.add_widget(btn_rest)
        left_bottom_box.add_widget(btn_main)
        left_bottom_box.add_widget(btn_quit)

        return sm
예제 #28
0
class DeleteProfileScreen(Screen):
    user_dict = {}
    userKey = ListProperty()
    users_list = ListView()
    sel_usr = StringProperty()

    def __init__(self, **kwargs):
        super(DeleteProfileScreen, self).__init__(**kwargs)
        self.sel_usr = '******'

    def on_enter(self, *args):
        print('on_enter called for delete profile screen')
        del self.userKey[:]
        self.user_dict.clear()
        self.userKey = fn.reload_dictionary(self.user_dict)
        if self.userKey != None:
            list_adapter = ListAdapter(data=self.userKey, selection_mode='single', allow_empty_selection=False, cls=myListItemButton)
        self.sel_usr = self.userKey[0]
        self.users_list.adapter = list_adapter
        self.users_list.adapter.bind(on_selection_change=self.callback)
        self.users_list._trigger_reset_populate()

    def callback(self, adapter):
        if len(adapter.selection) == 0:
            self.sel_usr = '******'
            print "No selected item"
        else:
            print adapter.selection[0].text
            self.sel_usr = adapter.selection[0].text
예제 #29
0
    def view_student(self):
        self.update_info()
        if self.grade12s_list.adapter.selection:
            # getting selected item name
            selection = self.grade12s_list.adapter.selection[0].text

            # creating layout for tab
            content = GridLayout(cols=2)
            col1 = GridLayout(cols=1)
            col2 = GridLayout(cols=1)
            col1.add_widget(Label(text="Student Name: " + selection))
            for i in self.grade12_list:
                if i[1] == selection:
                    col1.add_widget(Label(text="Grade: " + i[2]))
                    col1.add_widget(Label(text="Student ID: " + str(i[4])))
                    col1.add_widget(
                        Label(text="Accumulated Points: " + str(i[3])))
                    simple_list_adapter = SimpleListAdapter(
                        data=i[6].split('.')[1:], cls=Label)

            col2.add_widget(
                Label(text='Student Rewards History',
                      size_hint_y=None,
                      height=40))
            activity_history = ListView(adapter=simple_list_adapter)
            col2.add_widget(activity_history)
            content.add_widget(col1)
            content.add_widget(col2)
            popup = Popup(title=selection,
                          content=content,
                          size_hint=(None, None),
                          size=(800, 500))
            popup.open()
예제 #30
0
    def start_app(self):
        labels = [LabelModel() for _ in range(100)]

        self.image = Factory.MainImage(ImageModel())
        self.root.ids.image_box.add_widget(self.image)

        self.exif = Factory.GetExifData(ButtonModel(image=self.image, labels=labels))
        self.root.ids.button_box.add_widget(self.exif)
        right = Factory.RotateRight(self.exif.model)
        self.root.ids.button_box.add_widget(right)
        left = Factory.RotateLeft(self.exif.model)
        self.root.ids.button_box.add_widget(left)
        loc = Factory.GetLocation(self.exif.model)
        self.root.ids.button_box.add_widget(loc)
        next = Factory.NextImage(self.exif.model)
        self.root.ids.cycle_box.add_widget(next)
        prev = Factory.PreviousImage(self.exif.model)
        self.root.ids.cycle_box.add_widget(prev)
        get = Factory.OpenImage(self.exif.model)
        self.root.ids.button_box.add_widget(get)

        lab = Factory.ExifLabel(LabelModel())
        self.root.ids.exif_container.add_widget(lab)

        list_adapter = SimpleListAdapter(
            data=labels,
            args_converter=lambda row, model: {'model': model,
                                               'size_hint_y': None,
                                               'height':100},
            cls=Factory.ExifTags)
        self.root.ids.exif_container.add_widget(ListView(adapter=list_adapter))