当前位置: 首页>>代码示例>>Python>>正文


Python listadapter.ListAdapter类代码示例

本文整理汇总了Python中kivy.adapters.listadapter.ListAdapter的典型用法代码示例。如果您正苦于以下问题:Python ListAdapter类的具体用法?Python ListAdapter怎么用?Python ListAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ListAdapter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: FontChooser

class FontChooser(BoxLayout):
    font = StringProperty("")
    text = font
    def __init__(self, **kwargs):
        super(FontChooser, self).__init__(**kwargs)
        self.orientation = "vertical"
        self.fonts = sorted(map(str, fonts.get_fonts()))

        data = [{'text': str(i), 'is_selected': i == self.font} for i in self.fonts]

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

        self.list_adapter = ListAdapter(data=data, args_converter=args_converter, cls=ListItemButton, selection_mode='single', allow_empty_selection=False)
        self.list_view = ListView(adapter=self.list_adapter)
        self.list_adapter.bind(selection=self.on_font_select)

        self.label = Label(text="The quick brown fox jumps over the brown lazy dog. 0123456789", font_size="30dp", halign="center", size_hint_y=None)
        self.label.font_name = fonts.match_font(self.list_adapter.selection[0].text)
        self.label.bind(size=self.label.setter("text_size"))
        self.font = self.list_adapter.selection[0].text

        self.add_widget(self.list_view)
        self.add_widget(self.label)          

    def on_font_select(self, instance, value):
        self.font = value[0].text
        self.label.font_name = fonts.match_font(value[0].text)
开发者ID:Davideddu,项目名称:karaokivy,代码行数:29,代码来源:ui.py

示例2: __init__

    def __init__(self, settings, channel, **kwargs):
        super(ChannelSelectView, self).__init__(**kwargs)
        self.register_event_type('on_channel_selected')
        self.register_event_type('on_channel_cancel')
        data = []
        channel_list = self.ids.channelList

        available_channels = list(settings.runtimeChannels.get_active_channels().iterkeys())
        available_channels.sort()
        try:
            for available_channel in available_channels:
                data.append({'text': available_channel, 'is_selected': False})
                
            args_converter = lambda row_index, rec: {'text': rec['text'], 'size_hint_y': None, 'height': dp(50)}
    
            list_adapter = ListAdapter(data=data,
                               args_converter=args_converter,
                               cls=ChannelItemButton,
                               selection_mode='single',
                               allow_empty_selection=True)
    
            channel_list.adapter = list_adapter

            #select the current channel
            index = 0
            for item in list_adapter.data:
                if item['text'] == channel:
                    view = list_adapter.get_view(index)
                    view.trigger_action(duration=0) #duration=0 means make it an instant selection
                index += 1

            list_adapter.bind(on_selection_change=self.on_select)
            self.channel = channel
        except Exception as e:
            Logger.error("ChannelSelectView: Error initializing: " + str(e))
开发者ID:ddimensia,项目名称:RaceCapture_App,代码行数:35,代码来源:channelselectview.py

示例3: __init__

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

        categories = list()
        words = list()

        for entry in database_interface.get_data(database_interface.GUIDELINES.SHELF_TIME, {}):

            if entry['type'].capitalize() not in words:
                categories.append(controller.DataItem(text=entry['type'].capitalize()))
                words.append(entry['type'].capitalize())

        list_item_args_converter = lambda row_index, obj: {
            'text': obj.text,
            'height': 100,
            'font_size': 30,
            'selected_color': [0.2, 5, 0.5, 1.],
            'deselected_color': [1, 1, 1, 1.],
            'background_color': [1, 1, 1, 0.],
            'background_normal': "Images/Box.png",
            'color': [0, 0, 0, 1.],
            'padding': (5, 5)
            }

        ad = ListAdapter(data=categories,
                         args_converter=list_item_args_converter,
                         propagate_selection_to_data=True,
                         cls=ListItemButton)

        ad.bind(on_selection_change=self.show_bin_names)
        self.add_widget(ListView(adapter=ad))
        self.add_widget(ListView())
开发者ID:Nixon-,项目名称:Nutrition_Automation-server,代码行数:32,代码来源:UpdateBinScreen.py

示例4: MainView

