This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |