예제 #1
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])
예제 #2
0
    def create_adapters(self):
        list_item_args_converter = \
                lambda row_index, rec: {'text': rec['name'],
                                        'size_hint_y': None,
                                        'height': 25}

        categories = sorted(fruit_categories.keys())

        self.fruit_categories_dict_adapter = DictAdapter(
            sorted_keys=categories,
            data=fruit_categories,
            args_converter=list_item_args_converter,
            selection_mode='single',
            allow_empty_selection=False,
            cls=ListItemButton)

        fruits = fruit_categories[categories[0]]['fruits']

        self.fruits_dict_adapter = DictAdapter(
            sorted_keys=fruits,
            data=fruit_data,
            args_converter=list_item_args_converter,
            selection_mode='single',
            allow_empty_selection=False,
            cls=ListItemButton)
예제 #3
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])
예제 #4
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)
예제 #5
0
    def __init__(self, items, **kwargs):
        kwargs['cols'] = 2
        super(MasterDetailView, self).__init__(**kwargs)

        list_item_args_converter = \
                lambda row_index, rec: {'text': rec[1],
                                        'size_hint_y': None,
                                        'height': 25,
										'id' : str(rec[0])}

        dict_adapter = DictAdapter(sorted_keys=[i[0] for i in myquery.query_result],
                                   data=myquery.q_result_dict,
                                   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 = PageDetailView(
                page_txt=dict_adapter.selection[0].text,
				page_id=dict_adapter.selection[0].id,
                size_hint=(.7, 1.0),
				tname=myquery.q_table)

        dict_adapter.bind(on_selection_change=detail_view.page_changed)
        self.add_widget(detail_view)
예제 #6
0
    def __init__(self, items, **kwargs):
        kwargs['cols'] = 2
        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)
예제 #7
0
파일: gui.py 프로젝트: mugsy-mcgeee/augr
class PlayerListView(ModalView):
    player_adapter = ObjectProperty(None)
    match_perf = ObjectProperty(None)

    def __init__(self, **kwargs):
        super(PlayerListView, self).__init__(**kwargs)

        # filled in later with call to reload()
        self.player_adapter = DictAdapter(sorted_keys=[],
                                          data={},
                                          args_converter=self._player_converter,
                                          selection_mode='multiple',
                                          propagate_selection_to_data=True,
                                          template='CustomListItem')

        self.d2rp = None # set by parent

    def _player_converter(self, idx, rec):
        return {'player_label': rec['player_label'],
                'is_selected': rec['is_selected'],
                'size_hint_y': None,
                'height': 25}

    def reload(self):
        if not self.d2rp:
            return

        hero_len = max([len(dotalocal.hero[h['hero']]) for h in self.d2rp.players])

        p_str = {}
        for i,hero in enumerate(self.d2rp.players):
            hero_s = dotalocal.hero[hero['hero']]
            player = dotalocal.player(hero['player'])
            p_str[str(i)] = { 
                'player_label': ' {} | {}'.format(hero_s.ljust(hero_len), player),
                'is_selected': False }

        self.player_adapter = DictAdapter(sorted_keys=[i for i in range(len(p_str))],
                                          data=p_str,
                                          args_converter=self._player_converter,
                                          selection_mode='multiple',
                                          propagate_selection_to_data=True,
                                          template='CustomListItem')

        self.player_adapter.bind(on_selection_change=self.selection_changed)

    def selection_changed(self, *args):
        self.match_perf.redraw()

    def get_selected(self):
        selected = []
        for btn in self.player_adapter.selection:
            hero_s = btn.text.split('|')[0].strip()
            #for pl in self.d2rp.players:
            for pl in self.match_perf.match.all_players():
                if dotalocal.hero[pl['hero']] == hero_s:
                    selected.append(pl)
                    break
        return selected
예제 #8
0
    def __init__(self, **kwargs):
        kwargs['cols'] = 3
        kwargs['size_hint'] = (1.0, 1.0)
        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)
