diff options
25 files changed, 489 insertions, 0 deletions
diff --git a/Pruebas-108.xo b/Pruebas-108.xo Binary files differnew file mode 100644 index 0000000..8f8035e --- /dev/null +++ b/Pruebas-108.xo diff --git a/Pruebas.activity/MANIFEST b/Pruebas.activity/MANIFEST new file mode 100755 index 0000000..dff05af --- /dev/null +++ b/Pruebas.activity/MANIFEST @@ -0,0 +1,9 @@ + +prueba2.py +setup.py +activity/activity-web.svg +activity/activity.info + + +pruebas.glade +tarjeta.py diff --git a/Pruebas.activity/activity/activity-web.svg b/Pruebas.activity/activity/activity-web.svg new file mode 100755 index 0000000..c8f466a --- /dev/null +++ b/Pruebas.activity/activity/activity-web.svg @@ -0,0 +1,15 @@ +<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' [ + <!ENTITY stroke_color "#010101"> + <!ENTITY fill_color "#FFFFFF"> +]><svg enable-background="new 0 0 55 55" height="55px" version="1.1" viewBox="0 0 55 55" width="55px" x="0px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" y="0px"><g display="block" id="activity-browse"> + <circle cx="27.375" cy="27.5" display="inline" fill="&fill_color;" r="19.903" stroke="&stroke_color;" stroke-width="3.5"/> + <g display="inline"> + <path d="M27.376,7.598c0,0-11.205,8.394-11.205,19.976 c0,11.583,11.205,19.829,11.205,19.829" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5"/> + <path d="M27.376,7.598c0,0,11.066,9.141,11.066,19.976 c0,10.839-11.066,19.829-11.066,19.829" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5"/> + <line fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" x1="27.376" x2="27.376" y1="7.598" y2="47.402"/> + <line fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" x1="27.376" x2="27.376" y1="7.598" y2="47.402"/> + <line fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" x1="27.376" x2="27.376" y1="7.598" y2="47.402"/> + <line fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" x1="7.472" x2="47.278" y1="27.5" y2="27.5"/> + </g> +</g></svg> + diff --git a/Pruebas.activity/activity/activity.info b/Pruebas.activity/activity/activity.info new file mode 100755 index 0000000..667bc59 --- /dev/null +++ b/Pruebas.activity/activity/activity.info @@ -0,0 +1,6 @@ +[Activity] +name = Pruebas +activity_version = 108 +bundle_id = org.laptop.Pruebas +icon = activity-web +exec = sugar-activity prueba2.HelloWorld -s diff --git a/Pruebas.activity/prueba2.py b/Pruebas.activity/prueba2.py new file mode 100755 index 0000000..bfec1b9 --- /dev/null +++ b/Pruebas.activity/prueba2.py @@ -0,0 +1,123 @@ +#!/usr/bin/env python + +# example helloworld.py + +import os +import pygtk +pygtk.require('2.0') +import gtk +import gtk.glade +import time +import gobject +import tarjeta +import ConfigParser + +from gettext import gettext as _ +from sugar import profile +from dbus.service import method, signal +from dbus.gobject_service import ExportedGObject +from gobject import SIGNAL_RUN_FIRST, TYPE_PYOBJECT, GObject, timeout_add +#import csnd +#from csound.csoundserver import CsoundServer + +class HelloWorld(object): + + # def play_sound(self, snd, sound_file): + # if len(snd.split('.')) > 1: + # if snd.split('.')[1] in ['wav', 'aif', 'aiff']: + # self.cs.perform('i 102 0.0 3.0 "%s" 1 0.9 0'%(sound_file)) + # else: + # self.cs.perform('i 100 0.0 3.0 "%s" 1 0.9 0'%(sound_file)) + + + def hello2(self, widget, event): + if event.button == 3: + widget.popup(None, None, None, event.button, event.time) + return True + # else: + # cfg = ConfigParser.ConfigParser() + + # cfg.add_section("login") + # cfg.set("login", "nombre", "raul") + + # f = open("config.cfg", "w") + # cfg.write(f) + # f.close() + return False + + def getConfigFile(aa): + cfg = ConfigParser.ConfigParser() + #cfg.read("./conf.ini") + if not cfg.read(["config.cfg"]): + print "No existe el archivo" + #return None + else: + cfg.read(["config.cfg"]) + #total = cfg.get("sets", "total") + #print total + return cfg + + def destroy(self, widget, data=None): + gtk.main_quit() + + def load_images(self): + FOLDER = '/home/olpc/Activities/ScanningWrite.activity/tables/001/' + image_list = [] + audio_list = [] + card_list = [] + + for file_name in os.listdir(FOLDER): + if file_name.split('.')[1] == 'bmp': + image_list.append(FOLDER + file_name) + elif file_name.split('.')[1] == 'wav': + audio_list.append(FOLDER + file_name) + + #for x in range(len(image_list)): + for x in range(5): + try: + card_list.append(tarjeta.Tarjeta(image_list[x],audio_list[x],'pepe')) + #card_list[x].box1.get_children[1].set_size_request(500,500) + except Exception, e: + pass + return card_list + + def resize_image(self, button): + imagen_prueba = gtk.Image() + pixbuf = gtk.gdk.pixbuf_new_from_file() + scaled_buf = pixbuf.scale_simple(500,500, gtk.gdk.INTERP_BILINEAR) + imagen_prueba.set_from_pixbuf(scaled_buf) + self.button.set_image(imagen_prueba) + + def __init__(self): + gladefile = "pruebas.glade" + windowname = "window" + archivoglade = gtk.glade.XML('pruebas.glade', 'window') + self.window = archivoglade.get_widget('window') + self.window.connect("destroy", self.destroy) + archivoglade.signal_autoconnect(self) + self.botton = gtk.Button() + #self.botton2 = gtk.Button() + self.window.set_border_width(30) + table = gtk.Table(4, 4, False) + #table.attach( self.botton, 0, 1, 0, 1) + # Ponemos la tabla en la ventana principal + self.window.add(table) + + items = self.load_images() + fila = 0 + col = 0 + + for card in items: + if col < 4 : + table.attach(card,col, col + 1, fila, fila + 1,gtk.EXPAND,10,10) + col = col + 1 + else: + table.attach(card,col, col + 1, fila, fila + 1,gtk.EXPAND,10,10) + fila = fila + 1 + col = 0 + print fila,col + + self.window.show_all() + +app = HelloWorld() +gtk.main() diff --git a/Pruebas.activity/pruebas.glade b/Pruebas.activity/pruebas.glade new file mode 100755 index 0000000..911aa83 --- /dev/null +++ b/Pruebas.activity/pruebas.glade @@ -0,0 +1,27 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> + +<glade-interface> + +<widget class="GtkWindow" id="window"> + <property name="visible">True</property> + <property name="title" translatable="yes">window1</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">False</property> + <property name="resizable">True</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> + + <child> + <placeholder/> + </child> +</widget> + +</glade-interface> diff --git a/Pruebas.activity/setup.py b/Pruebas.activity/setup.py new file mode 100755 index 0000000..5791885 --- /dev/null +++ b/Pruebas.activity/setup.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +#!/usr/bin/env python + +from sugar.activity import bundlebuilder + +bundlebuilder.start() diff --git a/Pruebas.activity/tarjeta.py b/Pruebas.activity/tarjeta.py new file mode 100755 index 0000000..e6f4e51 --- /dev/null +++ b/Pruebas.activity/tarjeta.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python
+
+# example helloworld.py
+
+import pygtk
+pygtk.require('2.0')
+import gtk
+import os
+
+class Tarjeta(gtk.Button):
+ def sonido(self, widget, sound):
+ os.system("/usr/bin/aplay %s &" % sound )
+
+ def mostrarMenu(self, widget, event):
+ if event.button == 3:
+ widget.popup(None, None, None, event.button, event.time)
+ return True
+ elif event.button == 1:
+ self.sonido(self, widget)
+ return False
+ return False
+
+ def imagen_label_btn(parent, img, label_text):
+ # Crear caja para xpm y etiqueta
+ box1 = gtk.VBox(gtk.FALSE, 0)
+ box1.set_border_width(2)
+
+ # Ahora nos ponemos con la imagen
+ image = gtk.Image()
+ image.set_from_file(img) + + #pixbuf = gtk.gdk.pixbuf_new_from_file(img) + #scaled_buf = pixbuf.scale_simple(500,500, gtk.gdk.INTERP_BILINEAR) + #image.set_from_pixbuf(scaled_buf) +
+ #image.set_size_request(500,500)
+ # Creamos una etiqueta para el boton
+ label = gtk.Label(label_text)
+
+ # Empaquetamos el pixmap y la etiqueta en la caja
+ box1.pack_start(label, gtk.FALSE, gtk.FALSE, 3)
+ box1.pack_start(image, gtk.FALSE, gtk.FALSE, 3)
+
+
+ image.show()
+ label.show()
+ return box1
+
+ def __init__(self, fileImagen,sound,text):
+ gtk.Button.__init__(self)
+
+ self.sounds = sound
+ #self.set_size_request(100,100)
+ self.texto = text
+ #self.button = gtk.Button()
+ #self.imagen = gtk.Image()
+ #self.imagen.set_from_file(fileImagen)
+ self.box1 = self.imagen_label_btn( fileImagen, text)
+ self.box1.show()
+ self.add(self.box1)
+ #self.button.show()
+ #self.add(self.button)
+
+ self.file_menu = gtk.Menu()
+ # Creamos los elementos de menu
+ open_item = gtk.MenuItem("cambiar Imagen")
+ save_item = gtk.MenuItem("Cambiar Sonido")
+ quit_item = gtk.MenuItem("Salir")
+
+ self.file_menu.append(open_item)
+ self.file_menu.append(save_item)
+ self.file_menu.append(quit_item)
+ open_item.show()
+ save_item.show()
+ quit_item.show()
+ self.connect("clicked", self.sonido,self.sounds)
+ self.connect_object("button_press_event", self.mostrarMenu,self.file_menu)
+ self.show_all()
diff --git a/ScanningWrite-1.xo b/ScanningWrite-1.xo Binary files differnew file mode 100644 index 0000000..98adc2b --- /dev/null +++ b/ScanningWrite-1.xo diff --git a/ScanningWrite.activity/MANIFEST b/ScanningWrite.activity/MANIFEST new file mode 100644 index 0000000..41f9998 --- /dev/null +++ b/ScanningWrite.activity/MANIFEST @@ -0,0 +1,40 @@ +NEWS + + +activity/activity-icon.svg +activity/activity.info + + + + + + + + + + + + + + + + + + + + + + + +setup.py +scanning_write.py +tables/001/02_adios.bmp +tables/001/02_adios.wav +tables/001/01_hola.bmp +tables/001/01_hola.wav +tables/001/04_te_quiero.bmp +tables/001/04_te_quiero.wav +tables/001/05_prueba.bmp +tables/001/05_prueba.wav +tables/001/03_tengosed.bmp +tables/001/03_tengosed.wav diff --git a/ScanningWrite.activity/NEWS b/ScanningWrite.activity/NEWS new file mode 100644 index 0000000..047ccd0 --- /dev/null +++ b/ScanningWrite.activity/NEWS @@ -0,0 +1 @@ +No news.
\ No newline at end of file diff --git a/ScanningWrite.activity/activity/activity-icon.svg b/ScanningWrite.activity/activity/activity-icon.svg new file mode 100644 index 0000000..40f35b4 --- /dev/null +++ b/ScanningWrite.activity/activity/activity-icon.svg @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [ + <!ENTITY ns_svg "http://www.w3.org/2000/svg"> + <!ENTITY ns_xlink "http://www.w3.org/1999/xlink"> + <!ENTITY stroke_color "#000000"> + <!ENTITY fill_color "#FFFFFF"> +]><!--"--> +<svg version="1.1" id="Pippy_activity" xmlns="&ns_svg;" xmlns:xlink="&ns_xlink;" width="47.585" height="49.326" + viewBox="0 0 47.585 49.326" overflow="visible" enable-background="new 0 0 47.585 49.326" xml:space="preserve"> + +<path + fill="&fill_color;" stroke="&stroke_color;" stroke-width="2" d="M 30.689595,16.460324 L 24.320145,12.001708 L 2.7550028,23.830689 L 23.319231,38.662412 L 45.157349,26.742438 L 36.877062,21.100925" id="path3195" /> +<path + fill="&fill_color;" stroke="&stroke_color;" stroke-width="2" + nodetypes="cscscssscsssssccc" + d="M 12.201296,21.930888 C 13.063838,20.435352 17.035411,18.617621 20.372026,18.965837 C 22.109464,19.147161 24.231003,20.786115 24.317406,21.584638 C 24.401593,22.43057 25.386617,24.647417 26.88611,24.600494 C 28.114098,24.562065 28.61488,23.562481 28.992123,22.444401 C 28.992123,22.444401 28.564434,17.493894 31.897757,15.363536 C 32.836646,14.763482 35.806711,14.411448 37.249047,15.221493 C 38.691382,16.031536 37.648261,19.495598 36.785717,20.991133 C 35.923174,22.48667 32.967872,24.980813 32.967872,24.980813 C 31.242783,27.971884 29.235995,28.5001 26.338769,28.187547 C 23.859153,27.920046 22.434219,26.128159 21.837191,24.708088 C 21.323835,23.487033 20.047743,22.524906 18.388178,22.52176 C 17.218719,22.519542 14.854476,23.017137 16.212763,25.620664 C 16.687174,26.53 18.919175,28.917592 21.08204,29.521929 C 22.919903,30.035455 26.713699,31.223552 30.30027,31.418089 C 26.770532,33.262079 21.760623,32.530604 18.909599,31.658168 C 17.361253,30.887002 9.0350995,26.651992 12.201296,21.930888 z " + id="path2209" /> +<path + fill="&fill_color;" stroke="&stroke_color;" stroke-width="1" + d="M 37.832194,18.895786 C 36.495131,19.851587 34.017797,22.097672 32.3528,21.069911" + id="path2211" + transform-center-y="-3.6171625" + transform-center-x="-0.50601649" /> +<circle + fill="&stroke_color;" stroke="none" stroke-width="0" + cx="33.926998" + cy="6.073" + r="1.927" + id="circle2213" + transform="matrix(0.269108,-0.4665976,-0.472839,-0.2655557,26.503175,35.608682)" + /> +</svg> diff --git a/ScanningWrite.activity/activity/activity.info b/ScanningWrite.activity/activity/activity.info new file mode 100644 index 0000000..7b7a672 --- /dev/null +++ b/ScanningWrite.activity/activity/activity.info @@ -0,0 +1,10 @@ + +[Activity] +name = Scanning Write +bundle_id = org.laptop.ScanningWrite +service_name = org.laptop.ScanningWrite +class = scanning_write.ScanningWriteActivity +icon = activity-icon +activity_version = 1 +mime_types = +show_launcher = yes diff --git a/ScanningWrite.activity/scanning_write.py b/ScanningWrite.activity/scanning_write.py new file mode 100644 index 0000000..b87bb90 --- /dev/null +++ b/ScanningWrite.activity/scanning_write.py @@ -0,0 +1,129 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +from sugar.activity import activity +import logging, sys, os, gtk, gst, time, shutil, subprocess, signal + +from wave import open as waveOpen +from ossaudiodev import open as ossOpen + + +class ScanningWriteActivity(activity.Activity): + + def TakePhoto(self, widget, data=None): + pipeline = gst.parse_launch('v4l2src ! ffmpegcolorspace ! jpegenc ! filesink location=/tmp/image.jpg') + pipeline.set_state(gst.STATE_PLAYING) + time.sleep(1) + pipeline.set_state(gst.STATE_NULL) + self.image.set_from_file("/tmp/image.jpg") + + def SavePhoto(self, widget, data=None): + shutil.move("/tmp/image.jpg", "tables/001/05_prueba.bmp") + + def ToggleRecordSound(self, widget): + + + + if self.recording is False: + # codigo de grabacion de sonido + + fname = "/tmp/audio.wav" + + self.rec_process = subprocess.Popen(["/usr/bin/arecord", "--file-type=wav", "--channels=1", "--format=S16_LE", "--rate=48000", fname]) + + s = 0 + while s <= 0: + try: + s = os.path.getsize(fname) + except os.error: + time.sleep(0.02) + + f = open(fname,'rb') + self.recording = True + + return (self.recording, self.rec_process, f) + + else: + #codigo que para la grabacion + os.kill(self.rec_process.pid, signal.SIGKILL) + self.rec_process.wait() + + self.recording = False + return self.recording + + + def PlaySound(self, widget, data=None): + os.system("/usr/bin/aplay /tmp/audio.wav") + + + def SaveSound(self, widget, data=None): + shutil.move("/tmp/audio.wav", "tables/001/05_prueba.wav") + + def __init__(self, handle): + print "running activity init", handle + activity.Activity.__init__(self, handle) + print "activity running" + + # Creates the Toolbox. It contains the Activity Toolbar, which is the + # bar that appears on every Sugar window and contains essential + # functionalities, such as the 'Collaborate' and 'Close' buttons. + toolbox = activity.ActivityToolbox(self) + self.set_toolbox(toolbox) + toolbox.show() + + self.recording = False + self.rec_process = None + + + self.mainbox = gtk.VBox() + + + # Here we show the image taken from the XO camera + self.image = gtk.Image() + + + # This is for buttons + self.keyboard = gtk.HBox() + + self.mainbox.pack_start(self.image) + self.mainbox.pack_start(self.keyboard) + + self.photo_trigger = gtk.Button("Sacá una foto!") + self.photo_trigger.connect("clicked", self.TakePhoto) + self.keyboard.pack_start(self.photo_trigger) + + self.photo_saver = gtk.Button("Guardá tu foto!") + self.photo_saver.connect("clicked", self.SavePhoto) + self.keyboard.pack_start(self.photo_saver) + + self.record_trigger = gtk.Button("Empieza grabación sonido") + self.record_trigger.connect("clicked", self.ToggleRecordSound) + self.keyboard.pack_start(self.record_trigger) + + self.sound_player = gtk.Button("Escuchá tu sonido!") + self.sound_player.connect("clicked", self.PlaySound) + self.keyboard.pack_start(self.sound_player) + + self.sound_saver = gtk.Button("Guardá tu sonido!") + self.sound_saver.connect("clicked", self.SaveSound) + self.keyboard.pack_start(self.sound_saver) + + + self.set_canvas(self.mainbox) + + self.mainbox.show_all() + + + + # When the button receives the "clicked" signal, it will call the + # function hello() passing it None as its argument. The hello() + # function is defined above. + # self.button.connect("clicked", self.hello, None) + + # Set the button to be our canvas. The canvas is the main section of + # every Sugar Window. It fills all the area below the toolbox. + # self.set_canvas(self.button) + + # The final step is to display this newly created widget. + # self.button.show() + + print "AT END OF THE CLASS"
\ No newline at end of file diff --git a/ScanningWrite.activity/setup.py b/ScanningWrite.activity/setup.py new file mode 100755 index 0000000..cfcceaa --- /dev/null +++ b/ScanningWrite.activity/setup.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python +try: + from sugar.activity import bundlebuilder + bundlebuilder.start() +except ImportError: + import os + os.system("find ./ | sed 's,^./,ScanningWrite.activity/,g' > MANIFEST") + os.system('rm ScanningWrite.xo') + os.chdir('..') + os.system('zip -r ScanningWrite.xo ScanningWrite.activity') + os.system('mv ScanningWrite.xo ./ScanningWrite.activity') + os.chdir('ScanningWrite.activity') + diff --git a/ScanningWrite.activity/tables/001/01_hola.bmp b/ScanningWrite.activity/tables/001/01_hola.bmp Binary files differnew file mode 100644 index 0000000..49a9618 --- /dev/null +++ b/ScanningWrite.activity/tables/001/01_hola.bmp diff --git a/ScanningWrite.activity/tables/001/01_hola.wav b/ScanningWrite.activity/tables/001/01_hola.wav Binary files differnew file mode 100644 index 0000000..dc9b1eb --- /dev/null +++ b/ScanningWrite.activity/tables/001/01_hola.wav diff --git a/ScanningWrite.activity/tables/001/02_adios.bmp b/ScanningWrite.activity/tables/001/02_adios.bmp Binary files differnew file mode 100644 index 0000000..5a64404 --- /dev/null +++ b/ScanningWrite.activity/tables/001/02_adios.bmp diff --git a/ScanningWrite.activity/tables/001/02_adios.wav b/ScanningWrite.activity/tables/001/02_adios.wav Binary files differnew file mode 100644 index 0000000..10fe474 --- /dev/null +++ b/ScanningWrite.activity/tables/001/02_adios.wav diff --git a/ScanningWrite.activity/tables/001/03_tengosed.bmp b/ScanningWrite.activity/tables/001/03_tengosed.bmp Binary files differnew file mode 100644 index 0000000..bb7c9bd --- /dev/null +++ b/ScanningWrite.activity/tables/001/03_tengosed.bmp diff --git a/ScanningWrite.activity/tables/001/03_tengosed.wav b/ScanningWrite.activity/tables/001/03_tengosed.wav Binary files differnew file mode 100644 index 0000000..b1a6b78 --- /dev/null +++ b/ScanningWrite.activity/tables/001/03_tengosed.wav diff --git a/ScanningWrite.activity/tables/001/04_te_quiero.bmp b/ScanningWrite.activity/tables/001/04_te_quiero.bmp Binary files differnew file mode 100644 index 0000000..9451964 --- /dev/null +++ b/ScanningWrite.activity/tables/001/04_te_quiero.bmp diff --git a/ScanningWrite.activity/tables/001/04_te_quiero.wav b/ScanningWrite.activity/tables/001/04_te_quiero.wav Binary files differnew file mode 100644 index 0000000..f455485 --- /dev/null +++ b/ScanningWrite.activity/tables/001/04_te_quiero.wav diff --git a/ScanningWrite.activity/tables/001/05_prueba.bmp b/ScanningWrite.activity/tables/001/05_prueba.bmp Binary files differnew file mode 100644 index 0000000..44ea16f --- /dev/null +++ b/ScanningWrite.activity/tables/001/05_prueba.bmp diff --git a/ScanningWrite.activity/tables/001/05_prueba.wav b/ScanningWrite.activity/tables/001/05_prueba.wav Binary files differnew file mode 100644 index 0000000..3db9f3f --- /dev/null +++ b/ScanningWrite.activity/tables/001/05_prueba.wav |