Skip to content

Instantly share code, notes, and snippets.

View tito's full-sized avatar

Mathieu Virbel tito

View GitHub Profile
@tito
tito / poll_delegate_objus.py
Created February 1, 2014 15:19
Which delegate usage would be the best to have in Pyobjus ?
# Solution 1
# original solution proposed in the PR
# pro: easy declaration
# cons: instanciation is a little bit hard to write
# possible method conflict with multiple protocols
class MyObjcDelegate:
def connection_didFailWithError_(self, connection, error):
print("Protocol method got called!!", connection, error)
@tito
tito / gist:9092028
Created February 19, 2014 13:31
Cython VS Python Bytecode
$ ls -lah scatter.py
-rw-rw-r-- 1 tito tito 19K févr. 11 15:13 scatter.py
$ python -OO -m compileall scatter.py
$ ls -lah scatter.pyo
-rw-rw-r-- 1 tito tito 12K févr. 19 14:27 scatter.pyo
$ cython scatter.py
$ gcc $(pkg-config --libs --cflags python) -fPIC -shared -o scatter.so scatter.c
$ ls -lah scatter.so
----- pid 10622 at 2014-03-19 17:19:32 -----
Cmd line: com.meltingrocks.kivy2048:python
JNI: CheckJNI is off; workarounds are off; pins=0; globals=727
DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0)
"main" prio=5 tid=1 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x41586ca8 self=0x414c0408
doc/sources/installation/installation-linux.rst
394: $ python main.py
399: $ python main.py
413:If you wish to start your Kivy programs as scripts (by typing `./main.py`) or by double-clicking them,
422:Then, inside each main.py, add a new first line::
doc/sources/installation/installation-rpi.rst
59: python main.py
64: python main.py
@tito
tito / smoothline.py
Created May 22, 2014 23:25
Experimentation for Smooth Line with overdraw/alpha
from kivy.properties import NumericProperty
from kivy.graphics import Mesh, Line, Rectangle, ClearBuffers
from kivy.graphics.texture import Texture
from kivy.graphics.fbo import Fbo
from kivy.uix.widget import Widget
from kivy.uix.label import Label
from kivy.app import App
from math import pi, atan2, cos, sin
from kivy.clock import Clock
def on_index_pos(self, instance, index_pos):
slide = self.current_slide
if not hasattr(self, '_old_slide'):
self._old_slide = None
if self._old_slide:
self._old_slide.is_focused = False
if slide:
slide.is_focused = True
self._old_slide = slide
self.ensure_slides()
@tito
tito / animator.py
Last active August 29, 2015 14:04
Animator / Timeline execution (early poc)
"""
Animator
========
An `Animator` describe an event timeline that can be executed in top of any
widget. An `Executor` is responsible of executing an `Animator` on a `Widget`.
.. todo::
- relative attribute movement
@tito
tito / README
Last active August 29, 2015 14:06
pyjnius / allow customization of the JNIENV function to get
P4A_pyjnius_DIR=~/code/pyjnius ./distribute.sh -b minimal -m 'pyjnius python' -u pyjnius
cd .; ./build.py --package org.minimal.test --name _MINIMAL --version 1 --private ~/code/testmininal --asset debug installd
adb logcat *:S python:D
@tito
tito / selector.py
Last active August 29, 2015 14:06
Selector: brainstorming around a possible selector
import operator
from types import GeneratorType
from kivy.compat import string_types, iteritems
class Selector(object):
def __init__(self, children=[]):
super(Selector, self).__init__()
if not isinstance(children, (list, tuple, GeneratorType)):
self.children = (children, )
@tito
tito / main-interp.py
Created January 14, 2015 17:22
Touchtracer with interpolated input value
#!/usr/bin/kivy
__version__ = '1.0'
import kivy
kivy.require('1.0.6')
from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.label import Label
from kivy.graphics import Color, Rectangle, Point, GraphicException