예제 #9
0
    def on_enter(self):
        """ Repopulate the listview """
        info = self.playlist.get_info
        data = {
            str(i): {
                'text': item[0],
                'source': item[1],
                'album': info(item[0])["album"],
                'track': info(item[0])["file"],
                'is_selected': bool(i == self.playlist.current)
            }
            for i, item in enumerate(self.playlist.queue)
        }

        def args_converter(row_index, item):
            return {
                'text':
                item['text'],
                'size_hint_y':
                None,
                'height':
                "50dp",
                'cls_dicts': [{
                    'cls': ZenListImage,
                    'kwargs': {
                        'source': item['source'],
                        'size_hint_x': 0.1,
                        'row_index': row_index
                    }
                }, {
                    'cls': ZenListButton,
                    'kwargs': {
                        'text': item['track'],
                        'is_representing_cls': True,
                        'size_hint_x': 0.55,
                        'row_index': row_index
                    }
                }, {
                    'cls': ZenListButton,
                    'kwargs': {
                        'text': item['album'],
                        'size_hint_x': 0.35,
                        'row_index': row_index
                    }
                }]
            }

        dict_adapter = DictAdapter(
            sorted_keys=[str(i) for i in range(len(self.playlist.queue))],
            data=data,
            selection_mode='single',
            args_converter=args_converter,
            propagate_selection_to_data=True,
            cls=ZenListItem)

        self.listview.adapter = dict_adapter
        dict_adapter.bind(on_selection_change=self.selection_changed)
    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)
예제 #11
0
    def __init__(self, **kwargs):

        super(PlaylistLayout, self).__init__(**kwargs)

        integers_dict = {
            str(i): {
                'source': basename(self.playlist[i][0]),
                'size': '%dx%d' % tuple(self.playlist[i][3]) \
                        if self.playlist[i][0].lower().endswith('.yuv') else '',
                'format': self.playlist[i][1].upper() \
                          if self.playlist[i][0].lower().endswith('.yuv') else '',
                'playlist': self.playlist[i],
                'is_selected': False
            } for i in xrange(len(self.playlist))
        }
        args_converter = lambda row_index, rec: {
            'text':
            rec['source'],
            'size_hint_y':
            None,
            'height':
            25,
            'cls_dicts': [{
                'cls': ListItemButton,
                'kwargs': {
                    'text': rec['source']
                }
            }, {
                'cls': ListItemButton,
                'kwargs': {
                    'text': rec['size'],
                    'size_hint_x': None,
                    'width': 100
                }
            }, {
                'cls': ListItemButton,
                'kwargs': {
                    'text': rec['format'],
                    'size_hint_x': None,
                    'width': 70
                }
            }]
        }
        item_strings = [
            "{0}".format(index) for index in xrange(len(self.playlist))
        ]
        dict_adapter = DictAdapter(sorted_keys=item_strings,
                                   data=integers_dict,
                                   args_converter=args_converter,
                                   selection_mode='single',
                                   allow_empty_selection=False,
                                   cls=CompositeListItem)
        dict_adapter.bind(selection=self.setter('selection'))
        list_view = ListView(adapter=dict_adapter)
        self.layout.add_widget(list_view)
예제 #12
0
    def fill_er_up(self, unused=None):
        dc = "deselected_color"
        sc = "selected_color"
        args_converter = \
            lambda row_index, rec: \
                {"size_hint_y": None,
                 "height": 25,
                 #"height": rec["height"],
                 #"background_color": rec["status_colour"],
                 "cls_dicts": [
                       {"cls": MyListItemButton,
                           "kwargs": {"text": rec["id"]}}, #, dc: rec[dc]}},
                       {"cls": MyListItemButton,
                           "kwargs": {"text": rec["black"]}},
                       {"cls": MyListItemButton,
                           "kwargs": {"text": rec["white"]}},
                       {"cls": MyListItemButton,
                           "kwargs": {"text": rec["date"]}},
                       {"cls": MyListItemButton,
                           "kwargs": {"text": rec["size"]}},
                       {"cls": MyListItemButton,
                           "kwargs": {"text": rec["rules"]}},
                       ]}

        # TODO: Another hack - parent.parent
        gm = self.parent.parent.gm
        pm = gm.get_players_mgr()
        if self.screen.show_finished:
            games = gm.get_recently_finished()
        else:
            games = gm.get_all_unfinished_preserved()

        # TODO: The "if" is a hack
        games_dict = { g.game_id: game_data(g, pm) for g in games if g }

        self.item_strings = ["{0}".format(g_id) for g_id in games_dict.iterkeys() ]

        dict_adapter = DictAdapter(data=games_dict,
                                   args_converter=args_converter,
                                   selection_mode="single",
                                   allow_empty_selection=False, # Not working?
                                   cls=TwoLevelCompositeListItem)

        dict_adapter.bind(
            on_selection_change=self.changed_selection)

        self.adapter = dict_adapter

        # Use the adapter in our ListView:
        list_view = ListView(adapter=dict_adapter)

        self.add_widget(list_view)
        self.view = list_view
