平臺無關的 Python 封裝器:Plyer
Plyer 是一個平臺無關的 Python 封裝器,封裝了一些平臺獨立的 API。Plyer 并非要重復造輪子,而是將一些平臺的差異通過簡單的 API 進行封裝。
-
on python-for-android, pyjnius is used
-
on kivy-ios, pyobjus is used
-
on windows/mac/linux, commonly found libraries and programs will be used
示例代碼:
from plyer.vibrator import vibrate vibrate(10) # in Plyer, the argument is in seconds
Support
Platform | Android < 4.0 | Android > 4.0 | iOS | Windows | OSX | Linux |
---|---|---|---|---|---|---|
Accelerometer | X | X | X |
|
X | X |
Camera (taking picture) | X | X |
|
|
|
|
GPS | X | X | X |
|
|
|
Notifications | X | X |
|
X | X | X |
Text to speech | X | X | X | X | X | X |
Email (open mail client) |
|
X | X | X | X | X |
Vibrator | X | X |
|
|
|
|
Sms (send messages) | X | X |
|
|
|
|
Compass | X | X | X |
|
|
|
Unique ID (IMEI or SN) | X | X | X | X | X | X |
Gyroscope | X | X | X |
|
|
|
Battery | X | X | X | X | X | X |
Native file chooser |
|
|
|
X | X | X |
本文由用戶 ec3y 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!