Added forced dispatch of on_selection_change after instantiation of DetailView in examples.

This commit is contained in:
Jeff Pittman 2012-08-01 07:04:36 -05:00
parent 672b7a223c
commit 634aabbcf6
5 changed files with 14 additions and 3 deletions

View File

@ -19,7 +19,6 @@ class DetailView(GridLayout):
def __init__(self, **kwargs):
kwargs['cols'] = 2
super(DetailView, self).__init__(**kwargs)
self.bind(fruit_name=self.redraw)
def redraw(self, *args):
self.clear_widgets()
@ -101,6 +100,9 @@ class CascadingView(GridLayout):
on_selection_change=detail_view.on_selection_change)
self.add_widget(detail_view)
# Force triggering of on_selection_change() for the DetailView, for
# correct initial display.
fruits_list_adapter.touch_selection()
# Data from http://www.fda.gov/Food/LabelingNutrition/\
# FoodLabelingGuidanceRegulatoryInformation/\

View File

@ -147,6 +147,10 @@ class MasterDetailView(GridLayout):
list_adapter.bind(on_selection_change=detail_view.on_selection_change)
# Force triggering of on_selection_change() for the DetailView, for
# correct initial display.
list_adapter.touch_selection()
# Data from http://www.fda.gov/Food/LabelingNutrition/\
# FoodLabelingGuidanceRegulatoryInformation/\
# InformationforRestaurantsRetailEstablishments/\

View File

@ -67,6 +67,10 @@ class MasterDetailView(GridLayout):
list_adapter.bind(on_selection_change=detail_view.on_selection_change)
# Force triggering of on_selection_change() for the DetailView, for
# correct initial display.
list_adapter.touch_selection()
# Data from http://www.fda.gov/Food/LabelingNutrition/\
# FoodLabelingGuidanceRegulatoryInformation/\
# InformationforRestaurantsRetailEstablishments/\

View File

@ -122,6 +122,9 @@ class ListAdapter(SelectionSupport, SimpleListAdapter):
#else:
#print 'ERROR: No data, so cannot initialize selection.'
def touch_selection(self):
self.dispatch('on_selection_change')
class ListsAdapter(ListAdapter):
'''ListsAdapter is specialized for managing a dict of lists. It has wide

View File

@ -104,8 +104,6 @@ class SelectionSupport(object):
self.bind(selection_mode=self.check_for_empty_selection,
allow_empty_selection=self.check_for_empty_selection)
#self.check_for_empty_selection()
def handle_selection(self, obj):
if obj not in self.selection:
if self.selection_mode == 'single' and len(self.selection) > 0: