Writing /var/lib/dokuwiki/data/meta/teaching/ie0117/actividad_7new/kivy.meta failed
teaching:ie0117:actividad_7new:kivy
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
teaching:ie0117:actividad_7new:kivy [2016/05/16 16:52] – [Instrucciones] admin | teaching:ie0117:actividad_7new:kivy [2022/09/20 00:08] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Actividad | + | ====== Actividad: Kivy ====== |
===== Preguntas ===== | ===== Preguntas ===== | ||
Line 22: | Line 22: | ||
* Construya un paquete de debian para plyer e instálelo | * Construya un paquete de debian para plyer e instálelo | ||
+ | sudo apt-get install python-stdeb | ||
cd ~/ | cd ~/ | ||
python setup.py --command-packages=stdeb.command bdist_deb | python setup.py --command-packages=stdeb.command bdist_deb | ||
cd deb_dist | cd deb_dist | ||
sudo dpkg -i python-plyer_1.2.5dev-1_all.deb | sudo dpkg -i python-plyer_1.2.5dev-1_all.deb | ||
+ | |||
+ | ==== En Android ==== | ||
+ | |||
+ | * Configure un servidor ssh. Instale la aplicación sshdroid (Play) o primitive ftpd (de f-droid), configure una clave para el servidor ssh | ||
+ | * Instale kivy-launcher con Play. | ||
+ | |||
+ | ==== En la PC ==== | ||
+ | |||
+ | * Monte el directorio remoto del celular en la computadora (si utiliza primitive ftpd): | ||
+ | |||
+ | mkdir -p ~/mnt/cel | ||
+ | sshfs -p 1234 user@192.168.43.1:/ | ||
+ | |||
+ | * Ahora su celular está disponible en ~/mnt/cel | ||
+ | * Cambien al directorio de kivy en el celular desde su PC: | ||
+ | |||
+ | cd ~/ | ||
+ | mkdir test | ||
+ | cd test | ||
+ | |||
+ | * Dentro de este directorio cree un archivo llamado main.py con el siguiente contenido: | ||
+ | |||
+ | import kivy | ||
+ | kivy.require(' | ||
+ | | ||
+ | from kivy.app import App | ||
+ | from kivy.uix.label import Label | ||
+ | | ||
+ | | ||
+ | class MyApp(App): | ||
+ | | ||
+ | def build(self): | ||
+ | return Label(text=' | ||
+ | | ||
+ | | ||
+ | if __name__ == ' | ||
+ | MyApp().run() | ||
+ | |||
+ | |||
+ | * Ejecútelo en Linux: | ||
+ | |||
+ | python main.py | ||
+ | |||
+ | * Ahora para poder correr este programa se debe crear un archivo llamado android.txt con el siguiente contenido: | ||
+ | |||
+ | title=Test | ||
+ | author=test | ||
+ | orientation=portrait | ||
+ | |||
+ | ==== En Android ==== | ||
+ | |||
+ | * Utilice el kivy launcher para correr " | ||
+ | * Copie un archivo con una canción de la siguiente forma: | ||
+ | |||
+ | mkdir -p ~/ | ||
+ | cp directorio_cancion/ | ||
+ | |||
+ | * Cambien el contenido completo de main.py por lo siguiente: | ||
+ | |||
+ | from kivy.app import App | ||
+ | from kivy.uix.button import Button | ||
+ | from kivy.core.audio import SoundLoader | ||
+ | from plyer import accelerometer as acc | ||
+ | from kivy.logger import Logger | ||
+ | from time import sleep | ||
+ | from plyer import gps | ||
+ | from kivy.properties import StringProperty | ||
+ | from kivy.clock import Clock, mainthread | ||
+ | from kivy.lang import Builder | ||
+ | | ||
+ | | ||
+ | kv = ''' | ||
+ | BoxLayout: | ||
+ | orientation: | ||
+ | Label: | ||
+ | text: app.gps_location | ||
+ | Label: | ||
+ | text: app.gps_status | ||
+ | BoxLayout: | ||
+ | size_hint_y: | ||
+ | height: ' | ||
+ | padding: ' | ||
+ | ToggleButton: | ||
+ | text: ' | ||
+ | on_state: | ||
+ | app.gps.start() if self.state == ' | ||
+ | ''' | ||
+ | | ||
+ | class TestApp(App): | ||
+ | | ||
+ | gps_location = StringProperty() | ||
+ | gps_status = StringProperty(' | ||
+ | | ||
+ | | ||
+ | def build(self): | ||
+ | self.gps = gps | ||
+ | try: | ||
+ | self.gps.configure(on_location=self.on_location, | ||
+ | | ||
+ | except NotImplementedError: | ||
+ | import traceback | ||
+ | traceback.print_exc() | ||
+ | self.gps_status = 'GPS is not implemented for your platform' | ||
+ | | ||
+ | return Builder.load_string(kv) | ||
+ | | ||
+ | | ||
+ | @mainthread | ||
+ | def on_location(self, | ||
+ | self.gps_location = ' | ||
+ | ' | ||
+ | | ||
+ | @mainthread | ||
+ | def on_status(self, | ||
+ | self.gps_status = ' | ||
+ | | ||
+ | | ||
+ | if __name__==" | ||
+ | sound = SoundLoader.load(' | ||
+ | if sound: | ||
+ | print(" | ||
+ | print(" | ||
+ | sound.play() | ||
+ | acc.enable() | ||
+ | x=acc.get_acceleration() | ||
+ | sleep(1) | ||
+ | x=acc.get_acceleration() | ||
+ | x=acc.get_acceleration() | ||
+ | x=acc.get_acceleration() | ||
+ | x=acc.get_acceleration() | ||
+ | x=acc.get_acceleration() | ||
+ | Logger.info(' | ||
+ | | ||
+ | TestApp().run() | ||
+ | |||
+ | * Ejecútelo en Linux y Android y comente las diferencias. | ||
+ | |||
===== Evaluación ===== | ===== Evaluación ===== | ||
+ | |||
+ | Cuestionario: | ||
+ | |||
+ | * Comente que sucedió cuando corrió el primer programa main.py. Cuáles fueron las diferencias entre Linux y Android? | ||
+ | * Comente que sucedió cuando corrió el segundo programa main.py. Cuáles fueron las diferencias entre Linux y Android? | ||
+ | * Cómo puede generar mensajes de consola en el programa de Android y cómo puede leerlos? | ||
teaching/ie0117/actividad_7new/kivy.1463417562.txt.gz · Last modified: 2022/09/20 00:08 (external edit)