class MainView(BoxLayout):
    def __init__(self, **kwargs):
        kwargs['cols'] = 2
        super(MainView, self).__init__(**kwargs)
        #project_store = JsonStore('projectlist.json')
        lis, project_store = FApp().other()

        print lis
        print project_store

        self.list_adapter = ListAdapter(data=[("Project " + r + ' ' + project_store[r]['profile']['projecttitle'])
                                        for r in lis],
                                        cls=ListItemButton,
                                        sorted_keys=[])
        self.list_adapter.bind(on_selection_change=self.callback)
        list_view = ListView(adapter=self.list_adapter)
        self.add_widget(list_view)

    def callback(self, instance):
        global PROJECT
        p_num= instance.selection[0].text.split(' ')[1]
        PROJECT = p_num
        print p_num
        print 'project'
        return PROJECT
开发者ID:LeroyGethroeGibbs,项目名称:LinuxApp,代码行数:25,代码来源:version1.py

示例5: test_list_adapter_selection_mode_single

    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)
开发者ID:Titousensei,项目名称:kivy,代码行数:28,代码来源:test_selection.py

示例6: SettingContactList

class SettingContactList(ListView):

    def update_contacts(self):
        names = controller.database_interface.get_data(database_interface.CONTACT, {})
        li = list()

        for name in names:
            li.append(controller.DataItem(str(name['name'])))

        list_item_args_converter = lambda row_index, obj: {
            'text': obj.text,
            'font_size': 30,
            'height': 100,
            'selected_color': [0.2, 5, 0.5, 1.],
            'deselected_color': [1, 1, 1, 1.],
            'background_color': [1, 1, 1, 0.],
            'background_normal': "Images/Box.png",
            'color': [0, 0, 0, 1.],
            'padding': (5, 5)
        }
        self.adapter = ListAdapter(data=li,
                                   args_converter=list_item_args_converter,
                                   propagate_selection_to_data=True,
                                   allow_empty_selectio=False,
                                   cls=ListItemButton)
        self.adapter.bind(on_selection_change=controller.go_to_contact)

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.update_contacts()
开发者ID:Nixon-,项目名称:Nutrition_Automation-server,代码行数:30,代码来源:SettingContactScreen.py

示例7: load

    def load(self, path, filename):

        try:

            if str(filename[0]).endswith('mp3'):                   # добавление в плейлист только мр3 файлов
                self.list_of_songs.append(os.path.join(path, filename[0]))                  
            else:
                self.warnings('This is not .mp3 file')
        
            # ___ создание плейлиста в виде ListItemButton
            item_strings = ["{0}".format(index) for index in self.list_of_songs]
    
            list_adapter = ListAdapter( 
                                        data=self.list_of_songs,
                                        selection_mode='single',
                                        allow_empty_selection=False,
                                        cls=ListItemButton
                                        )
    
            list_view = ListView(adapter=list_adapter)
    
            list_adapter.bind(on_selection_change=self.sound_load)
    
            global list_view
            print(self.list_of_songs[0])

        except  IndexError:
            
            self.warnings('Choose a song')
开发者ID:Khritavarman,项目名称:Aleksandr_Chupov,代码行数:29,代码来源:audioplayer.py

示例8: RollbackDialog

class RollbackDialog(Popup):

    def __init__(self, oMainWidget, aRounds):
        self.turnadapt = ListAdapter(data=aRounds,
                                     args_converter=self.convert,
                                     cls=ListItemButton,
                                     selection_mode='single',
                                     allow_empty_selection=False)
        self.turnadapt.bind(selection=self.selection)
        self.oMainWidget = oMainWidget
        self.sRound = aRounds[0]
        super(RollbackDialog, self).__init__()

    def convert(self, iRow, sText):
        return {'text': sText,
                'size_hint_y': None, 'height': 25}

    def selection(self, oAdapt, *args):
        if self.turnadapt.selection:
            # We need this guard, since we're called twice on selection
            # changes - once with nothing selected and once with the
            # new selection
            self.sRound = self.turnadapt.selection[0].text

    def select(self):
        self.oMainWidget.rollback_to_round(self.sRound)
        self.dismiss()
开发者ID:drnlm,项目名称:vtes_reporting_tool,代码行数:27,代码来源:main.py

