Skip to content

Instantly share code, notes, and snippets.

# coding: utf-8
# Stub generator for ui module
# NOTES:
# * For classes, the base class is always assumed to be `object`. This isn't correct, but it shouldn't matter much because the
# generated stubs also contain inherited methods and data descriptors. Using the actual base classes would complicate things a
# little because the class definitions would have to appear in the correct order then.
# * It's not possible to get correct argspecs for functions and methods that are implemented in C, so they're always just
# `self, *args` (for bound methods) or `*args*` (for module-level functions) in the output.
import ui
@omz
omz / Untitled 4.py
Created January 2, 2014 15:05
Untitled 4
import console
import clipboard
import os
img = clipboard.get_image()
if img:
img.save('temp.jpg')
console.quicklook('temp.jpg')
os.remove('temp.jpg')
else:
@omz
omz / HowOld.py
Created May 1, 2015 10:43
HowOld.py
# coding: utf-8
# Batch-upload script for how-old.net (Pythonista)
import photos
import requests
import json
import ui
from io import BytesIO
result_size = 320
@omz
omz / Drum Machine.py
Created November 7, 2012 21:03
Drum Machine
#TODO: Adjust size to screen size (iPhone)
#TODO: Clear (and random, play/pause?) buttons
from scene import *
from sound import play_effect, set_volume, load_effect
from colorsys import hsv_to_rgb
import pickle
class DrumMachine (Scene):
def setup(self):
@omz
omz / SlimIt-Installer.py
Created October 21, 2013 17:11
SlimIt-Installer
ply_url = 'https://pypi.python.org/packages/source/p/ply/ply-3.4.tar.gz'
slimit_url = 'https://pypi.python.org/packages/source/s/slimit/slimit-0.8.1.zip'
print 'Downloading SlimIt...'
from urllib import urlretrieve
import tarfile
import zipfile
import shutil
import os
try:
@omz
omz / Meme Generator 2.py
Created November 7, 2012 21:01
Meme Generator 2
import Image
import ImageChops
import ImageDraw
import ImageFont
import ImageFilter
import clipboard
def draw_caption(img, text, outline=2, top=False):
text_img = Image.new('RGBA', img.size, (0, 0, 0, 0))
draw = ImageDraw.Draw(text_img)
/*
Batch-Rename Layers -- plugin for Sketch 2 (http://www.bohemiancoding.com/sketch/)
INSTALLATION
------------
Select "Reveal Plugins Folder..." in the "Plugins" menu,
then put this file in the folder that shows up in the Finder.
@omz
omz / Height map 1.py
Created February 29, 2016 19:15
Height map 1.py
# coding: utf-8
# Optimized version of the code in this forum post: https://forum.omz-software.com/topic/2850/2-problems-with-shape-nodes-and-sprite-nodes
from scene import *
import random
import ui
import math
def render_bottom_texture(width=100.0):
@omz
omz / CFNetworkProxySettings.py
Created July 26, 2015 13:25
CFNetworkProxySettings.py
# Print system proxy settings using CFNetwork
# NOTE: Requires Pythonista 1.6 (currently in beta)
from objc_util import *
CFNetworkCopySystemProxySettings = c.CFNetworkCopySystemProxySettings
CFNetworkCopySystemProxySettings.restype = c_void_p
CFNetworkCopySystemProxySettings.argtypes = []
proxy_settings = ObjCInstance(CFNetworkCopySystemProxySettings())
@omz
omz / Sound Demo.py
Created April 7, 2014 16:40
Sound Demo
# Simple demo of playing a looping sound using the (currently undocumented) sound.Player class
import sound
import os
from scene import *
class MyScene (Scene):
def setup(self):
self.player = sound.Player(os.path.expanduser('~/Pythonista.app/Beep.caf'))
self.player.number_of_loops = -1 #repeat forever