Skip to content

Instantly share code, notes, and snippets.

View amalgamatedclyde's full-sized avatar

Clyde Tressler amalgamatedclyde

View GitHub Profile
@amalgamatedclyde
amalgamatedclyde / gist:6939055
Created October 11, 2013 17:48
how do i update my listadapter data? the callback updates the ListProperty, but how do i use the ListProperty to update the adapter? maybe the ListProperty needs to a property of the adapter?
here is the class:
class StudentDetailList(ListView):
updater = ListProperty([])
def __init__(self, **kwargs):
super(StudentDetailList, self).__init__(**kwargs)
here are the adapters:
class carouselApp(App):
@amalgamatedclyde
amalgamatedclyde / gist:6964158
Created October 13, 2013 16:27
why doesn't this callback update the adapter?
def callback4(instance):
app = App.get_running_app()
if instance.text in app.l.ids['missing'].adapter.data and instance.is_selected == False:
newlist = app.l.ids['missing'].adapter.data
newlist.remove(instance.text)
#app.l.ids['missing'].adapter = SimpleListAdapter(data= newlist, cls= ListItemLabel)
print 'newlist is: ', newlist
the list logic is working, but the adapter assignment fails with this error: Exception: list adapter: data must be a tuple or list
@amalgamatedclyde
amalgamatedclyde / gist:6996968
Created October 15, 2013 19:06
here is the def build (self):
def build(self):
l= Builder.load_file('grd7.kv')
m= Builder.load_file('studentlist3.kv')
carousel = Carousel(direction='right')
carousel.add_widget(l)
carousel.add_widget(m)
popup = Popup(title='Please select a waypoint',
content = Button(text='close window'),
size_hint=(None, None), size=(400, 400))
@amalgamatedclyde
amalgamatedclyde / gist:7009061
Created October 16, 2013 14:58
simplest callback ever
FloatLayout:
Popup:
id: popup1
Button:
text: ('button pressed')
on_release: root.remove_widget(popup1)
#on_release: popup1.dismiss(force=True)
@amalgamatedclyde
amalgamatedclyde / gist:7009760
Created October 16, 2013 15:35
popup attaches to window behind all other widgets
def build(self):
l= Builder.load_file('grd7.kv')
m= Builder.load_file('studentlist3.kv')
carousel = Carousel(direction='right')
carousel.add_widget(l)
carousel.add_widget(m)
popup = Popup(title='Please select a waypoint',
content = Button(text='close window'),
size_hint=(None, None), size=(400, 400))
@amalgamatedclyde
amalgamatedclyde / gist:7232905
Created October 30, 2013 13:43
args converter
def my_args_converter(row_index, rec):
dict = {'text': rec.is_selected,
'font_size':100,
'padding_x': 100,
'halign': 'left',
'size_hint_y': None,
'cls_dicts': [{'cls': ImageButton, 'kwargs': {'text': str(rec[0])+', '+ rec[1], 'source': '/home/clyde/' + rec[3],'is_selected': rec.is_selected, 'size_hint': (.175,1),
'border_color': [0,0,0,1], 'deselected_color': [3,0,0,1], 'selected_color': [0, 6,.0,1], 'on_release' : callback4}},
{'cls': ListItemLabel,
'kwargs': {'text': str(rec.is_selected), 'font_size': 24,
@amalgamatedclyde
amalgamatedclyde / gist:7270268
Created November 1, 2013 19:03
this is wrong. i couldn't just add L65 because child was outside of the scope. and i needed bind_selection_from_children = BooleanProperty(True) then i got two lists if i didn't delete the self.add_widget line
class MyCompositeListItem(ButtonBehavior, CompositeListItem):
bind_selection_from_children = BooleanProperty(True)
def __init__(self, **kwargs):
super(MyCompositeListItem, self).__init__(**kwargs)
# There is an index to the data item this composite list item view
# represents. Get it from kwargs and pass it along to children in the
# loop below.
@amalgamatedclyde
amalgamatedclyde / gist:7270782
Created November 1, 2013 19:37
still not right
class MyCompositeListItem(ButtonBehavior, CompositeListItem):
bind_selection_from_children = BooleanProperty(True)
def __init__(self, **kwargs):
super(MyCompositeListItem, self).__init__(**kwargs)
ButtonBehavior.__init__(self, **kwargs)
# There is an index to the data item this composite list item view
# represents. Get it from kwargs and pass it along to children in the
@amalgamatedclyde
amalgamatedclyde / gist:7272001
Created November 1, 2013 21:09
this is the current state of my subclass and args_converter.
class MyCompositeListItem(CompositeListItem):
def __init__(self, **kwargs):
super(MyCompositeListItem, self).__init__(**kwargs)
is_selected = kwargs['is_selected']
##########
def my_args_converter(row_index, rec):
dict = {'text': '',
'is_selected': rec.is_selected,
for cls_dict in kwargs['cls_dicts']:
cls = cls_dict['cls']
cls_kwargs = cls_dict.get('kwargs', None)
if cls_kwargs:
cls_kwargs['index'] = index
cls_kwargs['is_selected'] = is_selected
if 'selection_target' not in cls_kwargs:
cls_kwargs['selection_target'] = self