예제 #13
0
    def __init__(self, **kwargs):
        kwargs['cols'] = 1
        kwargs['col_default_width'] = 100
        kwargs['row_default_height'] = 50
        super(GroupDeviceList, self).__init__(**kwargs)

        try:
            if RAW_DEVICES:
                devices = {
                    d.id: {
                        'name': d.name,
                        'status': d.status
                    }
                    for d in RAW_DEVICES
                }
                list_item_args_converter = lambda row_index, rec: {
                    'text': rec['name'],
                    'is_selected': False,
                    'size_hint_y': None,
                    'height': 60
                }

                dict_adapter = DictAdapter(
                    sorted_keys=[i for i in range(len(RAW_DEVICES))],
                    data=devices,
                    args_converter=list_item_args_converter,
                    selection_mode='single',
                    allow_empty_selection=False,
                    template='CustomGroupDeviceItem')
                list_view = ListView(adapter=dict_adapter)
                self.add_widget(list_view)
        except Exception as e:
            print 'Error occurred in GroupDeviceList: ', str(e)
예제 #14
0
	def __init__(self, **kwargs):
		kwargs['cols'] = 1
		kwargs['col_default_width'] = 100
		kwargs['row_default_height'] = 50
		super(DeviceList, self).__init__(**kwargs)

		try:
			if RAW_DEVICES:
				devices = { d['_id']: {'name': d['name'], 'status': d['status']} for d in RAW_DEVICES}
				for d in RAW_DEVICES:
					if d['cert'] != '':
						path = os.getcwd() + '/../dependency/certificate/' + str(d['_id']) + '.crt'
						if not os.path.lexists(path):
							cert = open(path, 'wb')
							cert.write(d['cert'])
							cert.close()



				list_item_args_converter = lambda row_index, rec: {'text': rec['name'],
																	'is_selected': False,
																	'size_hint_y': None,
																	'height': 60}

				dict_adapter = DictAdapter(sorted_keys=[i for i in range(len(RAW_DEVICES))],
											data=devices,
											args_converter=list_item_args_converter,
											selection_mode='single',
											allow_empty_selection=False,
											template='CustomListItem')
				list_view = ListView(adapter=dict_adapter)
				self.add_widget(list_view)
		except Exception as e:
			print 'Error occurred in DeviceList: ', str(e)
예제 #15
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
        )
예제 #16
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
예제 #17
0
파일: main.py 프로젝트: herrfeder/PyThek
def create_episode_view(media_data, objref):
    objref.episode_item_args_converter = \
                    lambda row_index, rec: {'name': rec['name'],
                                            'url': rec['url'],
                                            'thumb': rec['thumb'][1],
                                            'length': rec['length'],
                                            'number': rec['number'],
                                            'channel': rec['channel'],
                                            'size_hint_y': 5,
                                            'height': 80,
                                            'width': 100}

    categories = sorted(media_data.keys())
    objref.episodes_list_adapter = \
        DictAdapter(
            sorted_keys=categories,
            data=media_data,
            args_converter=objref.episode_item_args_converter,
            selection_mode='single',
            allow_empty_selection=False,
            cls=ThumbnailedGridEpisode)



    objref.episodes_list_view = \
       ListView(adapter=objref.episodes_list_adapter,
                padding=2,
                size_hint=(.4,1.0))
예제 #18
0
    def dump_data(self, **kwargs):
        from lvargsconv import args_convertor
        items = {str(i): kwargs['data'][i] for i in range(len(kwargs['data']))}
        print items
        dict_adapter = DictAdapter(
            data=items,
            args_converter=args_convertor,
            selection_mode='single',
            allow_empty_selection=True,
            cls=CustomListItem)

        dict_adapter.bind(on_selection_change=self.on_select)

        self.clear_widgets()
        self.add_widget(ListView(adapter=dict_adapter))
        pass
예제 #19
0
    def __init__(self, annot_model, graph, editor_widget, **kwargs):

        super(ObjectGraphRenderer, self).__init__(**kwargs)
        logging.info('ObjectGraphRenderer: initializing, with {0} edges'
                     ' in the graph.'.format(len(graph.edges)))

        self.model = annot_model
        self.graph = graph

        self.size = editor_widget.size
        self.pos = editor_widget.pos

        editor_widget.bind(size=self._update_size)
        editor_widget.bind(pos=self._update_pos)

        self.edge_adapter = DictAdapter(
            data=self.graph.edges,
            args_converter=self.edge_converter,
            selection_mode='multiple',
            cls=EdgeView,
        )

        self.view = EdgeListView(adapter=self.edge_adapter,
                                 size_hint=(None, None),
                                 size=self.size,
                                 pos=self.pos)
        self.edge_adapter.bind(
            on_selection_change=self.view.broadcast_selection)

        self.views_mask = dict()

        # Hacking the ListView
        # logging.debug('View children: {0}'.format(self.view.children))
        self.view.remove_widget(self.view.children[0])
        self.view.container = FloatLayout(pos=self.pos, size=self.size)
        self.view.add_widget(self.view.container)

        Window.bind(on_key_down=self.view.on_key_down)
        Window.bind(on_key_up=self.view.on_key_up)

        # Automating the redraw pipeline:
        #  - when edge data changes, fill in adapter data,
        self.graph.bind(edges=self.update_edge_adapter_data)
        #  - once adapter data changes, redraw
        self.edge_adapter.bind(data=self.do_redraw)

        self.add_widget(self.view)
