Skip to content

Instantly share code, notes, and snippets.

View amalgamatedclyde's full-sized avatar

Clyde Tressler amalgamatedclyde

View GitHub Profile
@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,
@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: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: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: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)
# Install distribute
# Run 'curl http://python-distribute.org/distribute_setup.py | venv/bin/python'
# Cwd /home/clyde/buildozer/.buildozer
/bin/sh: 1: curl: not found
# Install requirement datetime in virtualenv
# Run 'pip-2.7 install --download-cache=/home/clyde/.buildozer/cache --target=/home/clyde/buildozer/.buildozer/applibs datetime'
# Cwd /home/clyde/buildozer/.buildozer
Traceback (most recent call last):
File "/home/clyde/buildozer/.buildozer/venv/bin/pip-2.7", line 5, in <module>
from pkg_resources import load_entry_point
clyde@clyde-N55SF:/home/kivy$ sudo make
python setup.py build_ext --inplace
[INFO ] Kivy v1.8.0-dev
Found GLES 2.0 headers at /usr/include/GLES2/gl2.h
running build_ext
Build configuration is:
* use_opengl_es2 = True
* use_sdl = False
* use_glew = False
* use_rpi = False
I/python (14371): File "/home/clyde/buildozer/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/uix/textinput.py", line 1009, in on_focus
I/python (14371): File "/home/clyde/buildozer/.buildozer/android/platform/python-for-android/build/python-install/lib/python2.7/site-packages/kivy/core/window/window_pygame.py", line 378, in request_keyboard
I/python (14371): File "_android.pyx", line 190, in android._android.show_keyboard (android/_android.c:2286)
I/python (14371): TypeError: show_keyboard() takes exactly 2 positional arguments (0 given)
I/python (14371): Python for android ended.
I/AndroidRuntime(14371): VM exiting with result code 0, cleanup skipped.
@amalgamatedclyde
amalgamatedclyde / gist:7894289
Created December 10, 2013 17:12
here is an example
mylistobj.adapter = ListAdapter(data= sorted([item[0]+','+ item[1] for item in missing]), args_converter= args_conv, cls= ListItemButton)
@amalgamatedclyde
amalgamatedclyde / gist:8163247
Created December 28, 2013 19:35
i did not write this code. it was a demo posted somewhere
import kivy
kivy.require('1.8.0')
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.camera import Camera
from kivy.uix.button import Button
from kivy.core.window import Window
class MyApp(App):