This file contains hidden or 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 | |
''' | |
Demo of using the built-in iOS dictionary to check words | |
NOTES: This is quite slow, it might be possible to use the spell-checking | |
dictionary for this instead, haven't tried that yet. | |
If no dictionary is downloaded yet, the API will always return True | |
(probably so that the "Define" menu item can be shown before | |
a dictionary has been downloaded). | |
''' |
This file contains hidden or 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 | |
''' | |
This is a little helper script to make it easier | |
to create single-file scripts with Pythonista, while | |
still taking advantage of the UI editor. | |
It'll essentially convert the .pyui file to a compact | |
string representation that you can embed directly | |
in your script. The code to unpack and load the UI | |
is also auto-generated for convenience. |
This file contains hidden or 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 hidden or 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 ui | |
import os | |
from objc_util import ObjCInstance, ObjCClass | |
from operator import attrgetter | |
import time | |
import threading | |
import functools | |
import ftplib | |
import re |
This file contains hidden or 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 | |
# Barcode scanner demo for Pythonista | |
# Based on http://www.infragistics.com/community/blogs/torrey-betts/archive/2013/10/10/scanning-barcodes-with-ios-7-objective-c.aspx | |
from objc_util import * | |
from ctypes import c_void_p | |
import ui | |
import sound | |
found_codes = set() |
This file contains hidden or 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 | |
from objc_util import * | |
import console | |
import urllib | |
import dialogs | |
WKWebView = ObjCClass('WKWebView') | |
UIViewController = ObjCClass('UIViewController') | |
UIBarButtonItem = ObjCClass('UIBarButtonItem') | |
NSURLRequest = ObjCClass('NSURLRequest') |
This file contains hidden or 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 hidden or 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 | |
from objc_util import * | |
import threading | |
NSBundle = ObjCClass('NSBundle') | |
LocalAuthentication = NSBundle.bundleWithPath_('/System/Library/Frameworks/LocalAuthentication.framework') | |
LocalAuthentication.load() | |
LAContext = ObjCClass('LAContext') | |
# authenticate() will raise one of these exceptions when authentication |
This file contains hidden or 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 | |
''' | |
Basic theme editor for Pythonista 1.6 (beta) | |
WARNING: Use at your own risk! User themes aren't "officially" supported, and | |
this may break in future versions. If you enter invalid JSON or anything else | |
that the app can't deal with, it *will* crash -- your input is not validated | |
in any way. | |
''' |
This file contains hidden or 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
# Utility functions for setting UI/syntax highlighting theme in Pythonista (1.6 beta) using objc_util. WARNING: This relies on some internals that may change in the future. | |
# When run as a script, it toggles between the default (light) theme and Tomorrow-Dark. | |
from objc_util import * | |
import os | |
import glob | |
def get_theme_names(): | |
res_path = str(ObjCClass('NSBundle').mainBundle().resourcePath()) | |
theme_paths = glob.glob(os.path.join(res_path, 'Themes2/*.json')) |