예제 #20
0
    def __init__(self, **kwargs):
        kwargs['cols'] = 2
        super(MotionViewList, self).__init__(**kwargs)

        def args_converter(row_index, row_data):
            return {
                'text':
                row_data['text'],
                'size_hint_y':
                None,
                'height':
                25,
                'cls_dicts': [
                    {
                        'cls': ListItemLabel,
                        'kwargs': {
                            'text': row_data['text'],
                            'is_representing_cls': True
                        }
                    },
                    {
                        'cls': ListItemLabel,
                        'kwargs': {
                            'text': "Middle-{0}".format(row_data['text']),
                            'is_representing_cls': True
                        }
                    },
                    {
                        'cls': ListItemLabel,
                        'kwargs': {
                            'text': "End-{0}".format(row_data['text']),
                            'is_representing_cls': True
                        }
                    },
                    {
                        'cls': ListItemButton,
                        'kwargs': {
                            'text': row_data['text']
                        }
                    },
                ]
            }

        item_strings = ["{0}".format(index) for index 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)

        self.list_view = ListView(adapter=dict_adapter)

        self.step_button = Button(text='Step')
        self.reset_button = Button(text='Reset')
        self.spacer = Label()
        self.assemble_components()
예제 #21
0
    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=(0.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=(0.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=(0.6, 1.0))

        fruits_list_adapter.bind(on_selection_change=detail_view.fruit_changed)
        self.add_widget(detail_view)
예제 #22
0
 def update(self):
     f = open("Downloads/History")
     f = f.read().split("\n")
     for i in f:
         i = i.split(',')
         self.lists[i[0]] = i[1:]
     dict_adapter = DictAdapter(sorted_keys=sorted(self.lists.keys()),
                                data=self.lists,
                                selection_mode='single',
                                allow_empty_selection=False,
                                cls=ListItemButton)
예제 #23
0
    def __init__(self, **kwargs):
        item_strings = ["{0}".format(index) for index in range(11)]

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

        super(BlockListView, self).__init__(adapter=dict_adapter)
    def prepare_stations_dict_adapter(self, stations, filter_text):
        data = {}
        for number in range(len(stations)):
            station = stations[number]
            if station.matches(filter_text) is True:
                data[number] = station

        dict_adapter = DictAdapter(data=data,
                                   args_converter=self.station_converter,
                                   template=b'StationTemplate')
        return dict_adapter
예제 #25
0
파일: gui.py 프로젝트: mugsy-mcgeee/augr
    def __init__(self, **kwargs):
        super(PlayerListView, self).__init__(**kwargs)

        # filled in later with call to reload()
        self.player_adapter = DictAdapter(sorted_keys=[],
                                          data={},
                                          args_converter=self._player_converter,
                                          selection_mode='multiple',
                                          propagate_selection_to_data=True,
                                          template='CustomListItem')

        self.d2rp = None # set by parent
예제 #26
0
파일: views.py 프로젝트: Anhmike/Iseekey
 def __init__(self, **kwargs):
     self.level = self.level+ 1
     subdirs={}
     if self.level <= 2:
         for subfolder in os.listdir(self.datadir):
             if os.path.isdir(os.path.join(self.datadir,subfolder)):
                 subdirs[os.path.join(self.datadir,subfolder)] = {'text': subfolder,'is_selected': False}
     else:
         for subfolder in os.listdir(self.datadir):
             subdirs[os.path.join(self.datadir,subfolder)] = {'text': subfolder,'is_selected': False}
     args_converter = \
         lambda row_index, rec: {'text': rec['text'],
                                 'is_selected': rec['is_selected'],
                                 'size_hint_y': 10,
                                 'height': 40}
     f_adapter = DictAdapter(data=subdirs,
                              args_converter=args_converter,
                              sorted_keys=subdirs.keys(),
                              template='FListItem')
     super(FView, self).__init__(adapter=f_adapter)
     f_adapter.bind(on_selection_change=self.callback)
예제 #27
0
    def __init__(self, **kwargs):

        super(PlaylistLayout, self).__init__(**kwargs)

        integers_dict = {
            str(i): {
                'source': basename(self.playlist[i][0]),
                'size': '%dx%d' % tuple(self.playlist[i][3]) \
                        if self.playlist[i][0].lower().endswith('.yuv') else '',
                'format': self.playlist[i][1].upper() \
                          if self.playlist[i][0].lower().endswith('.yuv') else '',
                'playlist': self.playlist[i],
                'is_selected': False
            } for i in xrange(len(self.playlist))
        }
        args_converter = lambda row_index, rec: {
            'text': rec['source'],
            'size_hint_y': None,
            'height': 25,
            'cls_dicts': [
                {'cls': ListItemButton,
                 'kwargs': {'text': rec['source']}},
                {'cls': ListItemButton,
                 'kwargs': {'text': rec['size'],
                            'size_hint_x': None, 'width': 100}},
                {'cls': ListItemButton,
                 'kwargs': {'text': rec['format'],
                            'size_hint_x': None, 'width': 70}}
            ]
        }
        item_strings = ["{0}".format(index) for index in xrange(len(self.playlist))]
        dict_adapter = DictAdapter(sorted_keys=item_strings,
                                   data=integers_dict,
                                   args_converter=args_converter,
                                   selection_mode='single',
                                   allow_empty_selection=False,
                                   cls=CompositeListItem)
        dict_adapter.bind(selection=self.setter('selection'))
        list_view = ListView(adapter=dict_adapter)
        self.layout.add_widget(list_view)
예제 #28
0
파일: list_two_up.py 프로젝트: xyqgcs/kivy
    def __init__(self, **kwargs):
        kwargs['cols'] = 3
        kwargs['size_hint'] = (1.0, 1.0)
        super(TwoUpView, self).__init__(**kwargs)

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

        fruits_dict_adapter = \
                DictAdapter(
                    sorted_keys=sorted(fruit_data.keys()),
                    data=fruit_data,
                    args_converter=list_item_args_converter,
                    selection_mode='multiple',
                    allow_empty_selection=False,
                    cls=ListItemButton)

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

        self.add_widget(fruits_list_view)

        fruits_dict_adapter2 = \
                ReceivingFruitsDictAdapter(
                    sorted_keys=[],
                    data={},
                    args_converter=list_item_args_converter,
                    selection_mode='single',
                    allow_empty_selection=True,
                    cls=ListItemButton)

        fruits_list_view2 = ListView(adapter=fruits_dict_adapter2,
                                     size_hint=(.2, 1.0))

        fruits_dict_adapter.bind(
                on_selection_change=fruits_dict_adapter2.fruits_changed)

        self.add_widget(fruits_list_view2)
예제 #29
0
    def __init__(self, **kwargs):
        kwargs['cols'] = 2
        super(PartnerUpdateView, self).__init__(**kwargs)


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

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

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

        self.add_widget(self.master_list_view)

        self.popup = self.make_comm_popup()

        detail_container = AnchorLayout()
        detail_view = PartnerDetailView(self,
                fruit_name=self.dict_adapter.selection[0].text,
                size_hint=(.7, None))
        detail_container.add_widget(detail_view)

        self.dict_adapter.bind(on_selection_change=detail_view.partner_changed)

        communicate_button_layout = AnchorLayout(anchor_y = 'bottom', size_hint = (.7, None))
        communicate_button = Button(text = 'Communication', size_hint_y=None,height=25)
        communicate_button.bind(on_press = self.popup.open)
        communicate_button_layout.add_widget(communicate_button)
        self.add_widget(detail_container)
        self.add_widget(communicate_button_layout)
예제 #30
0
    def on_enter(self):
        """ Repopulate the listview """
        info = self.playlist.get_info
        data = {str(i): {'text': item[0],
                         'source': item[1],
                         'album': info(item[0])["album"],
                         'track': info(item[0])["file"],
                         'is_selected': bool(i == self.playlist.current)}
                for i, item in enumerate(self.playlist.queue)}

        def args_converter(row_index, item):
            return {'text': item['text'],
                    'size_hint_y': None,
                    'height': "60sp",
                    'cls_dicts': [{'cls': ZenListImage,
                                   'kwargs': {'source': item['source'],
                                              'size_hint_x': 0.1,
                                              'row_index': row_index}},
                                  {'cls': ZenListButton,
                                   'kwargs': {'text': item['track'],
                                              'is_representing_cls': True,
                                              'size_hint_x': 0.55,
                                              'row_index': row_index}},
                                  {'cls': ZenListButton,
                                   'kwargs': {'text': item['album'],
                                              'size_hint_x': 0.35,
                                              'row_index': row_index}}]}

        dict_adapter = DictAdapter(
            sorted_keys=[str(i) for i in range(len(self.playlist.queue))],
            data=data,
            selection_mode='single',
            args_converter=args_converter,
            propagate_selection_to_data=True,
            cls=ZenListItem)

        self.listview.adapter = dict_adapter
        dict_adapter.bind(on_selection_change=self.selection_changed)
예제 #31
0
    def BuildList(self):
        args_converter = \
            lambda row_index, rec: \
                {'text': rec['text'],
                 'height': 25,
                 'size_hint_y': None,
                 'cls_dicts': [{'cls': ListItemLabel,
                        'kwargs': {'text': rec['text'][3], 'height': 25,}},
                       {'cls': ListItemLabel,
                        'kwargs': {'text': rec['text'][0], 'size_hint_x':.3}},
                       {'cls': ListItemLabel,
                        'kwargs': {'text': rec['text'][1], 'size_hint_x':.02}},
                       {'cls': ListItemLabel,
                        'kwargs': {'text': rec['text'][2], 'size_hint_x':.3}}]}

        #item_strings = [self.listftp[index][3] for index in xrange(len(self.listftp))]
        integers_dict = {
            self.listftp[i][3]: {
                'text': self.listftp[i],
                'is_selected': False
            }
            for i in xrange(len(self.listftp))
        }

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

        # Use the adapter in our ListView:
        self.list_view = ListView(adapter=dict_adapter)
        #print "len", len(self.listftp), self.listftp

        #self.list_view = ListView(item_strings = self.listftp)

        self.buttonLoad = Button(text='Load', size_hint_y=.1)
        self.buttonLoad.bind(on_release=self.Load)

        self.buttonDoIt = Button(text='Do it', size_hint_y=.1)
        self.buttonDoIt.bind(on_release=self.DoIt)

        #self.buttonCancel = Button(text = 'Cancel', size_hint_y = .1)#, center_x = 150)
        #self.buttonCancel.bind(on_release = self.Cancel)

        #add the widgets
        self.add_widget(self.buttonLoad)
        self.add_widget(self.list_view)
        self.add_widget(self.buttonDoIt)
    def __init__(self, **kwargs):
        kwargs['cols'] = 2
        super(MainView, self).__init__(**kwargs)

        # This is quite an involved args_converter, so we should go through the
        # details. A CompositeListItem instance is made with the args
        # returned by this converter. The first three, text, size_hint_y,
        # height are arguments for CompositeListItem. The cls_dicts list
        # contains argument sets for each of the member widgets for this
        # composite: ListItemButton and ListItemLabel.
        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)]

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

        # Use the adapter in our ListView:
        list_view = ListView(adapter=dict_adapter)

        self.add_widget(list_view)
