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évisionLes deux révisions suivantes
kivy_plyer [2020/01/04 08:57] – [android.permissions] sergekivy_plyer [2020/01/04 09:00] – [Exemple Envoi de Sms] serge
Ligne 154: Ligne 154:
  
 =====Exemple Envoi de Sms===== =====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>
 +
 +===La permission SEND_SMS n'est pas acceptée par Android===
 <code> <code>
 01-04 09:55:02.162  3635  3654 I python  : [INFO   ] [Base        ] Leaving application in progress... 01-04 09:55:02.162  3635  3654 I python  : [INFO   ] [Base        ] Leaving application in progress...
kivy_plyer.txt · Dernière modification : 2020/12/01 17:43 de serge