SlideShare a Scribd company logo
Pythonista
iOS
@jbking
PyCon JP 2017
Who?
@jbking
Yarch( )
ex-OpenStacker
IoT Platform
Pythonista
?
Pythonistaで始めるiOSプロトタイプ開発
Pythonista
• Pythonista: A full-featured Python environment for iOS devices
• europython 2014 https://ep2014.europython.eu/en/
schedule/sessions/109/
• Pythonista Pythonista 

iOS Pythonista
• https://pycon.jp/2016/ja/schedule/presentation/47/ PyCon
JP 2016
• Pythonista
• PyCon mini Kumamoto
(1)
•
•
• Pythonista iOS
• iOS Pythonista
•
• NumPy SymPy, SimPy, Matplotlib
• StaSh
• , Git
(2)
•
• iOS Python
•
• Python
• Objective-C
• iOS
Pythonista
iOS
•
• Xcode
•
• AppStore ?
•
• Xcode https://github.com/omz/
PythonistaAppTemplate
• Python
Pythonista iOS
• Pythonista Python
• iOS Framework Python
•
•
Python
Yes
No
Pythonista
No
Yes
C
iOS objc_util
No
Yes
Yes
No
• Pythonista
•
• (BLE)
• iOS
• ( , C/S)
• GPIO
•
• Python
• NG
• iOS Pythonista
• objc_util
• ( Framework … )
•
•
objc_util ???
objc_util
• Pythonista
• Objective-C
•
• iOS
• objc_msgSend
Framework
from objc_util import *
NSBundle.bundleWithPath_('/System/Library/
Frameworks/Photos.framework').load()
AVFoundation.framework AVKit.framework Accelerate.framework Accounts.framework AdSupport.framework
AddressBook.framework AddressBookUI.framework AssetsLibrary.framework AudioToolbox.framework
AudioUnit.framework CFNetwork.framework CallKit.framework CloudKit.framework Contacts.framework
ContactsUI.framework CoreAudio.framework CoreAudioKit.framework CoreBluetooth.framework CoreData.framework
CoreFoundation.framework CoreGraphics.framework CoreImage.framework CoreLocation.framework
CoreMIDI.framework CoreMedia.framework CoreMotion.framework CoreSpotlight.framework CoreTelephony.framework
CoreText.framework CoreVideo.framework EventKit.framework EventKitUI.framework ExternalAccessory.framework
Foundation.framework GLKit.framework GSS.framework GameController.framework GameKit.framework
GameplayKit.framework HealthKit.framework HealthKitUI.framework HomeKit.framework IOKit.framework
ImageIO.framework Intents.framework IntentsUI.framework JavaScriptCore.framework LocalAuthentication.framework
MapKit.framework MediaAccessibility.framework MediaPlayer.framework MediaToolbox.framework
MessageUI.framework Messages.framework Metal.framework MetalKit.framework
MetalPerformanceShaders.framework MobileCoreServices.framework ModelIO.framework
MultipeerConnectivity.framework NetworkExtension.framework NewsstandKit.framework NotificationCenter.framework
OpenAL.framework OpenGLES.framework PassKit.framework Photos.framework PhotosUI.framework
PushKit.framework QuartzCore.framework QuickLook.framework ReplayKit.framework SafariServices.framework
SceneKit.framework Security.framework Social.framework Speech.framework SpriteKit.framework StoreKit.framework
System.framework SystemConfiguration.framework Twitter.framework UIKit.framework UserNotifications.framework
UserNotificationsUI.framework VideoSubscriberAccount.framework VideoToolbox.framework
WatchConnectivity.framework WebKit.framework iAd.framework
from objc_util import *
UIScreen = ObjCClass('UIScreen')
screen = UIScreen.mainScreen()
if screen.brightness() < 0.3:
screen.setBrightness_(0.6)
else:
screen.setBrightness_(0.1)
from objc_util import *
def DemoClass_foo_(_self, _cmd, _s):
print('result: %s' % ObjCInstance(_s))
# NSObject
DemoClass = create_objc_class(
'DemoClass',
ObjCClass('NSObject'),
methods=[DemoClass_foo_],
protocols=[])
demo_obj = DemoClass.alloc().init()
demo_obj.foo_("hello")
result: hello
def DemoClass_foo_(_self, _cmd, _s): ...
def bar_baz_(_self, _cmd, _x1, _x2): ...
DemoClass = create_objc_class(
...
methods=[DemoClass_foo_, bar_baz_],
...
demo_obj = DemoClass.alloc().init()
demo_obj.foo_("hello")
demo_obj.bar_baz_(2, 3)
demo_obj.bar_(2, baz=5)
# UIColor.colorWithRed:green:blue:alpha
UIColor.colorWithRed(1.0, green=0.0,
blue=0.0, alpha=1.0)
UIColor.color(red=1.0, green=0.0, blue=0.0,
alpha=1.0)
from objc_util import ObjCClass
def is_word_valid(word):
reflib =
ObjCClass('UIReferenceLibraryViewController')
return reflib.dictionaryHasDefinitionForTerm_(word)
test_words = ['foo', 'bar', 'quuz', 'cat', 'dog']
for word in test_words:
print('%s: %s' % (word, is_word_valid(word)))
foo: False
bar: True
quuz: False
cat: True
dog: True
https://gist.github.com/omz/599ef8aeae22620261c6
from objc_util import *
UIApplication = ObjCClass('UIApplication')
vc =
UIApplication.sharedApplication().keyWindow
().rootViewController()
print(vc.childViewControllers())
<b'__NSArrayI': (
"<UINavigationController: 0x1038db200>",
"<PA2TabViewController: 0x104003000>",
"<PA2AccessoryTabViewController: 0x1038dac00>"
)>
Pythonista
Pythonistaで始めるiOSプロトタイプ開発
Pythonistaで始めるiOSプロトタイプ開発
• objc_util
• iOS Framework
• ObjCClass ObjCInstance
Python
•
•
•
Pythonistaで始めるiOSプロトタイプ開発
IoT
• cb
• BLE
• CoreBluetooth
• Sony MESH
https://youtu.be/uJ6VVklLUQc
https://github.com/jbking/pythonista-misc/blob/master/mesh/button_demo.py
• objc_util
• SpriteKit
(SKPhysicsBody)
https://youtu.be/rS6FHvKrU6Y
https://github.com/jbking/pythonista-misc/blob/master/spritekit/skview-demo.py
•
• ui, Requests
•
• appex, webbrowser,
(pythonista://ScriptName)
tips
•
• view.present(hide_title_bar=True)
•
• CPU
• GPU
•
• Omz gist
• https://gist.github.com/omz/
• Pythonista Tools
• https://github.com/Pythonista-Tools/Pythonista-
Tools
Questions?

More Related Content

What's hot (20)

PDF
GLMM in interventional study at Require 23, 20151219
Shuhei Ichikawa
 
PDF
CV分野におけるサーベイ方法
Hirokatsu Kataoka
 
PPTX
課題設定について
murakami yusuke
 
PDF
【論文調査】XAI技術の効能を ユーザ実験で評価する研究
Satoshi Hara
 
PDF
変分推論と Normalizing Flow
Akihiro Nitta
 
PPTX
(実験心理学徒だけど)一般化線形混合モデルを使ってみた
Takashi Yamane
 
PDF
[DL輪読会]Model soups: averaging weights of multiple fine-tuned models improves ...
Deep Learning JP
 
PPTX
Deep Learningで似た画像を見つける技術 | OHS勉強会#5
Toshinori Hanya
 
PDF
NIPS2017読み会 LightGBM: A Highly Efficient Gradient Boosting Decision Tree
Takami Sato
 
PDF
機械学習 入門
Hayato Maki
 
PDF
PyMCがあれば,ベイズ推定でもう泣いたりなんかしない
Toshihiro Kamishima
 
PDF
バンディット問題の理論とアルゴリズムとその実装
EinosukeIida
 
PPTX
21世紀で最もセクシーな職業!?「データサイエンティスト」の実像に迫る
Takashi J OZAKI
 
PPTX
Zotero紹介
Takara Ishimoto
 
PPTX
[DL輪読会]Set Transformer: A Framework for Attention-based Permutation-Invariant...
Deep Learning JP
 
PDF
トップカンファレンスへの論文採択に向けて(AI研究分野版)/ Toward paper acceptance at top conferences (AI...
JunSuzuki21
 
PDF
因果推論の基礎
Hatsuru Morita
 
PPTX
【DL輪読会】The Forward-Forward Algorithm: Some Preliminary
Deep Learning JP
 
PDF
大規模な組合せ最適化問題に対する発見的解法
Shunji Umetani
 
PPTX
[DL輪読会]Explainable Reinforcement Learning: A Survey
Deep Learning JP
 
GLMM in interventional study at Require 23, 20151219
Shuhei Ichikawa
 
CV分野におけるサーベイ方法
Hirokatsu Kataoka
 
課題設定について
murakami yusuke
 
【論文調査】XAI技術の効能を ユーザ実験で評価する研究
Satoshi Hara
 
変分推論と Normalizing Flow
Akihiro Nitta
 
(実験心理学徒だけど)一般化線形混合モデルを使ってみた
Takashi Yamane
 
[DL輪読会]Model soups: averaging weights of multiple fine-tuned models improves ...
Deep Learning JP
 
Deep Learningで似た画像を見つける技術 | OHS勉強会#5
Toshinori Hanya
 
NIPS2017読み会 LightGBM: A Highly Efficient Gradient Boosting Decision Tree
Takami Sato
 
機械学習 入門
Hayato Maki
 
PyMCがあれば,ベイズ推定でもう泣いたりなんかしない
Toshihiro Kamishima
 
バンディット問題の理論とアルゴリズムとその実装
EinosukeIida
 
21世紀で最もセクシーな職業!?「データサイエンティスト」の実像に迫る
Takashi J OZAKI
 
Zotero紹介
Takara Ishimoto
 
[DL輪読会]Set Transformer: A Framework for Attention-based Permutation-Invariant...
Deep Learning JP
 
トップカンファレンスへの論文採択に向けて(AI研究分野版)/ Toward paper acceptance at top conferences (AI...
JunSuzuki21
 
因果推論の基礎
Hatsuru Morita
 
【DL輪読会】The Forward-Forward Algorithm: Some Preliminary
Deep Learning JP
 
大規模な組合せ最適化問題に対する発見的解法
Shunji Umetani
 
[DL輪読会]Explainable Reinforcement Learning: A Survey
Deep Learning JP
 

Similar to Pythonistaで始めるiOSプロトタイプ開発 (10)

PDF
Pythonistaの使い方
Yusuke Muraoka
 
PPTX
Mobile, Open Source, and the Drive to the Cloud
Dev_Events
 
PPTX
Mobile, Open Source, & the Drive to the Cloud
Dev_Events
 
PDF
[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...
PROIDEA
 
PDF
Try! Swift Tokyo2017
Amy Cheong
 
PDF
Introduction to iOS Penetration Testing
OWASP
 
PDF
FrenchKit: End to End Application Development with Swift
Chris Bailey
 
PDF
Letswift18 키노트
Jung Kim
 
PPTX
How to integrate python into a scala stack
Fliptop
 
PPTX
Server Side Swift
Software Infrastructure
 
Pythonistaの使い方
Yusuke Muraoka
 
Mobile, Open Source, and the Drive to the Cloud
Dev_Events
 
Mobile, Open Source, & the Drive to the Cloud
Dev_Events
 
[CONFidence 2016] Sławomir Kosowski - Introduction to iOS Application Securit...
PROIDEA
 
Try! Swift Tokyo2017
Amy Cheong
 
Introduction to iOS Penetration Testing
OWASP
 
FrenchKit: End to End Application Development with Swift
Chris Bailey
 
Letswift18 키노트
Jung Kim
 
How to integrate python into a scala stack
Fliptop
 
Server Side Swift
Software Infrastructure
 
Ad

More from Yusuke Muraoka (14)

PDF
いかにして問題をとくか
Yusuke Muraoka
 
PDF
私のPythonとの関わりかた
Yusuke Muraoka
 
PDF
Substance D world-plone-day-2017
Yusuke Muraoka
 
PDF
Gunma.web #24 MySQL HA
Yusuke Muraoka
 
PDF
The Substance D - Plone Symposium Tokyo 2015
Yusuke Muraoka
 
PPTX
プロパティディスクリプタとその拡張ライブラリ
Yusuke Muraoka
 
PPTX
Django learning Part2
Yusuke Muraoka
 
PPTX
Django learning
Yusuke Muraoka
 
PDF
Poolboy
Yusuke Muraoka
 
KEY
Pyramid Security
Yusuke Muraoka
 
PDF
Some about chef
Yusuke Muraoka
 
PDF
Debug it-python-hack-a-thon-2011.02
Yusuke Muraoka
 
PDF
App Engineと非同期とテストと私
Yusuke Muraoka
 
ODP
Can A Python Go Beyond The Python
Yusuke Muraoka
 
いかにして問題をとくか
Yusuke Muraoka
 
私のPythonとの関わりかた
Yusuke Muraoka
 
Substance D world-plone-day-2017
Yusuke Muraoka
 
Gunma.web #24 MySQL HA
Yusuke Muraoka
 
The Substance D - Plone Symposium Tokyo 2015
Yusuke Muraoka
 
プロパティディスクリプタとその拡張ライブラリ
Yusuke Muraoka
 
Django learning Part2
Yusuke Muraoka
 
Django learning
Yusuke Muraoka
 
Pyramid Security
Yusuke Muraoka
 
Some about chef
Yusuke Muraoka
 
Debug it-python-hack-a-thon-2011.02
Yusuke Muraoka
 
App Engineと非同期とテストと私
Yusuke Muraoka
 
Can A Python Go Beyond The Python
Yusuke Muraoka
 
Ad

Recently uploaded (20)

PDF
Shuen Mei Parth Sharma Boost Productivity, Innovation and Efficiency wit...
AWS Chicago
 
PPTX
Simplifying End-to-End Apache CloudStack Deployment with a Web-Based Automati...
ShapeBlue
 
PPTX
TYPES OF COMMUNICATION Presentation of ICT
JulieBinwag
 
PDF
OpenInfra ID 2025 - Are Containers Dying? Rethinking Isolation with MicroVMs.pdf
Muhammad Yuga Nugraha
 
PDF
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PDF
Novus-Safe Pro: Brochure-What is Novus Safe Pro?.pdf
Novus Hi-Tech
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PPTX
Top Managed Service Providers in Los Angeles
Captain IT
 
PPTX
python advanced data structure dictionary with examples python advanced data ...
sprasanna11
 
PPTX
The Yotta x CloudStack Advantage: Scalable, India-First Cloud
ShapeBlue
 
PDF
Market Wrap for 18th July 2025 by CIFDAQ
CIFDAQ
 
PDF
Women in Automation Presents: Reinventing Yourself — Bold Career Pivots That ...
DianaGray10
 
PDF
GITLAB-CICD_For_Professionals_KodeKloud.pdf
deepaktyagi0048
 
PDF
Empowering Cloud Providers with Apache CloudStack and Stackbill
ShapeBlue
 
PDF
Sustainable and comertially viable mining process.pdf
Avijit Kumar Roy
 
PDF
The Past, Present & Future of Kenya's Digital Transformation
Moses Kemibaro
 
PPTX
UI5Con 2025 - Beyond UI5 Controls with the Rise of Web Components
Wouter Lemaire
 
PDF
CIFDAQ'S Token Spotlight for 16th July 2025 - ALGORAND
CIFDAQ
 
PDF
Trading Volume Explained by CIFDAQ- Secret Of Market Trends
CIFDAQ
 
Shuen Mei Parth Sharma Boost Productivity, Innovation and Efficiency wit...
AWS Chicago
 
Simplifying End-to-End Apache CloudStack Deployment with a Web-Based Automati...
ShapeBlue
 
TYPES OF COMMUNICATION Presentation of ICT
JulieBinwag
 
OpenInfra ID 2025 - Are Containers Dying? Rethinking Isolation with MicroVMs.pdf
Muhammad Yuga Nugraha
 
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
Novus-Safe Pro: Brochure-What is Novus Safe Pro?.pdf
Novus Hi-Tech
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
Top Managed Service Providers in Los Angeles
Captain IT
 
python advanced data structure dictionary with examples python advanced data ...
sprasanna11
 
The Yotta x CloudStack Advantage: Scalable, India-First Cloud
ShapeBlue
 
Market Wrap for 18th July 2025 by CIFDAQ
CIFDAQ
 
Women in Automation Presents: Reinventing Yourself — Bold Career Pivots That ...
DianaGray10
 
GITLAB-CICD_For_Professionals_KodeKloud.pdf
deepaktyagi0048
 
Empowering Cloud Providers with Apache CloudStack and Stackbill
ShapeBlue
 
Sustainable and comertially viable mining process.pdf
Avijit Kumar Roy
 
The Past, Present & Future of Kenya's Digital Transformation
Moses Kemibaro
 
UI5Con 2025 - Beyond UI5 Controls with the Rise of Web Components
Wouter Lemaire
 
CIFDAQ'S Token Spotlight for 16th July 2025 - ALGORAND
CIFDAQ
 
Trading Volume Explained by CIFDAQ- Secret Of Market Trends
CIFDAQ
 

Pythonistaで始めるiOSプロトタイプ開発

  • 5. Pythonista • Pythonista: A full-featured Python environment for iOS devices • europython 2014 https://ep2014.europython.eu/en/ schedule/sessions/109/ • Pythonista Pythonista 
 iOS Pythonista • https://pycon.jp/2016/ja/schedule/presentation/47/ PyCon JP 2016 • Pythonista • PyCon mini Kumamoto
  • 6. (1) • • • Pythonista iOS • iOS Pythonista • • NumPy SymPy, SimPy, Matplotlib • StaSh • , Git
  • 7. (2) • • iOS Python • • Python • Objective-C • iOS
  • 8. Pythonista iOS • • Xcode • • AppStore ? • • Xcode https://github.com/omz/ PythonistaAppTemplate • Python
  • 9. Pythonista iOS • Pythonista Python • iOS Framework Python • •
  • 11. • Pythonista • • (BLE) • iOS • ( , C/S) • GPIO •
  • 12. • Python • NG • iOS Pythonista • objc_util • ( Framework … ) • •
  • 15. Framework from objc_util import * NSBundle.bundleWithPath_('/System/Library/ Frameworks/Photos.framework').load() AVFoundation.framework AVKit.framework Accelerate.framework Accounts.framework AdSupport.framework AddressBook.framework AddressBookUI.framework AssetsLibrary.framework AudioToolbox.framework AudioUnit.framework CFNetwork.framework CallKit.framework CloudKit.framework Contacts.framework ContactsUI.framework CoreAudio.framework CoreAudioKit.framework CoreBluetooth.framework CoreData.framework CoreFoundation.framework CoreGraphics.framework CoreImage.framework CoreLocation.framework CoreMIDI.framework CoreMedia.framework CoreMotion.framework CoreSpotlight.framework CoreTelephony.framework CoreText.framework CoreVideo.framework EventKit.framework EventKitUI.framework ExternalAccessory.framework Foundation.framework GLKit.framework GSS.framework GameController.framework GameKit.framework GameplayKit.framework HealthKit.framework HealthKitUI.framework HomeKit.framework IOKit.framework ImageIO.framework Intents.framework IntentsUI.framework JavaScriptCore.framework LocalAuthentication.framework MapKit.framework MediaAccessibility.framework MediaPlayer.framework MediaToolbox.framework MessageUI.framework Messages.framework Metal.framework MetalKit.framework MetalPerformanceShaders.framework MobileCoreServices.framework ModelIO.framework MultipeerConnectivity.framework NetworkExtension.framework NewsstandKit.framework NotificationCenter.framework OpenAL.framework OpenGLES.framework PassKit.framework Photos.framework PhotosUI.framework PushKit.framework QuartzCore.framework QuickLook.framework ReplayKit.framework SafariServices.framework SceneKit.framework Security.framework Social.framework Speech.framework SpriteKit.framework StoreKit.framework System.framework SystemConfiguration.framework Twitter.framework UIKit.framework UserNotifications.framework UserNotificationsUI.framework VideoSubscriberAccount.framework VideoToolbox.framework WatchConnectivity.framework WebKit.framework iAd.framework
  • 16. from objc_util import * UIScreen = ObjCClass('UIScreen') screen = UIScreen.mainScreen() if screen.brightness() < 0.3: screen.setBrightness_(0.6) else: screen.setBrightness_(0.1)
  • 17. from objc_util import * def DemoClass_foo_(_self, _cmd, _s): print('result: %s' % ObjCInstance(_s)) # NSObject DemoClass = create_objc_class( 'DemoClass', ObjCClass('NSObject'), methods=[DemoClass_foo_], protocols=[]) demo_obj = DemoClass.alloc().init() demo_obj.foo_("hello") result: hello
  • 18. def DemoClass_foo_(_self, _cmd, _s): ... def bar_baz_(_self, _cmd, _x1, _x2): ... DemoClass = create_objc_class( ... methods=[DemoClass_foo_, bar_baz_], ... demo_obj = DemoClass.alloc().init() demo_obj.foo_("hello") demo_obj.bar_baz_(2, 3) demo_obj.bar_(2, baz=5) # UIColor.colorWithRed:green:blue:alpha UIColor.colorWithRed(1.0, green=0.0, blue=0.0, alpha=1.0) UIColor.color(red=1.0, green=0.0, blue=0.0, alpha=1.0)
  • 19. from objc_util import ObjCClass def is_word_valid(word): reflib = ObjCClass('UIReferenceLibraryViewController') return reflib.dictionaryHasDefinitionForTerm_(word) test_words = ['foo', 'bar', 'quuz', 'cat', 'dog'] for word in test_words: print('%s: %s' % (word, is_word_valid(word))) foo: False bar: True quuz: False cat: True dog: True https://gist.github.com/omz/599ef8aeae22620261c6
  • 20. from objc_util import * UIApplication = ObjCClass('UIApplication') vc = UIApplication.sharedApplication().keyWindow ().rootViewController() print(vc.childViewControllers()) <b'__NSArrayI': ( "<UINavigationController: 0x1038db200>", "<PA2TabViewController: 0x104003000>", "<PA2AccessoryTabViewController: 0x1038dac00>" )> Pythonista
  • 23. • objc_util • iOS Framework • ObjCClass ObjCInstance Python • • •
  • 25. IoT • cb • BLE • CoreBluetooth • Sony MESH https://youtu.be/uJ6VVklLUQc https://github.com/jbking/pythonista-misc/blob/master/mesh/button_demo.py
  • 27. • • ui, Requests • • appex, webbrowser, (pythonista://ScriptName)
  • 29. • Omz gist • https://gist.github.com/omz/ • Pythonista Tools • https://github.com/Pythonista-Tools/Pythonista- Tools