예제 #33
0
파일: main.py 프로젝트: herrfeder/PyThek
    def update_adapters(self):
        categories = sorted(self.download_dict.keys())
        self.download_table.download_dict_adapter = \
                DictAdapter(
                    sorted_keys = categories,
                    data = self.download_dict,
                    args_converter = self.download_item_args_converter,
                    selection_mode='single',
                    allow_empty_selection=False,
                    cls=DownloadItem)

        self.download_table.download_list_view = \
                ListView(adapter=self.download_table.download_dict_adapter,
                         padding=2,
                         size_hint=(1,1))
예제 #34
0
    def create_listview(self, dict_data):
        list_item_args_converter = \
                lambda row_index, rec: {'text': str(row_index) + ' ' + rec['title'],
                                        'size_hint_y': None,
                                        'height': 25}

        dict_adapter = DictAdapter(
            sorted_keys=[str(i) for i in range(0, len(dict_data.keys()))],
            data=dict_data,
            args_converter=list_item_args_converter,
            selection_mode='single',
            allow_empty_selection=True,
            cls=ListItemLabel)

        master_list_view = ListView(adapter=dict_adapter)
        return master_list_view, dict_adapter
예제 #35
0
파일: main.py 프로젝트: AndTH/HiQontrol
    def populate(self):
        # FIXME: This should be dynamically detected from the network or manually added/removed
        item_strings = ['0', '1']
        integers_dict = {
            '0': {
                'text': 'Si Compact 16',
                'ip_address': SI_COMPACT_16_IP,
                'hiqnet_address': SI_COMPACT_16_DEVICE_ADDRESS,
                'is_selected': False
            },
            '1': {
                'text': 'Lool',
                'ip_address': '192.168.1.3',
                'hiqnet_address': 9999,
                'is_selected': False
            }
        }

        args_converter = \
            lambda row_index, rec: \
            {'text': rec['text'],
             'size_hint_y': None,
             'height': 50,
             'cls_dicts': [{'cls': ListItemButton,
                            'kwargs': {'text': rec['text'],
                                       'is_representing_cls': True}},
                           {'cls': ListInfoButton,
                            'kwargs': {'text': 'i',  # TODO: replace by a nice icon
                                       'size_hint_x': None}},
                           {'cls': ListLocateButton,
                            'kwargs': {'text': 'L',  # TODO: replace by a nice icon
                                       'size_hint_x': None,
                                       'hiqnet_address': rec['hiqnet_address'],
                                       'ip_address': rec['ip_address'],
                                       'serial_number': SI_COMPACT_16_SERIAL}},  # FIXME
                           {'cls': ListMixButton,
                            'kwargs': {'text': '>',  # TODO: replace by a nice icon
                                       'size_hint_x': None}}]}

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

        return dict_adapter
