Outils pour utilisateurs

Outils du site


kivy_plyer

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
Prochaine révisionLes deux révisions suivantes
kivy_plyer [2020/01/02 18:52] – [Utilisation] sergekivy_plyer [2020/10/30 10:06] – [Kivy: plyer] serge
Ligne 1: Ligne 1:
 ====== Kivy: plyer====== ====== Kivy: plyer======
- 
 <WRAP center round box 60% centeralign> <WRAP center round box 60% centeralign>
 **{{tagpage>kivy|Toutes les pages Kivy}}** **{{tagpage>kivy|Toutes les pages Kivy}}**
 **[[http://translate.google.com/translate?hl=&sl=auto&tl=en&u=https%3A%2F%2Fressources.labomedia.org%2Fkivy_plyer|English Version]]** **[[http://translate.google.com/translate?hl=&sl=auto&tl=en&u=https%3A%2F%2Fressources.labomedia.org%2Fkivy_plyer|English Version]]**
 +</WRAP>
 +<WRAP center round box 40% centeralign>
 +**[[les_pages_kivy_en_details|Les pages Kivy en détails]]**
 </WRAP> </WRAP>
  
 +**Plyer** fournit des façades pour accéder facilement à des fonctionnalités Android. C'est une alternative simple à **[[kivy_jnius|jnuis]]**
 =====Installation===== =====Installation=====
- 
   sudo pip3 install plyer   sudo pip3 install plyer
- 
- 
  
 =====Ressources===== =====Ressources=====
 +Très pauvres !
   * **[[https://kivy.org/doc/stable/guide/android.html#plyer|Plyer]]**   * **[[https://kivy.org/doc/stable/guide/android.html#plyer|Plyer]]**
   * **[[https://github.com/kivy/plyer|plyer sur github.com ]]** Le Readme donne les fonctions possible en fonction des plateformes   * **[[https://github.com/kivy/plyer|plyer sur github.com ]]** Le Readme donne les fonctions possible en fonction des plateformes
-  * **[[https://github.com/kivy/plyer/tree/master/examples|Les exemples sur gituhub]], mais c'est pour du python2, et c'est mal codé ! +  * **[[https://github.com/kivy/plyer/tree/master/examples|Les exemples sur gituhub]]**, mais c'est pour du python2, et c'est mal codé ! 
 +=====Possiblité d'accès===== 
 +===Android=== 
 +Accelerometer 
 +Audio recording  
 +Barometer 
 +Battery 
 +Bluetooth 
 +Brightness 
 +Call 
 +Camera (taking picture)  
 +Compass 
 +Email (open mail client) 
 +Flash 
 +GPS 
 +Gravity  
 +Gyroscope 
 +Humidity 
 +IR Blaster 
 +Light 
 +Native file chooser 
 +Notifications 
 +Orientation 
 +Proximity 
 +SMS (send messages)  
 +Spatial Orientation  
 +Speech to text 
 +Storage Path 
 +Temperature 
 +Text to speech 
 +Unique ID 
 +Vibrator 
 +===Linux=== 
 +Accelerometer  
 +Battery 
 +Brightness  
 +CPU count 
 +Email (open mail client)  
 +Native file chooser 
 +Notifications 
 +Screenshot  
 +Storage Path  
 +Text to speech 
 +Unique ID 
 +Wifi
 =====Exemple===== =====Exemple=====
 Vous voulez quelque chose, faîtes le vous même ! Vous voulez quelque chose, faîtes le vous même !
 +
 +L'exemple **[[https://github.com/kivy/plyer/tree/master/examples/accelerometer/basic|Accelerometer Test]]** pour python3 et corrigé:
  
 <code python main.py> <code python main.py>
Ligne 109: Ligne 154:
 </code> </code>
  
 +===Le *apk===
 +  * {{media_08:accelbasicexample-1.1.apk|accelbasicexample-1.1.apk}}
 +=====android.permissions=====
 +  * [[https://developer.android.com/reference/android/Manifest.permission.html|Liste de toutes les permissions]]
 +
 +=====Exemple Envoi de Sms=====
 +<code python main.py>
 +#! /usr/bin/env python3
 +# -*- coding: utf-8 -*-
 +
 +from kivy.app import App
 +from kivy.uix.boxlayout import BoxLayout
 +from kivy.uix.button import Button
 +from kivy.properties import StringProperty
 +
 +from plyer import sms
 +
 +class SmsInterface(BoxLayout):
 +    pass
 +
 +class IntentButton(Button):
 +    sms_recipient = StringProperty()
 +    sms_message = StringProperty()
 +
 +    def send_sms(self, *args):
 +        sms.send(recipient=self.sms_recipient, message=self.sms_message)
 +
 +class SmsApp(App):
 +    def build(self):
 +        return SmsInterface()
 +
 +    def on_pause(self):
 +        return True
 +
 +if __name__ == "__main__":
 +    SmsApp().run()
 +</code>
 +
 +<code python sms.kv>
 +<SmsInterface>:
 +    orientation: 'vertical'
 +    BoxLayout:
 +        size_hint_y: None
 +        height: sp(30)
 +        Label:
 +            text: 'Recipient:'
 +        TextInput:
 +            id: recipient
 +            multiline: False
 +            on_text_validate: message.focus = True
 +    BoxLayout:
 +        Label:
 +            text: 'Message:'
 +        TextInput:
 +            id: message
 +    IntentButton:
 +        sms_recipient: recipient.text
 +        sms_message: message.text
 +        text: 'Send SMS'
 +        size_hint_y: None
 +        height: sp(40)
 +        on_release: self.send_sms()
 +</code>
 +
 +<code python buildozer.spec>
 +[app]
 +title = Sms
 +package.name = sms
 +package.domain = org.test
 +source.dir = .
 +source.include_exts = py,png,jpg,kv,atlas
 +version = 0.3
 +requirements = python3,kivy,plyer
 +orientation = portrait
 +fullscreen = 0
 +android.arch = armeabi-v7a
 +android.permissions = READ_PHONE_STATE, SEND_SMS, RECEIVE_SMS, READ_SMS
 +
 +[buildozer]
 +log_level = 2
 +warn_on_root = 1
 +</code>
 +===Le *.apk===
 +  * {{ ::sms_armeabi-v7a-0.3-armeabi-v7a-debug.apk |sms_armeabi-v7a-0.3-armeabi-v7a-debug.apk}}
 +
 +===La permission SEND_SMS n'est pas acceptée par Android===
 +<code>
 +01-04 09:55:02.162  3635  3654 I python  : [INFO   ] [Base        ] Leaving application in progress...
 +01-04 09:55:02.164  3635  3654 I python  :  Traceback (most recent call last):
 +01-04 09:55:02.164  3635  3654 I python  :    File "/media/data/3D/projets/sms/.buildozer/android/app/main.py", line 34, in <module>
 +01-04 09:55:02.166  3635  3654 I python  :    File "/media/data/3D/projets/sms/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/sms/kivy/app.py", line 855, in run
 +01-04 09:55:02.167  3635  3654 I python  :    File "/media/data/3D/projets/sms/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/sms/kivy/base.py", line 504, in runTouchApp
 +01-04 09:55:02.169  3635  3654 I python  :    File "/media/data/3D/projets/sms/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/sms/kivy/core/window/window_sdl2.py", line 747, in mainloop
 +01-04 09:55:02.172  3635  3654 I python  :    File "/media/data/3D/projets/sms/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/sms/kivy/core/window/window_sdl2.py", line 479, in _mainloop
 +01-04 09:55:02.174  3635  3654 I python  :    File "/media/data/3D/projets/sms/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/sms/kivy/base.py", line 342, in idle
 +01-04 09:55:02.177  3635  3654 I python  :    File "/media/data/3D/projets/sms/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/sms/kivy/base.py", line 327, in dispatch_input
 +01-04 09:55:02.178  3635  3654 I python  :    File "/media/data/3D/projets/sms/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/sms/kivy/base.py", line 293, in post_dispatch_input
 +01-04 09:55:02.181  3635  3654 I python  :    File "kivy/_event.pyx", line 707, in kivy._event.EventDispatcher.dispatch
 +01-04 09:55:02.184  3635  3654 I python  :    File "/media/data/3D/projets/sms/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/sms/kivy/uix/behaviors/button.py", line 179, in on_touch_up
 +01-04 09:55:02.185  3635  3654 I python  :    File "kivy/_event.pyx", line 703, in kivy._event.EventDispatcher.dispatch
 +01-04 09:55:02.187  3635  3654 I python  :    File "kivy/_event.pyx", line 1214, in kivy._event.EventObservers.dispatch
 +01-04 09:55:02.188  3635  3654 I python  :    File "kivy/_event.pyx", line 1098, in kivy._event.EventObservers._dispatch
 +01-04 09:55:02.189  3635  3654 I python  :    File "/media/data/3D/projets/sms/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/sms/kivy/lang/builder.py", line 64, in custom_callback
 +01-04 09:55:02.191  3635  3654 I python  :    File "/data/data/org.test.sms/files/app/sms.kv", line 23, in <module>
 +01-04 09:55:02.194  3635  3654 I python  :      on_release: self.send_sms()
 +01-04 09:55:02.195  3635  3654 I python  :    File "/media/data/3D/projets/sms/.buildozer/android/app/main.py", line 23, in send_sms
 +01-04 09:55:02.196  3635  3654 I python  :    File "/media/data/3D/projets/sms/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/sms/plyer/facades/sms.py", line 46, in send
 +01-04 09:55:02.197  3635  3654 I python  :    File "/media/data/3D/projets/sms/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/sms/plyer/platforms/android/sms.py", line 21, in _send
 +01-04 09:55:02.200  3635  3654 I python  :    File "jnius/jnius_export_class.pxi", line 1044, in jnius.jnius.JavaMultipleMethod.__call__
 +01-04 09:55:02.203  3635  3654 I python  :    File "jnius/jnius_export_class.pxi", line 766, in jnius.jnius.JavaMethod.__call__
 +01-04 09:55:02.205  3635  3654 I python  :    File "jnius/jnius_export_class.pxi", line 860, in jnius.jnius.JavaMethod.call_method
 +01-04 09:55:02.206  3635  3654 I python  :    File "jnius/jnius_utils.pxi", line 91, in jnius.jnius.check_exception
 +01-04 09:55:02.207  3635  3654 I python  :  jnius.jnius.JavaException: JVM exception occurred: Sending SMS message: uid 10074 does not have android.permission.SEND_SMS.
 +01-04 09:55:02.208  3635  3654 I python  : Python for android ended.
 +</code>
  
-{{tag>kivy sb}}+{{tag> kivy python sb }}
kivy_plyer.txt · Dernière modification : 2020/12/01 17:43 de serge