Skip to content

Instantly share code, notes, and snippets.

@kiok46
kiok46 / PlyerUtils.py
Created June 10, 2018 09:55
Plyer: Platform independent compatibility layer
# utils.py file.
class Proxy(object):
...
def __init__(self, name, facade):
...
def _ensure_obj(self):
...
name = object.__getattribute__(self, '_name')
module = 'plyer.platforms.{}.{}'.format(
@kiok46
kiok46 / PlyerAccelerometerInit.py
Created June 10, 2018 09:54
Plyer: Platform independent compatibility layer
# __init__.py file.
from plyer import facades
from plyer.utils import Proxy
#: Accelerometer proxy to :class:`plyer.facades.Accelerometer`
accelerometer = Proxy('accelerometer', facades.Accelerometer)
#other features...
@kiok46
kiok46 / PlyerCall.py
Created June 10, 2018 09:51
Plyer: Platform independent compatibility layer
from plyer import call
call.makecall('9997654321')
@kiok46
kiok46 / PlyerCallImplementation.py
Created June 10, 2018 09:50
Plyer: Platform independent compatibility layer
from jnius import autoclass
from plyer.facades import Call
from plyer.platforms.android import activity
Intent = autoclass('android.content.Intent')
uri = autoclass('android.net.Uri')
class AndroidCall(Call):
@kiok46
kiok46 / Plyertexttospeech.kv
Created June 10, 2018 09:49
Plyer: Platform independent compatibility layer
<Text2SpeechDemo>:
BoxLayout:
orientation: 'vertical'
padding: 20
TextInput:
id: notification_text
text: 'Put message here'
Button:
@kiok46
kiok46 / PlyerTextToSpeechMain.py
Created June 10, 2018 09:48
Plyer: Platform independent compatibility layer
import kivy
kivy.require('1.8.0')
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.popup import Popup
from plyer import tts
@kiok46
kiok46 / Plyerflash.py
Created June 10, 2018 09:47
Plyer: Platform independent compatibility layer
from plyer import flash
flash.on()
@kiok46
kiok46 / PlyerBattery.py
Created June 10, 2018 09:46
Plyer: Platform independent compatibility layer
from plyer import battery
battery.status
// {'percentage': 82.0, 'isCharging': False}
@kiok46
kiok46 / PlyerAccelerometer.py
Last active June 10, 2018 09:47
Plyer: Platform independent compatibility layer
from plyer import accelerometer
accelerometer.enable()
accelerometer.acceleration
//(-10.048464775085449, 6.825869083404541, 7.7260890007019043)
@kiok46
kiok46 / Texture_Management_main.kv
Last active June 10, 2018 09:33
Texture management in Kivy using atlas
<ProgressBar>:
canvas:
Color:
rgb: 1, 1, 1
BorderImage:
border: (12, 12, 12, 12)
pos: self.x, self.center_y - 12
size: self.width, 24
source: 'atlas://textures/red-lightgrey/myatlas/progressbar_background'
BorderImage: