本文整理汇总了Python中kivy.adapters.listadapter.ListAdapter.bind方法的典型用法代码示例。如果您正苦于以下问题:Python ListAdapter.bind方法的具体用法?Python ListAdapter.bind怎么用?Python ListAdapter.bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.adapters.listadapter.ListAdapter
的用法示例。
在下文中一共展示了ListAdapter.bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SettingAreasList
# 需要导入模块: from kivy.adapters.listadapter import ListAdapter [as 别名]
# 或者: from kivy.adapters.listadapter.ListAdapter import bind [as 别名]
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)
示例2: SettingContactList
# 需要导入模块: from kivy.adapters.listadapter import ListAdapter [as 别名]
# 或者: from kivy.adapters.listadapter.ListAdapter import bind [as 别名]
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()
示例3: FontChooser
# 需要导入模块: from kivy.adapters.listadapter import ListAdapter [as 别名]
# 或者: from kivy.adapters.listadapter.ListAdapter import bind [as 别名]
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)
示例4: MainView
# 需要导入模块: from kivy.adapters.listadapter import ListAdapter [as 别名]
# 或者: from kivy.adapters.listadapter.ListAdapter import bind [as 别名]
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
示例5: __init__
# 需要导入模块: from kivy.adapters.listadapter import ListAdapter [as 别名]
# 或者: from kivy.adapters.listadapter.ListAdapter import bind [as 别名]
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())
示例6: load
# 需要导入模块: from kivy.adapters.listadapter import ListAdapter [as 别名]
# 或者: from kivy.adapters.listadapter.ListAdapter import bind [as 别名]
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')
示例7: RollbackDialog
# 需要导入模块: from kivy.adapters.listadapter import ListAdapter [as 别名]
# 或者: from kivy.adapters.listadapter.ListAdapter import bind [as 别名]
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()
示例8: __init__
# 需要导入模块: from kivy.adapters.listadapter import ListAdapter [as 别名]
# 或者: from kivy.adapters.listadapter.ListAdapter import bind [as 别名]
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))
示例9: ListeVille
# 需要导入模块: from kivy.adapters.listadapter import ListAdapter [as 别名]
# 或者: from kivy.adapters.listadapter.ListAdapter import bind [as 别名]
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)
示例10: DockAppsList
# 需要导入模块: from kivy.adapters.listadapter import ListAdapter [as 别名]
# 或者: from kivy.adapters.listadapter.ListAdapter import bind [as 别名]
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})
示例11: __init__
# 需要导入模块: from kivy.adapters.listadapter import ListAdapter [as 别名]
# 或者: from kivy.adapters.listadapter.ListAdapter import bind [as 别名]
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))
示例12: TestKVfile
# 需要导入模块: from kivy.adapters.listadapter import ListAdapter [as 别名]
# 或者: from kivy.adapters.listadapter.ListAdapter import bind [as 别名]
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()
示例13: generate_start_screen
# 需要导入模块: from kivy.adapters.listadapter import ListAdapter [as 别名]
# 或者: from kivy.adapters.listadapter.ListAdapter import bind [as 别名]
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)
示例14: on_text
# 需要导入模块: from kivy.adapters.listadapter import ListAdapter [as 别名]
# 或者: from kivy.adapters.listadapter.ListAdapter import bind [as 别名]
def on_text(self, *args):
#get text field text
text_input_value = self.header_textinput.text
#once user has type 3 letters and more, start substring search
if len(text_input_value)>2:
#if previous listview exists, remove it
self.closeListView()
#start search, put the response data in a list adapter
suggestions = app.datamall_bus_stop.busnamesubstringSearch(text_input_value)
#ListitemButton Behaviour
args_converter = lambda row_index, rec: {
'text':rec['text'],
'size_hint':(None,None),
'height': '50dp',
'width': self.header_textinput.width
}
suggestion_listadapter = ListAdapter(
data=suggestions,
args_converter=args_converter,
selection_mode='multiple',
selection_limit=1,
allow_empty_selection=True,
cls=ListItemButton
)
#binds each listview button to the autofill function
suggestion_listadapter.bind(on_selection_change=self.selection_change)
#Logger.info("heightheight"+str(dp(60)))
#Logger.info("heightheight"+str(float(dp(50)*len(suggestions)/self.height)))
self.suggestion_listview = ListView(
adapter=suggestion_listadapter,
size_hint_y=(float(dp(50)*len(suggestions)/self.height)) if (float(dp(50)*len(suggestions)/self.height))<0.4 else 0.4,
width=self.header_textinput.width,
pos_hint={"top":(self.height-self.header_textinput.height*1.3)/self.height},
x=self.header_textinput.x
)
#The container is a GridLayout widget held within a ScrollView widget.
#So we are giving the ScrollViewParent a custom scroll effect
#ListView >> ScrollView >> GridLayout
#effect_cls is an ObjectProperty and defaults to DampedScrollEffect.
self.suggestion_listview.container.parent.effect_cls = self.scrolleffect
#Timeout allowed to trigger the scroll_distance, in milliseconds. If the user has not moved scroll_distance within the timeout, the scrolling will be disabled, and the touch event will go to the children.
self.suggestion_listview.container.parent.scroll_distance = 10
self.suggestion_listview.container.parent.scroll_timeout = 1000
self.listview_widget_collector.append(self.suggestion_listview)
self.ids['searchbusscreen_floatlayout'].add_widget(self.suggestion_listview)
else:
#User is deleting his input, so naturally, we shall close the listview (if it exists)
self.closeListView()
示例15: DataScreen
# 需要导入模块: from kivy.adapters.listadapter import ListAdapter [as 别名]
# 或者: from kivy.adapters.listadapter.ListAdapter import bind [as 别名]
class DataScreen(Screen):
def __init__(self, **kwargs):
super(DataScreen, self).__init__(**kwargs)
tab = TabbedPanel()
self.th_chart_head = TabbedPanelHeader(text='Chart')
tab.default_tab_text = 'Table'
self.list_adapter = ListAdapter(data=[],
args_converter=self.argsc,
cls=TableItemView,
selection_mode='single',
allow_empty_selection=True)
self.list_adapter.bind(on_selection_change=self.selection_changed)
list_view = ListView(adapter=self.list_adapter)
self.th_chart_head.content = GraphView()
tab.default_tab_content = TableView(list_view)
tab.add_widget(self.th_chart_head)
button = Button(text='Add',size_hint_y=None,height=dp(50))
button.bind(on_release=self.addItem)
layout = BoxLayout(orientation='vertical')
layout.add_widget(tab)
layout.add_widget(button)
self.add_widget(layout)
def selection_changed(self, *args):
i = self.list_adapter.selection[0].parent
self.manager.get_screen('editscreen').editEntry(i)
self.manager.transition.direction = 'left'
self.manager.current = 'editscreen'
# self.selected_item = args[0].selection[0].text
def addItem(self, *args):
self.manager.transition.direction = 'left'
self.manager.current = 'editscreen'
def argsc(self, row_index, obj):
return { 'entrydate': obj[0],
'amount': obj[1],
'gallons': obj[2],
'mileage': obj[3],
'size_hint_y': None,
'height': dp(25),
'index': row_index}
def update_list(self, new_list, *args):
self.list_adapter.data.append(new_list)
temp = TableItemView(entrydate=new_list[0],
amount=new_list[1],
gallons=new_list[2],
mileage=new_list[3],
index=0)
self.th_chart_head.content.add_point(temp)