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
# Play a blues melody on Pythonista on the iPad (iOS) | |
import sound | |
import time | |
def playNotes(inNotes, inWithEmphisis=False): | |
for note in inNotes: | |
sound.play_effect('Piano_' + note) | |
if (inWithEmphisis): | |
time.sleep(0.25) | |
sound.play_effect('Piano_' + note) |
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
#!/usr/bin/env python | |
# installNyamuk -- https://github.com/iwanbk/nyamuk | |
# download from github the nyamuk Python library and install it for Pythonista on iOS | |
#import nyamuk, sys # uncomment if you want to test if nyamuk is already installed | |
#print('got it...') | |
#sys.exit() | |
import os, shutil, urllib, zipfile |
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
from scene import * | |
from random import random | |
class MyScene (Scene): | |
def setup(self): | |
# This will be called before the first frame is drawn. | |
self.root_layer = Layer(self.bounds) | |
self.mLines = [] | |
self.mCount = 0 | |
(self.mCurrLocX, self.mCurrLocY) = self.bounds.center() |
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
# http://omz-forums.appspot.com/pythonista/post/5144563366756352 | |
import random, scene | |
sizeInPixels = 100 | |
def rectFromPt(inPoint): # returns a scene.Rect centered on inPoint | |
half = sizeInPixels / 2 | |
return scene.Rect(inPoint.x - half, inPoint.y - half, sizeInPixels, sizeInPixels) | |
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
# replace ALL tab characters with four spaces | |
import editor, sys | |
theText = editor.get_text() | |
theCount = theText.count('\t') | |
if not theText.count('\t'): | |
print('no tabs found.') | |
sys.exit() | |
theLength = len(theText) |
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
#!/usr/bin/env python | |
# For details, in Mac OS X Terminal type: man pbcopy | |
import subprocess, sys | |
def getClipboardData(): # Only works for data types: {txt | rtf | ps} | |
p = subprocess.Popen(['pbpaste'], stdout=subprocess.PIPE) | |
retcode = p.wait() | |
data = p.stdout.read() |
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 canvas, scene | |
from contextlib import contextmanager | |
@contextmanager | |
def privateGstate(): | |
"""Save the canvas.gstate and then restore it when leaving the 'with' clause.""" | |
canvas.save_gstate() | |
try: yield None | |
finally: canvas.restore_gstate() |
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
Moved to: https://github.com/cclauss/Pythonista_scene |
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
# Update: This looks like a far better solution... | |
# `console.set_idle_timer_disabled(flag)` | |
# Disable or enable the idle timer (which puts the device to sleep after a certain period of inactivity). | |
# noDoze.py -- keep relaunching yourself to prevent | |
# your iOS device from falling asleep. | |
import notification, time, urllib | |
def argsString(argv): |
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 scene, threading, time | |
colorRed = scene.Color(1, 0, 0) | |
colorGreen = scene.Color(0, 1, 0) | |
colorBlue = scene.Color(0, 0, 1) | |
theColors = (colorRed, colorGreen, colorBlue) | |
greyLight = scene.Color(.7, .7, .7) | |
greyMedium = scene.Color(.5, .5, .5) | |
greyDark = scene.Color(.3, .3, .3) |
OlderNewer