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

PDF
多腕バンディット問題: 定式化と応用 (第13回ステアラボ人工知能セミナー)
PPTX
three.jsを「遅い」と思わせないデータの扱い方
PDF
アジャイルジャーニー
PDF
バーチャルリアリティ(VR)概要
PDF
自動テストの誤解とアンチパターン in 楽天 Tech Talk
PPTX
Deep Learningで似た画像を見つける技術 | OHS勉強会#5
PPTX
スマホマーケットの概要と、 マーケティングの失敗例と改善 (アナリティクス アソシエーション 特別セミナー)
PDF
クラシックな機械学習の入門  11.評価方法
多腕バンディット問題: 定式化と応用 (第13回ステアラボ人工知能セミナー)
three.jsを「遅い」と思わせないデータの扱い方
アジャイルジャーニー
バーチャルリアリティ(VR)概要
自動テストの誤解とアンチパターン in 楽天 Tech Talk
Deep Learningで似た画像を見つける技術 | OHS勉強会#5
スマホマーケットの概要と、 マーケティングの失敗例と改善 (アナリティクス アソシエーション 特別セミナー)
クラシックな機械学習の入門  11.評価方法

What's hot (20)

PDF
ゲームAIの中の数学(上)
PDF
No011-01-Suc3rum-20100225
PDF
「ユーザーを理解するって言うほどカンタンじゃないよね」 UXデザイン・UXリサーチをもう一度ちゃんと理解しよう!
PPTX
レベルを上げて物理で殴れ、Fuzzing入門 #pyfes
PPTX
ビジネスモデルの作り方
PPTX
大規模グラフデータ処理
PPTX
PyTorch, PixyzによるGenerative Query Networkの実装
PDF
Cognitive Complexity でコードの複雑さを定量的に計測しよう
PDF
【2023年版】UXデザインの資格ってどんなの? HCD-Net認定 人間中心設計スペシャリスト・人間中心設計専門家
PPTX
クラウドファースト時代のAWS活用事例と今後の展望 - AWS Cloud Storage & DB Day 2014
PPTX
9コマシナリオの使い方
PDF
GPU最適化入門
PDF
リンク機構を有するロボットをGazeboで動かす
PPTX
機械学習×セキュリティ
PDF
食べログのフロントエンドエンジニアってめっちゃ大変やねん・・・
PDF
ゲームシナリオ構成法 2015版
PDF
ナラティブ・プロトタイピング
PDF
[메조미디어] 2023 모바일게임 업종 분석 리포트
PDF
4つの戦犯から考えるサービスづくりの失敗
PDF
フロー効率性とリソース効率性について #xpjug
ゲームAIの中の数学(上)
No011-01-Suc3rum-20100225
「ユーザーを理解するって言うほどカンタンじゃないよね」 UXデザイン・UXリサーチをもう一度ちゃんと理解しよう!
レベルを上げて物理で殴れ、Fuzzing入門 #pyfes
ビジネスモデルの作り方
大規模グラフデータ処理
PyTorch, PixyzによるGenerative Query Networkの実装
Cognitive Complexity でコードの複雑さを定量的に計測しよう
【2023年版】UXデザインの資格ってどんなの? HCD-Net認定 人間中心設計スペシャリスト・人間中心設計専門家
クラウドファースト時代のAWS活用事例と今後の展望 - AWS Cloud Storage & DB Day 2014
9コマシナリオの使い方
GPU最適化入門
リンク機構を有するロボットをGazeboで動かす
機械学習×セキュリティ
食べログのフロントエンドエンジニアってめっちゃ大変やねん・・・
ゲームシナリオ構成法 2015版
ナラティブ・プロトタイピング
[메조미디어] 2023 모바일게임 업종 분석 리포트
4つの戦犯から考えるサービスづくりの失敗
フロー効率性とリソース効率性について #xpjug
Ad

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

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

More from Yusuke Muraoka (14)

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

Recently uploaded (20)

PDF
Empathic Computing: Creating Shared Understanding
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Encapsulation theory and applications.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Approach and Philosophy of On baking technology
PPT
Teaching material agriculture food technology
PPTX
Cloud computing and distributed systems.
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Empathic Computing: Creating Shared Understanding
20250228 LYD VKU AI Blended-Learning.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Chapter 3 Spatial Domain Image Processing.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Per capita expenditure prediction using model stacking based on satellite ima...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Agricultural_Statistics_at_a_Glance_2022_0.pdf
MIND Revenue Release Quarter 2 2025 Press Release
NewMind AI Weekly Chronicles - August'25 Week I
Encapsulation theory and applications.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Building Integrated photovoltaic BIPV_UPV.pdf
Review of recent advances in non-invasive hemoglobin estimation
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Approach and Philosophy of On baking technology
Teaching material agriculture food technology
Cloud computing and distributed systems.
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf

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