示例9: __init__

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

        self.parent_and_uncles_list_adapter = ListAdapter(
            data=[El.get("TEXT") for El in parentMap[selectedParent]],
            selection_mode='single',
            allow_empty_selection=False,
            cls=ListItemButton)
        self.add_widget(ListView(adapter=self.parent_and_uncles_list_adapter))
        self.parent_and_uncles_list_adapter.get_view(selectedIndexList[-2]).trigger_action(duration=0)

        self.main_list_adapter = ListAdapter(
            data=[El.get("TEXT") for El in selectedParent],
            selection_mode='single',
            allow_empty_selection=False,
            cls=ListItemButton)
        self.add_widget(ListView(adapter=self.main_list_adapter))
        self.main_list_adapter.get_view(selectedIndexList[-1]).trigger_action(duration=0)

        child_list_adapter = ListAdapter(
            data=[El.get("TEXT") for El in selectedParent[selectedIndexList[-1]]],
            selection_mode='single',
            allow_empty_selection=True,
            cls=ListItemButton)
        self.add_widget(ListView(adapter=child_list_adapter))
开发者ID:assimilatedgiraffe,项目名称:darkmm,代码行数:25,代码来源:main.py

示例10: __init__

 def __init__(self, **kwargs):
     super(ChannelSelectView, self).__init__(**kwargs)
     self.register_event_type('on_channel_selected')
     self.register_event_type('on_channel_cancel')
     
     settings = kwargs.get('settings')
     type = kwargs.get('type')
     channel = kwargs.get('channel')
     
     data = []
     channel_list = self.ids.channelList
     try:
         for available_channel,channelMeta in settings.runtimeChannels.channels.iteritems():
             channel_type = channelMeta.type
             data.append({'text': available_channel, 'is_selected': False})
             
         args_converter = lambda row_index, rec: {'text': rec['text'], 'size_hint_y': None, 'height': dp(50)}
 
         list_adapter = ListAdapter(data=data,
                            args_converter=args_converter,
                            cls=ChannelItemButton,
                            selection_mode='single',
                            allow_empty_selection=True)
 
         channel_list.adapter=list_adapter
         list_adapter.bind(on_selection_change=self.on_select)
         self.channel = channel
     except Exception as e:
         Logger.error("ChannelSelectView: Error initializing: " + str(e))
开发者ID:imstimpy,项目名称:RaceCapture_App,代码行数:29,代码来源:channelselectview.py

示例11: ListeVille

class ListeVille(MainApp):
    def __init__(self, parent,**kwargs):
        super(MainApp, self).__init__(**kwargs)
        self.parent = parent
        self.orientation = 'vertical'
        self.ville_depart = None
        self.ville_arriver = None

        self.list_adapter = ListAdapter(
            data=gestion_bd.select_ville(),
            cls=ListItemButton,
            sorted_keys=[],
            selection_mode='multiple',
            )
        self.list_adapter.bind(on_selection_change=self.selection_change)

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

    def selection_change(self, adapter, *args):
        for element in adapter.selection:
            x = element.index #index du truc selectionner
            print(adapter.data[x])
            if self.ville_depart != None:
                self.ville_arriver = adapter.data[x]
            if self.ville_depart == None:
                self.ville_depart = adapter.data[x]
                self.list_adapter.data = gestion_bd.select_seconde_ville(str(adapter.data[x]))
            if self.ville_arriver != None:
                self.resultat()

    def resultat(self):
        self.retour = gestion_bd.select_horaire(self.ville_depart, self.ville_arriver)
        self.parent.remove_widget(self.list_view)
        affichage = Affichage(self.parent, self.ville_depart, self.ville_arriver, self.retour)
开发者ID:simplonve,项目名称:projet_appli_transport,代码行数:34,代码来源:old_main.py

示例12: DockAppsList

class DockAppsList(ListView):
	def __init__(self, *args, **kwargs):
		super(DockAppsList, self).__init__(*args, **kwargs)	
		the_apps = [DataItem(text=a["name"]) for a in APPS.info('')]
		args_converter = lambda row_index, obj: {'text': obj.text,
							'is_selected':obj.is_selected,
							'size_hint_y': None,
							'height': 20,
							'font_size':14,
							'deselected_color':[0,0,0,0],
							'selected_color':[.96,.56,.36,1],
							'background_normal':"images/button.png",
							'background_down':"images/buton.png",
							'color':[.2,.2,.2,1]}
		self.adapter=ListAdapter(data = the_apps, 
					selection_mode = 'multiple',
					args_converter=args_converter,
					allow_empty_selection = True,
					propagate_selection_to_data=True,
					cls = ListItemButton,
					sorted_keys=[])
		#self.adapter.select_list(self.adapter.data,extend=False)
		self.adapter.bind(on_selection_change=self.on_select)
	def on_select(self, *args, **kwargs):
		l = [a.text for a in args[0].selection]
		updateConfig({'dock-apps':l})
