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
# example of custom touch dispatch module | |
import ui | |
# wrapper class for Touch, since ui.Touch is readonly | |
class Touch(object): | |
def __init__(self,touch): | |
self.location=touch.location | |
self.touch_id=touch.touch_id | |
self.phase=touch.phase | |
self.prev_location=touch.prev_location |
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 ui | |
class Touch(object): | |
''' writable version of ui.Touch''' | |
def __init__(self,touch): | |
self.location=touch.location | |
self.touch_id=touch.touch_id | |
self.phase=touch.phase | |
self.prev_location=touch.prev_location | |
self.timestamp=touch.timestamp |
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 ui | |
class Touch(object): | |
''' writable version of ui.Touch''' | |
def __init__(self,touch): | |
self.location=touch.location | |
self.touch_id=touch.touch_id | |
self.phase=touch.phase | |
self.prev_location=touch.prev_location | |
self.timestamp=touch.timestamp |
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
''' | |
useless path editor. | |
tap to add a point. tap again to add a control point. | |
then, another control point, and finally another point on the curve. | |
existing points and control points can be dragged around, to change the curve. | |
clicking save button saves an image of the path, without the handles. | |
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
class world (object): | |
def webview_should_start_load(self,webview, url, nav_type): | |
if url.startswith('world://'): | |
print 'country selected:', urlparse.unquote(urlparse.urlparse(url).netloc) | |
return False | |
else: | |
return True | |
import ui,os | |
w=ui.WebView() |
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
# Source: https://gist.github.com/5212628 | |
# | |
# All-purpose gist tool for Pythonista. | |
# | |
# When run directly, this script sets up four other scripts that call various | |
# functions within this file. Each of these sub-scripts are meant for use as | |
# action menu items. They are: | |
# | |
# Set Gist ID.py - Set the gist id that the current file should be | |
# associated with. |
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 | |
import objc_util | |
from objc_util import * | |
# setup an array of objects we cannot discard | |
objc_util.retain=getattr(objc_util,'retain',[]) | |
root_vc = UIApplication.sharedApplication().keyWindow().rootViewController() | |
def mailComposeController_didFinishWithResult_error_(self, sel, controller, result, error): | |
root_vc.dismissModalViewControllerAnimated_(True) |
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 | |
import console,ui | |
ptype=console.alert('select present type','select one','fullscreen','panel','sheet') | |
ptypes=('fullscreen','panel','sheet') | |
class KBTest(ui.View): | |
def __init__(self): | |
self.kb_callback=None | |
self.frame=(0,0,768,768) | |
self.flex='wh' |
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- | |
import ui,time | |
def setup_view(v): | |
''' a very slow and complicated setup''' | |
for i in xrange(10): | |
b=ui.Button(bg_color=(1,i/20.,0)) | |
b.frame=(200,0,50,50) | |
b.y=i*50 | |
v.add_subview(b) |
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- | |
import ui,time | |
def setup_view(v): | |
''' a very slow and complicated setup''' | |
for i in xrange(10): | |
b=ui.Button(bg_color=(1,i/20.,0)) | |
b.frame=(200,0,50,50) | |
b.y=i*50 | |
v.add_subview(b) |