Skip to content

Instantly share code, notes, and snippets.

View amalgamatedclyde's full-sized avatar

Clyde Tressler amalgamatedclyde

View GitHub Profile
@amalgamatedclyde
amalgamatedclyde / gist:7517620
Created November 17, 2013 20:04
instantiating dynamic class
if i use this loop outside of def build(self): i get this: kivy.factory.FactoryException: Unknown class <TravelerBtn>
if i change the widget in the for loop to 'Button,' i get 24 buttons in the stacklayout with the propertext.
if i use the loop within 'def build (self):', i can't set the text value of the <TravelerBtn> instances.
def build (self):
for i in range(25):
i = Factory.TravelerBtn(text =str(i))
rootwidget.add_widget(i)
@amalgamatedclyde
amalgamatedclyde / gist:7417537
Created November 11, 2013 18:07
why is the window dying
I/python (10499): Android kivy bootstrap done. __name__ is __main__
I/python (10499): Run user program, change dir and execute main.py
I/python (10499): [INFO ] Kivy v1.8.0-dev
I/python (10499): [INFO ] [Logger ] Record log in /data/data/org.test.myapp/files/.kivy/logs/kivy_13-11-11_4.txt
I/python (10499): [INFO ] [Factory ] 156 symbols loaded
I/python (10499): [DEBUG ] [Cache ] register <kv.image> with limit=None, timeout=60s
I/python (10499): [DEBUG ] [Cache ] register <kv.atlas> with limit=None, timeout=Nones
I/python (10499): /data/data/org.test.myapp/files/lib/python2.7/site-packages/kivy/core/image/img_pygame.py:12: RuntimeWarning: import cdrom: No module named cdrom
I/python (10499): (ImportError: No module named cdrom)
I/python (10499): [INFO ] [Image ] Providers: img_tex, img_dds, img_pygame, img_pil, img_gif
@amalgamatedclyde
amalgamatedclyde / gist:7402071
Created November 10, 2013 18:41
list args_conv
def my_args_converter(row_index, rec):
dict = {'text': '',
'index': rec[4],
'is_selected': rec.is_selected,
'padding_x': 100,
'halign': 'left',
'size_hint_y': None,
'cls_dicts': [{'cls': ImageButton, 'kwargs': {'source': rec[3], 'masterIndex': rec[4], 'size_hint': (.175,1),
'border_color': [0,0,0,1], 'deselected_color': [3,0,0,1], 'selected_color': [0, 6,.0,1], 'is_selected': rec.is_selected,'on_release' : callback}},
{'cls': MyListItemLabel,
@amalgamatedclyde
amalgamatedclyde / gist:7306522
Created November 4, 2013 17:50
two callbacks. the first does not refresh the listview, the second does
def callback(instance):
global names
global missing
global missinglist
names[instance.masterIndex].is_selected = not(names[instance.masterIndex].is_selected)
print names[instance.masterIndex].is_selected, names[instance.masterIndex]
for item in missing:
if names[instance.masterIndex] in missing:
@amalgamatedclyde
amalgamatedclyde / gist:7278538
Created November 2, 2013 12:44
here is the args_converter and the kv line for the listview
def my_args_converter(row_index, rec):
dict = {'text': '',
'index': rec[4],
'is_selected': rec.is_selected,
'padding_x': 100,
'halign': 'left',
'size_hint_y': None,
'cls_dicts': [{'cls': ImageButton, 'kwargs': {'source': '/home/clyde/' + rec[3], 'index': rec[4], 'size_hint': (.175,1),
'border_color': [0,0,0,1], 'deselected_color': [3,0,0,1], 'selected_color': [0, 6,.0,1], 'on_release' : callback}},
{'cls': ListItemLabel,
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
@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,
@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: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: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,