Skip to content

Instantly share code, notes, and snippets.

View tito's full-sized avatar

Mathieu Virbel tito

View GitHub Profile
@tito
tito / focusable_widgets.py
Last active June 7, 2022 22:32
Kivy focusable widgets
# coding=utf-8
from kivy.uix.behaviors import FocusBehavior
from kivy.uix.checkbox import CheckBox
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
from kivy.lang import Builder
Builder.load_string("""
#:import rgb kivy.utils.get_color_from_hex
<FocusableCheckBox,FocusableButton,FocusableTextInput>:
@tito
tito / progressspinner.py
Created February 4, 2016 17:29
ProgressSpinner using fontello
'''
Font-based ProgressSpinner
==========================
'''
from kivy.lang import Builder
from kivy.properties import NumericProperty, BooleanProperty, StringProperty
from kivy.clock import Clock
from kivy.uix.widget import Widget
@tito
tito / redisviewer.py
Last active March 16, 2023 01:48
Redis pubsub viewer
import redis
import sys
host = sys.argv[1]
room = sys.argv[2]
print "-- connect to redis"
client = redis.Redis(host=host)
pubsub = client.pubsub()
pubsub.subscribe(room)
print "-- listen to {}".format(room)
@tito
tito / image_hook.py
Created October 5, 2015 21:44
Image: control direction of animation (normal or reverse). Great to have open/close animation
from functools import partial
def coreimage_animation(self, *largs):
# accept reverse direction
if not self._image:
return
textures = self.image.textures
self._texture = self.image.textures[self._anim_index]
self.dispatch('on_texture')
self._anim_index += self._anim_direction
@tito
tito / router-example.py
Last active May 15, 2018 05:04
Kivy Router (tests)
# coding=utf-8
from kivy.app import App
from kivy.properties import StringProperty
from kivy.uix.relativelayout import RelativeLayout
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder
from kivy.logger import Logger
import re
@tito
tito / main.py
Last active July 21, 2021 14:31
iBeacon iOS 8 Scanner (python / pyobjus / kivy), using ranging API
# coding=utf-8
"""
iBeacon Scanner
===============
This scanner works exclusively on iOS real devices, simulator don't support
iBeacon ranging API at all.
The usage is quite simple:
@tito
tito / threaded_decorator.py
Last active August 31, 2015 20:09
Threaded decorator for kivy with callback
import threading
from kivy.clock import mainthread
def threaded(callback):
def _threaded(f):
def _threaded_callback(*args, **kwargs):
def _run_in_threaded_callback(*args, **kwargs):
ret = f(*args, **kwargs)
mainthread(callback)(ret)
thread = threading.Thread(target=_run_in_threaded_callbacks, args=args, kwargs=kwargs)
@tito
tito / automateclient.py
Created August 30, 2015 14:32
Kivy Automation
# coding=utf-8
"""
Automation client for automatesocket.py
=======================================
"""
import socket
import struct
import json
@tito
tito / threading_jnius.py
Last active January 24, 2016 16:55
Detect Thread exit to run jnius.detach() on Android
# Goal: detect when a thread exit to call jnius.detach()
# and prevent crash from Android/ART
# So we listen to "return" events from the "run" function of the threading.Thread
# The profiling function given to threading.set_profilefunc() is installed in the
# thread before the run() function of the Thread.
# All we need to do is filter on "return" event of the "run" function for the
# original Thread.run() of Python's threading.py
# ERROR: it doesn't detect when a thread crash (python exception)
@tito
tito / console.py
Created June 20, 2015 18:49
Console (inspector reboot)
# coding=utf-8
"""
Console
=======
Reboot of the old inspector, designed to be modular and keep concerns separated.
Open with control+e (or cmd+e on OSX).
.. versionadded:: 1.9.1