Skip to content

Instantly share code, notes, and snippets.

@kived
kived / my.kv
Last active May 31, 2016 21:09
Kivy: referencing widgets
BoxLayout:
NavBar:
sm: screen_manager
ScreenManager:
id: screen_manager
@kived
kived / texrottest.py
Created May 2, 2016 20:34
Kivy: rotate texture
import kivy
kivy.require('1.8.1')
from kivy.app import App
from kivy.lang import Builder
root = Builder.load_string('''
FloatLayout:
Widget:
pos_hint: {'center_x': 0.5, 'center_y': 0.5}
@kived
kived / myapp.py
Created April 25, 2016 19:17
Kivy: reschedule for kv id
def property_handler(self, inst, value):
try:
widget = self.ids.widget_id
except AttributeError:
Clock.schedule_once(lambda dt: self.property_handler(inst, value))
else:
widget.some_value = value
@kived
kived / main.py
Created April 15, 2016 20:19
Kivy: Android unicode test
import kivy
kivy.require('1.9.1')
from kivy.app import App
from kivy.lang import Builder
from kivy.properties import StringProperty
from os.path import join, dirname
root = '''
Button:
@kived
kived / dialog.kv
Created April 11, 2016 20:16
Kivy: auto-sized dialog
<AppDialog>:
size_hint: 1, None
height: grid.minimum_height
GridLayout:
id: grid
size_hint_x: 0.8
size_hint_y: None
height: self.minimum_height
on_height: root._align_center()
from twisted.internet.protocol import Protocol, ClientFactory
from twisted.internet.defer import inlineCallbacks
from twisted.internet.threads import deferToThread
import pdb
# audio imports
import pyaudio,wave
class AudioClientFactory(ClientFactory):
def __init__(self, canvas_obj):
self.canvas_obj = canvas_obj
@kived
kived / dictupdatetest.py
Created April 6, 2016 17:02
Kivy: DictProperty updating widgets
import kivy
kivy.require('1.8.1')
from kivy.app import App
from kivy.lang import Builder
from kivy.properties import DictProperty
from kivy.clock import Clock
from random import random
root = '''
@kived
kived / separator.kv
Last active March 18, 2021 20:18
Kivy: Separator widgets
<Separator@Widget>:
canvas:
Color:
rgba: 1, 1, 1, 1
Rectangle:
pos: self.pos
size: self.size
<HSeparator@Separator>:
size_hint_y: None
@kived
kived / cbcentral.h
Created April 3, 2016 21:31
CBCentralManager code
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
@interface cbcentral : NSObject<CBCentralManagerDelegate> {
CBCentralManager* central;
NSMutableArray* events;
NSLock* eventlock;
NSMutableArray* _peripherals;
CBPeripheral* _connecting;
}
@kived
kived / animtest.py
Created March 24, 2016 17:35
Kivy: precision animation
import kivy
kivy.require('1.8.1')
from kivy.app import App
from kivy.lang import Builder
from kivy.clock import Clock
from kivy.utils import interpolate
from time import time
root = Builder.load_string('''