예제 #36
0
파일: rktool.py 프로젝트: brBart/RKSV
    def __init__(self, receipt, algorithmPrefix, isValid, key, **kwargs):
        self._init_key = key if key else None
        self._receipt = receipt
        self._key = None
        self._algorithmPrefix = algorithmPrefix
        self._is_valid = isValid
        self._popup = None

        convert = lambda row_index, rec: \
                { 'item_name': rec[0]
                , 'item_value': rec[1]
                }
        keys = list(range(1, 14))

        self.adapter = DictAdapter(sorted_keys=keys,
                                   data=dict(),
                                   args_converter=convert,
                                   cls=ViewReceiptItem)

        super(ViewReceiptWidget, self).__init__(**kwargs)

        if receipt.isDummy() or receipt.isReversal():
            self.decrypt_button.disabled = True

        if isValid:
            self.verify_button.text = _('Valid Signature')
            self.verify_button.disabled = True
            self.verify_button.background_color = (0, 1, 0, 1)

        if receipt.isSignedBroken():
            self.verify_button.text = _('No Signature')
            self.verify_button.disabled = True

            if not receipt.isDummy() and not receipt.isReversal(
            ) and receipt.isNull():

                def showReceiptError(instance):
                    displayError(
                        verify_receipt.UnsignedNullReceiptException(
                            receipt.receiptId))

                Clock.schedule_once(showReceiptError, 0)

        self.updateView()
