User Tools

Site Tools


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.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
teaching:ie0117:actividad_7new:kivy [2016/05/16 17:25] adminteaching:ie0117:actividad_7new:kivy [2022/09/20 00:08] (current) – external edit 127.0.0.1
Line 1: Line 1:
-====== Actividad 7: Kivy ======+====== 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 ~/local/src/plyer   cd ~/local/src/plyer
   python setup.py --command-packages=stdeb.command bdist_deb   python setup.py --command-packages=stdeb.command bdist_deb
Line 63: Line 64:
   if __name__ == '__main__':   if __name__ == '__main__':
       MyApp().run()       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 "Test"
 +  * Copie un archivo con una canción de la siguiente forma:
 +
 +  mkdir -p ~/mnt/cel/storage/emulated/0/kivy/test/musica/
 +  cp directorio_cancion/cancion.mp3 ~/mnt/cel/storage/emulated/0/kivy/test/musica/
 +
 +  * 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: 'vertical'
 +      Label:
 +          text: app.gps_location
 +      Label:
 +          text: app.gps_status
 +      BoxLayout:
 +          size_hint_y: None
 +          height: '48dp'
 +          padding: '4dp'
 +          ToggleButton:
 +              text: 'Start' if self.state == 'normal' else 'Stop'
 +              on_state:
 +                  app.gps.start() if self.state == 'down' else app.gps.stop()
 +  '''
 +  
 +  class TestApp(App):
 +  
 +      gps_location = StringProperty()
 +      gps_status = StringProperty('Click Start to get GPS location updates')
 +  
 +  
 +      def build(self):
 +          self.gps = gps
 +          try:
 +              self.gps.configure(on_location=self.on_location,
 +                                 on_status=self.on_status)
 +          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, **kwargs):
 +          self.gps_location = '\n'.join([
 +              '{}={}'.format(k, v) for k, v in kwargs.items()])
 +  
 +      @mainthread
 +      def on_status(self, stype, status):
 +          self.gps_status = 'type={}\n{}'.format(stype, status)
 +  
 +  
 +  if __name__=="__main__":
 +      sound = SoundLoader.load('musica/cancion.mp3')
 +      if sound:
 +          print("Sound found at %s" % sound.source)
 +          print("Sound is %.3f seconds" % sound.length)
 +          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('title: This is a info message.'+str(x))
 +  
 +      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.1463419548.txt.gz · Last modified: 2022/09/20 00:08 (external edit)