Build a Mobile App and trigger Subprocess on your Raspberry Pi

Paswordless SSH access to the Pi

ssh pi@<your_IP_address> 

Kivy

-m pip install kivy

Building our LED App

from kivy.app import App
from kivy.uix.gridlayout import GridLayout


class MyGrid(GridLayout)::
pass


class MyApp(App):
def build(self):
return MyGrid()
if __name__ == "__main__":
MyApp().run()
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.gridlayout import GridLayout
class MyGrid(GridLayout):
def __init__(self, **kwargs):
super(MyGrid, self).__init__(**kwargs)
self.cols = 2
self.hello = Button(text="hello", font_size=40) #button 1
self.world = Button(text="world", font_size=40) #button 2

#Adding the buttons as widgets. self.add_widget(self.hello)
self.add_widget(self.world)


class MyApp(App):
def build(self):
return MyGrid()
if __name__ == "__main__":
MyApp().run()
class MyGrid(GridLayout):
def __init__(self, **kwargs):
super(MyGrid, self).__init__(**kwargs)
self.cols = 2
self.hello = Button(text="hello", font_size=40) #button1
self.world = Button(text="world", font_size=40) #button2
self.button = Button(text="button 3", font_size=40) #button3

#Adding the buttons as widgets.
self.add_widget(self.hello)
self.add_widget(self.world)
self.add_widget(self.button)
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.gridlayout import GridLayout
class MyGrid(GridLayout):
def __init__(self, **kwargs):
super(MyGrid, self).__init__(**kwargs)
self.cols = 1
self.led = Button(text="Turn on LED", font_size=40)
self.add_widget(self.led)


class MyApp(App):
def build(self):
return MyGrid()
if __name__ == "__main__":
MyApp().run()
class MyGrid(GridLayout):

def __init__(self, **kwargs):
super(MyGrid, self).__init__(**kwargs)
self.cols = 1
self.led = Button(text="Turn on LED", font_size=40)
self.add_widget(self.led) self.led.bind(on_press=self.pressed) def pressed(self, instance):
print("Button has been pressed")
import subprocess
ip = "your.ip.address"
filepath = "Documents/Python-Projects/your_file.py"
class MyGrid(GridLayout):

def __init__(self, **kwargs):
super(MyGrid, self).__init__(**kwargs)
self.cols = 1
self.led = Button(text="Turn on LED", font_size=40)
self.add_widget(self.led) self.led.bind(on_press=self.pressed) def pressed(self, instance):
subprocess.run("ssh pi@{} python {}".format(ip, file_path), shell=True, check=True)
ssh pi@your.ip.address python Documents/Python-Projects/your_file.py

Creating an iOS Package

brew install autoconf automake libtool pkg-config
brew link libtool
sudo easy_install pip
# pip method if available (sudo might be needed.)
sudo pip install Cython==0.29.10
pip3 install -r requirements.txt
git clone git://github.com/kivy/kivy-ios
cd kivy-ios
ls
toolchain <command> [<args>]

Available commands:
build Build a recipe (compile a library for the required target architecture)
clean Clean the build of the specified recipe
distclean Clean the build and the result
recipes List all the available recipes
status List all the recipes and their build status

Xcode:
create Create a new xcode project
update Update an existing xcode project (frameworks, libraries..)
launchimage Create Launch images for your xcode project
icon Create Icons for your xcode project
pip Install a pip dependency into the distribution
pip3 Install a pip dependency into the python 3 distribution
cd kivy-ios
python3 toolchain.py build python3
python3 toolchain.py build sdl2
python3 toolchain.py build python3 kivy
python3 toolchain.py recipes
python3 toolchain.py create <title> <app_directory>
python3 toolchain.py create exampleapp ~/Desktop/kivy/example_app
open exampleapp-ios/exampleapp.xcodeproj

Sources:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store