예제 #37
0
    def __init__(self, **kwargs):
        kwargs['cols'] = 2
        super(MainView, self).__init__(**kwargs)

        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)]

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

        # Use the adapter in our ListView:
        list_view = ListView(adapter=dict_adapter)
        self.add_widget(list_view)
예제 #38
0
    def __init__(self, stamp_dict, **kwargs):
        super(StampList, self).__init__(**kwargs)

        self.size_hint = (1.0, 0.55)

        self.stamp_dict = stamp_dict

        list_item_args_converter = \
            lambda row_index, rec: {'text': rec['name'],
                                    'size_hint_y': None,
                                    'height': Window.height * 0.6 / 5}

        dict_adapter = DictAdapter(sorted_keys=sorted(self.stamp_dict.keys()),
                                   data=self.stamp_dict,
                                   args_converter=list_item_args_converter,
                                   selection_mode='single',
                                   allow_empty_selection=False,
                                   cls=ViewStampButton)

        self.adapter = dict_adapter
예제 #39
0
 def __init__(self, **kwargs):
     if 'controller' in kwargs:
         self.controller = kwargs['controller']
         kwargs['controller'] = None
         del kwargs['controller']
     if 'main_ui' in kwargs:
         self.main_ui = kwargs['main_ui']
         kwargs['main_ui'] = None
         del kwargs['main_ui']
     super(MediaPlayer, self).__init__(**kwargs)
     self.track_list = []
     self.list_tracks = DictAdapter(data=self.tracks_info,
                                    sorted_keys=self.sorted_tracks,
                                    args_converter=self.args_converter,
                                    template='CustomListItem',
                                    selection_mode='single',
                                    propagate_selection_to_data=True,
                                    allow_empty_selection=True)
     self.ids['trackslist'].adapter = self.list_tracks
     self.register_server('ti')