开发者ID:archlinux2002,项目名称:launcher,代码行数:26,代码来源:main.py

示例13: SettingAreasList

class SettingAreasList(ListView):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        bins = controller.sort_bin(database_interface.get_data(database_interface.CONFIG.BINS, {}))
        areas = list()

        for area in bins:
            areas.append(controller.DataItem('Bin ' + str(area['bin']) + ': ' + area['name'].capitalize()))

        list_item_args_converter = lambda row_index, obj: {
            'text': obj.text,
            'font_size': 30,
            'height': 100,
            'selected_color': [0.2, 5, 0.5, 1.],
            'deselected_color': [1, 1, 1, 1.],
            'background_color': [1, 1, 1, 0.],
            'background_normal': "Images/Box.png",
            'color': [0, 0, 0, 1.],
            'padding': (5, 5)
        }
        self.adapter = ListAdapter(data=areas,
                                   args_converter=list_item_args_converter,
                                   propagate_selection_to_data=True,
                                   allow_empty_selectio=False,
                                   cls=ListItemButton)
        self.adapter.bind(on_selection_change=controller.go_to_update)
开发者ID:Nixon-,项目名称:Nutrition_Automation-server,代码行数:27,代码来源:SettingAreasScreen.py

示例14: TestKVfile

class TestKVfile(BoxLayout):
    ind, tot = 0,0

    def addUrl(self):
        print self.url_box.text
        url = newWidget()
        self.add_widget(url)
        url.hello.text = self.url_box.text
        self.url_box.text = ""
        self.list_adapter = ListAdapter(data=["Item #{0}".format(i) for i in range(10)], cls=ListItemButton,
                                        sorted_keys=[])
        self.list_adapter.bind(on_selection_change=self.selection_change)
        list_view = ListView(adapter=self.list_adapter, multiselect=True)
        self.add_widget(list_view)

    def selection_change(self, args):
        print args

    def sayHello(self):
        print self.url_box.text
        print "Hellooooooo"
        self.ind += 1
        if(self.ind == 5):
            self.ind, self.tot = 0, self.tot+1
        self.current_progress.value, self.total_progress.value = self.ind, self.tot
        self.a = selectList()
        self.a.open()
开发者ID:sarathm09,项目名称:YoutubeDownloader,代码行数:27,代码来源:tests.py

示例15: generate_start_screen

    def generate_start_screen(self, screen=None):
        # If we're going back to home after a session
        # TODO P2: make this more efficient (state last saved flag, for example)
        if self.cards:
            self.save_state()

        self.card_filename = None
        self.cards = []
        self.card_list = []
        self.current_card = None
        self.valid_cards = []

        screen.clear_widgets()

        start_layout = GridLayout(size_hint=(1,1), cols=1, rows=2)

        self.load_card_lists()

        empty_cards_list = False

        if not self.card_list:
            empty_cards_list = True

            # No decks on device, so let's try copying over our samples
            # 
            # This code is hideous because Android returns errors even when things succeed
            # So we can't trust thrown exceptions!

            sample_list = glob.glob("samples/*.tsv")
            if sample_list:
                for file in sample_list:
                    try:
                        shutil.copy2(file, self.user_data_dir)
                    except:
                        pass

                    self.card_list.append(file[8:])

                empty_cards_list = False
            else:
                empty_cards_list = True
                no_cards_label = Label(markup=True, pos=(0,0), font_name='img/ipag.ttf', size_hint=(1,.85),
                                       font_size=16, halign="center", text="No tsv files found in " + self.user_data_dir)
                start_layout.add_widget(no_cards_label)

        if not empty_cards_list:
            list_adapter = ListAdapter(data=self.card_list, cls=ListItemButton, 
                                       args_converter=(lambda row_index, rec: 
                                                       {'text': rec,'height':75}), 
                                       sorted_keys=[])
            list_adapter.bind(on_selection_change=self.select_cards)
            card_list = ListView(item_strings=self.card_list, adapter=list_adapter, size_hint=(1,.85))
            start_layout.add_widget(card_list)

        file_chooser_btn = Button(text='Import List', size_hint=(1,.15))
        file_chooser_btn.bind(on_release=self.go_to_import_screen)
        start_layout.add_widget(file_chooser_btn)

        screen.add_widget(start_layout)
开发者ID:btrent,项目名称:qflash,代码行数:59,代码来源:main.py


注:本文中的kivy.adapters.listadapter.ListAdapter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。