Skip to content

Instantly share code, notes, and snippets.

View objc_classes.py
from objc_util import *
import weakref
import functools
''' Attempt at making more natural objc class in pythonista.
decorate python class with @objclass to create an ObjCClass.
set superclass and protocols class attributes, if desired.
View Untitled_5.py
import ui
class PointShowingView(ui.View):
def __init__(self,*args,**kwargs):
ui.View.__init__(self,*args,**kwargs)
self.p=(150,150)
self.color=(0.5,0.5,.5)
def draw(self):
ui.set_color(self.color)
ui.Path.rect(*self.p,100,100).fill()
View Untitled_215.py
# coding: utf-8
from objc_util import *
import ui
def printMethods(whichObject):
#print (dir(whichObject))
for method in dir(whichObject):
View multirecord.py
import sound
import ui
from math import floor
class RecorderView(ui.View):
'''simple metering view, attached to a recorder'''
def __init__(self, filename, callback=None, *args,**kwargs):
ui.View.__init__(self,*args,**kwargs)
View multirecord.py
import sound
import ui
from math import floor
class RecorderView(ui.View):
'''simple metering view, attached to a recorder'''
def __init__(self, filename, *args,**kwargs):
ui.View.__init__(self,*args,**kwargs)
@jsbain
jsbain / notification_center.py
Created Nov 18, 2018
notification_center.py
View notification_center.py
from objc_util import *
import console
from functools import partial
NSNotificationCenter=ObjCClass('NSNotificationCenter')
#logging.basicConfig(filename='log.txt',format='%(levelname)s:%(message)s', level=logging.DEBUG)
class NotificationObserver(object):
View audiounit_lib.py
from ctypes import *
from objc_util import c
AudioUnitRenderActionFlags=c_uint32
OSStatus=c_int32
OSType=c_uint32
class SMPTETimeType(c_uint32):
kSMPTETimeType24 = 0
kSMPTETimeType25 = 1
kSMPTETimeType30Drop = 2
kSMPTETimeType30 = 3
View audiounittest2.py
from objc_util import *
from ctypes import *
from coreaudioconstants import *
import time
import numpy as np
''' Adapted from https://www.cocoawithlove.com/2010/10/ios-tone-generator-introduction-to.html
'''
AudioUnitRenderActionFlags=c_uint32
View audiounittest2.py
from objc_util import *
from ctypes import *
from coreaudioconstants import *
import time
import numpy as np
''' Adapted from https://www.cocoawithlove.com/2010/10/ios-tone-generator-introduction-to.html
'''
AudioUnitRenderActionFlags=c_uint32
View iosurface.py
from objc_util import *
from ctypes import *
from contextlib import contextmanager
import ui
import numpy as np
''' define ctypes signatures'''
IOSurfaceCreate=c.IOSurfaceCreate
IOSurfaceCreate.argtypes=[c_void_p]
IOSurfaceCreate.restype=c_void_p