예제 #40
0
    def __init__(self,
                 **kwargs):  #using kwargs we can pass variable no. of arguents
        kwargs['cols'] = 3
        super(NewsView, self).__init__(**kwargs)
        feedurl = sys.argv[1]
        if len(sys.argv) != 2:
            print("please input 2 arguements")
            exit()
        else:
            feed = feedparser.parse(feedurl)
            numofentries = len(feed['entries'])
            for i in range(0, numofentries):
                news_list[i] = dict({
                    'index':
                    str(i),
                    'title':
                    feed['entries'][i]['title'],
                    'imageurl':
                    feed['entries'][i]["media_thumbnail"][0]["url"]
                })

            list_item_args_converter = \
                 lambda row_index, rec: {'text': rec['title'],
                                           'imageurl': rec['imageurl'],
                                           'size_hint_y': None,
                                           'height': 100}
            nlist = sorted(news_list.keys())
            news_list_adapter = \
            DictAdapter(
                       sorted_keys=nlist,
                       data=news_list,
                       args_converter=list_item_args_converter,
                       selection_mode='single',
                       allow_empty_selection=False,
                       template='ThumbnailedListItem')



            news_list_view = \
                    ListView(adapter=news_list_adapter)
            self.add_widget(news_list_view)
    def __init__(self, items, **kwargs):
        kwargs['cols'] = 2
        super(MasterDetailView, self).__init__(**kwargs)

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

        print fruit_data
        
        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=ModButton)

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

        self.add_widget(master_list_view)
예제 #42
0
파일: gui.py 프로젝트: mugsy-mcgeee/augr
    def reload(self):
        if not self.d2rp:
            return

        hero_len = max([len(dotalocal.hero[h['hero']]) for h in self.d2rp.players])

        p_str = {}
        for i,hero in enumerate(self.d2rp.players):
            hero_s = dotalocal.hero[hero['hero']]
            player = dotalocal.player(hero['player'])
            p_str[str(i)] = { 
                'player_label': ' {} | {}'.format(hero_s.ljust(hero_len), player),
                'is_selected': False }

        self.player_adapter = DictAdapter(sorted_keys=[i for i in range(len(p_str))],
                                          data=p_str,
                                          args_converter=self._player_converter,
                                          selection_mode='multiple',
                                          propagate_selection_to_data=True,
                                          template='CustomListItem')

        self.player_adapter.bind(on_selection_change=self.selection_changed)
예제 #43
0
class PartnerUpdateView(GridLayout):

    partner_data = {'Child 1' : {'name' : 'Child 1',
                             'street' : None,
                             'street2' : None,
                             'type' : 'Unknown',
                             'zip' : None,
                             'city' : 'Some Village',
                             'phone' : '22 55 55 55'}}

    def __init__(self, **kwargs):
        kwargs['cols'] = 2
        super(PartnerUpdateView, self).__init__(**kwargs)


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

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

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

        self.add_widget(self.master_list_view)

        self.popup = self.make_comm_popup()

        detail_container = AnchorLayout()
        detail_view = PartnerDetailView(self,
                fruit_name=self.dict_adapter.selection[0].text,
                size_hint=(.7, None))
        detail_container.add_widget(detail_view)

        self.dict_adapter.bind(on_selection_change=detail_view.partner_changed)

        communicate_button_layout = AnchorLayout(anchor_y = 'bottom', size_hint = (.7, None))
        communicate_button = Button(text = 'Communication', size_hint_y=None,height=25)
        communicate_button.bind(on_press = self.popup.open)
        communicate_button_layout.add_widget(communicate_button)
        self.add_widget(detail_container)
        self.add_widget(communicate_button_layout)

    def make_comm_popup(self):

        prms = {} # TODO add server parameters from DB
        cont = BoxLayout(orientation = 'vertical')
        cont.add_widget(CommunicateContent(self, prms))

        gl = GridLayout(cols=2)
        fetch_button = Button(text = 'Fetch data', size_hint_y=None, height=25)
        fetch_button.bind(on_press = self.fetch_data)
        send_button = Button(text = 'Send data', size_hint_y=None, height=25)
        send_button.bind(on_press = self.send_data)
        gl.add_widget(fetch_button)
        gl.add_widget(send_button)
        cont.add_widget(gl)


        return Popup(title = 'Communicate', content = cont, size_hint=(0.6, None), height=200)

    def fetch_data(self, instance):
        self.popup.dismiss()
        communicate.fetch_partners(self.server, self.user, self.password)
        self.partner_data = communicate.get_partners_from_db()
        print "DATA", self.dict_adapter.data.keys()
        for d in self.dict_adapter.data.items():
            print "HEI", d


        #self.partner_data = {'hei' : {'name': 'hei'}}
        self.dict_adapter.sorted_keys = sorted(self.partner_data.keys())
        #self.dict_adapter.data = [('hei', {'name' : 'hei'})]
        self.dict_adapter.data = self.partner_data

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

        #self.add_widget(self.master_list_view)


    def send_data(self, instance):
        self.popup.dismiss()
        communicate.send_partners(self.server, self.user, self.password)
예제 #44
0
    def on_selection_change(self, *args):
        DictAdapter.on_selection_change(self, *args)
        global voc_learn

        for i in self.selection:
            voc_learn = i.text