Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Aguiar <alanjas@hotmail.com>2013-03-02 18:07:15 (GMT)
committer Alan Aguiar <alanjas@hotmail.com>2013-03-02 18:07:15 (GMT)
commitea258a428969672401d77e56d48258e363d8136a (patch)
treedf351a2c1d452f16e6e42b82c58dd0553c166dfb
parenta563e163683ca06a6ef3e5d1145fb57d3e1bc447 (diff)
add port of Flavio
-rwxr-xr-xactivity.py182
-rw-r--r--activity/activity.info2
-rwxr-xr-xbutiaAPI.py20
-rwxr-xr-xfollowme.py4
-rwxr-xr-xlib/sugargame/canvas.py16
-rwxr-xr-xlib/sugargame/event.py45
-rwxr-xr-xmain.py14
-rw-r--r--po/en.po95
-rw-r--r--po/pl.po88
-rw-r--r--po/zh_CN.po97
-rwxr-xr-xsetup.py2
11 files changed, 273 insertions, 292 deletions
diff --git a/activity.py b/activity.py
index 40d850e..1bc1288 100755
--- a/activity.py
+++ b/activity.py
@@ -29,13 +29,14 @@
import sys
sys.path.insert(0, "lib")
-import gtk
-from sugar.activity import activity
-from sugar.graphics.toolbarbox import ToolbarBox
-from sugar.graphics.toolbutton import ToolButton
-from sugar.activity.widgets import ActivityToolbarButton
-from sugar.activity.widgets import StopButton
-from sugar.graphics.toolbarbox import ToolbarButton
+import gi
+from gi.repository import Gtk
+from sugar3.activity import activity
+from sugar3.graphics.toolbarbox import ToolbarBox
+from sugar3.graphics.toolbutton import ToolButton
+from sugar3.activity.widgets import ActivityToolbarButton
+from sugar3.activity.widgets import StopButton
+from sugar3.graphics.toolbarbox import ToolbarButton
import sugargame.canvas
import main
from gettext import gettext as _
@@ -78,7 +79,7 @@ class Activity(activity.Activity):
self.build_resolution_toolbar(toolbox)
self.build_colors_toolbar(toolbox)
- separador13 = gtk.SeparatorToolItem()
+ separador13 = Gtk.SeparatorToolItem()
separador13.props.draw = False
separador13.set_expand(True)
toolbox.toolbar.insert(separador13, -1)
@@ -88,39 +89,39 @@ class Activity(activity.Activity):
toolbox.toolbar.insert(stop_button, -1)
stop_button.show()
- self.set_toolbox(toolbox)
+ self.toolbar_box = toolbox
toolbox.show()
self.show_all()
def build_calibrate_toolbar(self, toolbox):
- calibrate_bar = gtk.Toolbar()
+ calibrate_bar = Gtk.Toolbar()
- item1 = gtk.ToolItem()
- label1 = gtk.Label()
+ item1 = Gtk.ToolItem()
+ label1 = Gtk.Label()
label1.set_text(' ' + _('Calibrate/Follow') + ' ')
item1.add(label1)
calibrate_bar.insert(item1, -1)
stop_calibrate = ToolButton('media-playback-stop')
- stop_calibrate.set_tooltip(_('Stop'))
+ stop_calibrate.set_tooltip_text(_('Stop'))
stop_calibrate.set_accelerator('<ctrl>space')
stop_calibrate.connect('clicked', self.stop_execute)
calibrate_bar.insert(stop_calibrate, -1)
- separator1 = gtk.SeparatorToolItem()
+ separator1 = Gtk.SeparatorToolItem()
separator1.props.draw = True
calibrate_bar.insert(separator1, -1)
- item3 = gtk.ToolItem()
- self.label_color_red = gtk.Label()
+ item3 = Gtk.ToolItem()
+ self.label_color_red = Gtk.Label()
self.label_color_red.set_text(' ' + _('Calibrated color:') + ' ' + _('Red') + ' ')
item3.add(self.label_color_red)
calibrate_bar.insert(item3, -1)
- item4 = gtk.ToolItem()
- self.red_spin = gtk.SpinButton()
+ item4 = Gtk.ToolItem()
+ self.red_spin = Gtk.SpinButton()
self.red_spin.set_range(0, 255)
self.red_spin.set_increments(1, 10)
self.red_spin.props.value = self.colorC[0]
@@ -128,14 +129,14 @@ class Activity(activity.Activity):
item4.add(self.red_spin)
calibrate_bar.insert(item4, -1)
- item5 = gtk.ToolItem()
- self.label_color_green = gtk.Label()
+ item5 = Gtk.ToolItem()
+ self.label_color_green = Gtk.Label()
self.label_color_green.set_text(' ' + _('Green') + ' ')
item5.add(self.label_color_green)
calibrate_bar.insert(item5, -1)
- item6 = gtk.ToolItem()
- self.green_spin = gtk.SpinButton()
+ item6 = Gtk.ToolItem()
+ self.green_spin = Gtk.SpinButton()
self.green_spin.set_range(0, 255)
self.green_spin.set_increments(1, 10)
self.green_spin.props.value = self.colorC[1]
@@ -143,14 +144,14 @@ class Activity(activity.Activity):
item6.add(self.green_spin)
calibrate_bar.insert(item6, -1)
- item7 = gtk.ToolItem()
- self.label_color_blue = gtk.Label()
+ item7 = Gtk.ToolItem()
+ self.label_color_blue = Gtk.Label()
self.label_color_blue.set_text(' ' + _('Blue') + ' ')
item7.add(self.label_color_blue)
calibrate_bar.insert(item7, -1)
- item8 = gtk.ToolItem()
- self.blue_spin = gtk.SpinButton()
+ item8 = Gtk.ToolItem()
+ self.blue_spin = Gtk.SpinButton()
self.blue_spin.set_range(0, 255)
self.blue_spin.set_increments(1, 10)
self.blue_spin.props.value = self.colorC[2]
@@ -168,16 +169,16 @@ class Activity(activity.Activity):
def build_options_toolbar(self, toolbox):
- options_bar = gtk.Toolbar()
+ options_bar = Gtk.Toolbar()
- item1 = gtk.ToolItem()
- label1 = gtk.Label()
+ item1 = Gtk.ToolItem()
+ label1 = Gtk.Label()
label1.set_text(' ' + _('Pixels') + ' ')
item1.add(label1)
options_bar.insert(item1, -1)
- item2 = gtk.ToolItem()
- pixels = gtk.SpinButton()
+ item2 = Gtk.ToolItem()
+ pixels = Gtk.SpinButton()
pixels.set_range(0, 1000)
pixels.set_increments(1, 10)
pixels.props.value = self.pixels
@@ -185,18 +186,18 @@ class Activity(activity.Activity):
item2.add(pixels)
options_bar.insert(item2, -1)
- separator1 = gtk.SeparatorToolItem()
+ separator1 = Gtk.SeparatorToolItem()
separator1.props.draw = True
options_bar.insert(separator1, -1)
- item3 = gtk.ToolItem()
- self.label_threshold_red = gtk.Label()
+ item3 = Gtk.ToolItem()
+ self.label_threshold_red = Gtk.Label()
self.label_threshold_red.set_text(' ' + _('Threshold:') + ' ' + _('Red') + ' ')
item3.add(self.label_threshold_red)
options_bar.insert(item3, -1)
- item4 = gtk.ToolItem()
- red_spin = gtk.SpinButton()
+ item4 = Gtk.ToolItem()
+ red_spin = Gtk.SpinButton()
red_spin.set_range(0, 255)
red_spin.set_increments(1, 10)
red_spin.props.value = self.threshold[0]
@@ -204,14 +205,14 @@ class Activity(activity.Activity):
item4.add(red_spin)
options_bar.insert(item4, -1)
- item5 = gtk.ToolItem()
- self.label_threshold_green = gtk.Label()
+ item5 = Gtk.ToolItem()
+ self.label_threshold_green = Gtk.Label()
self.label_threshold_green.set_text(' ' + _('Green') + ' ')
item5.add(self.label_threshold_green)
options_bar.insert(item5, -1)
- item6 = gtk.ToolItem()
- green_spin = gtk.SpinButton()
+ item6 = Gtk.ToolItem()
+ green_spin = Gtk.SpinButton()
green_spin.set_range(0, 255)
green_spin.set_increments(1, 10)
green_spin.props.value = self.threshold[1]
@@ -219,14 +220,14 @@ class Activity(activity.Activity):
item6.add(green_spin)
options_bar.insert(item6, -1)
- item7 = gtk.ToolItem()
- self.label_threshold_blue = gtk.Label()
+ item7 = Gtk.ToolItem()
+ self.label_threshold_blue = Gtk.Label()
self.label_threshold_blue.set_text(' ' + _('Blue') + ' ')
item7.add(self.label_threshold_blue)
options_bar.insert(item7, -1)
- item8 = gtk.ToolItem()
- blue_spin = gtk.SpinButton()
+ item8 = Gtk.ToolItem()
+ blue_spin = Gtk.SpinButton()
blue_spin.set_range(0, 255)
blue_spin.set_increments(1, 10)
blue_spin.props.value = self.threshold[2]
@@ -244,16 +245,16 @@ class Activity(activity.Activity):
def build_resolution_toolbar(self, toolbox):
- resolution_bar = gtk.Toolbar()
+ resolution_bar = Gtk.Toolbar()
- item1 = gtk.ToolItem()
- label1 = gtk.Label()
+ item1 = Gtk.ToolItem()
+ label1 = Gtk.Label()
label1.set_text(' ' + _('Show size') + ' ')
item1.add(label1)
resolution_bar.insert(item1, -1)
- item2 = gtk.ToolItem()
- x_size_spin = gtk.SpinButton()
+ item2 = Gtk.ToolItem()
+ x_size_spin = Gtk.SpinButton()
x_size_spin.set_range(160, 1200)
x_size_spin.set_increments(1, 10)
x_size_spin.props.value = int(self.show_size[0])
@@ -261,14 +262,14 @@ class Activity(activity.Activity):
item2.add(x_size_spin)
resolution_bar.insert(item2, -1)
- item3 = gtk.ToolItem()
- label3 = gtk.Label()
+ item3 = Gtk.ToolItem()
+ label3 = Gtk.Label()
label3.set_text(' X ')
item3.add(label3)
resolution_bar.insert(item3, -1)
- item4 = gtk.ToolItem()
- y_size_spin = gtk.SpinButton()
+ item4 = Gtk.ToolItem()
+ y_size_spin = Gtk.SpinButton()
y_size_spin.set_range(120, 900)
y_size_spin.set_increments(1, 10)
y_size_spin.props.value = int(self.show_size[1])
@@ -276,12 +277,12 @@ class Activity(activity.Activity):
item4.add(y_size_spin)
resolution_bar.insert(item4, -1)
- separator1 = gtk.SeparatorToolItem()
+ separator1 = Gtk.SeparatorToolItem()
separator1.props.draw = True
resolution_bar.insert(separator1, -1)
- item5 = gtk.ToolItem()
- label5 = gtk.Label()
+ item5 = Gtk.ToolItem()
+ label5 = Gtk.Label()
label5.set_text(' ' + _('Show grid'))
item5.add(label5)
resolution_bar.insert(item5, -1)
@@ -299,33 +300,33 @@ class Activity(activity.Activity):
def build_colors_toolbar(self, toolbox):
- barra_colors = gtk.Toolbar()
+ barra_colors = Gtk.Toolbar()
- item1 = gtk.ToolItem()
- label1 = gtk.Label()
+ item1 = Gtk.ToolItem()
+ label1 = Gtk.Label()
label1.set_text(_('Color mode') + ' ')
item1.add(label1)
barra_colors.insert(item1, -1)
- item2 = gtk.ToolItem()
+ item2 = Gtk.ToolItem()
modes = ('RGB', 'YUV', 'HSV')
combo = Combo(modes)
item2.add(combo)
combo.connect('changed', self.change_combo)
barra_colors.insert(item2, -1)
- separator1 = gtk.SeparatorToolItem()
+ separator1 = Gtk.SeparatorToolItem()
separator1.props.draw = True
barra_colors.insert(separator1, -1)
- item_l = gtk.ToolItem()
- label4 = gtk.Label()
+ item_l = Gtk.ToolItem()
+ label4 = Gtk.Label()
label4.set_text(_('Brightness') + ' ')
item_l.add(label4)
barra_colors.insert(item_l, -1)
- item = gtk.ToolItem()
- brightness_spin = gtk.SpinButton()
+ item = Gtk.ToolItem()
+ brightness_spin = Gtk.SpinButton()
brightness_spin.set_range(-1, 255)
brightness_spin.set_increments(1, 10)
brightness_spin.props.value = int(self.brightness)
@@ -333,49 +334,49 @@ class Activity(activity.Activity):
item.add(brightness_spin)
barra_colors.insert(item, -1)
- separator2 = gtk.SeparatorToolItem()
+ separator2 = Gtk.SeparatorToolItem()
separator2.props.draw = True
barra_colors.insert(separator2, -1)
- item3 = gtk.ToolItem()
- label3 = gtk.Label()
+ item3 = Gtk.ToolItem()
+ label3 = Gtk.Label()
label3.set_text(_('Threshold view'))
item3.add(label3)
barra_colors.insert(item3, -1)
threshold_view = ToolButton('media-playback-stop')
threshold_view.connect('clicked', self.threshold_view)
- threshold_view.set_tooltip(_('Yes'))
+ threshold_view.set_tooltip_text(_('Yes'))
barra_colors.insert(threshold_view, -1)
- separator3 = gtk.SeparatorToolItem()
+ separator3 = Gtk.SeparatorToolItem()
separator3.props.draw = True
barra_colors.insert(separator3, -1)
- item4 = gtk.ToolItem()
- label4 = gtk.Label()
+ item4 = Gtk.ToolItem()
+ label4 = Gtk.Label()
label4.set_text(_('Outline'))
item4.add(label4)
barra_colors.insert(item4, -1)
outline_view = ToolButton('media-playback-stop')
outline_view.connect('clicked', self.outline_view)
- outline_view.set_tooltip(_('Yes'))
+ outline_view.set_tooltip_text(_('Yes'))
barra_colors.insert(outline_view, -1)
- separator4 = gtk.SeparatorToolItem()
+ separator4 = Gtk.SeparatorToolItem()
separator4.props.draw = True
barra_colors.insert(separator4, -1)
- item5 = gtk.ToolItem()
- label5 = gtk.Label()
+ item5 = Gtk.ToolItem()
+ label5 = Gtk.Label()
label5.set_text(_('Rects'))
item5.add(label5)
barra_colors.insert(item5, -1)
rects_view = ToolButton('media-playback-stop')
rects_view.connect('clicked', self.rects_view)
- rects_view.set_tooltip(_('Yes'))
+ rects_view.set_tooltip_text(_('Yes'))
barra_colors.insert(rects_view, -1)
barra_colors.show_all()
@@ -421,30 +422,30 @@ class Activity(activity.Activity):
self.followme_activity.put_threshold_view(self.use_threshold_view)
if not self.use_threshold_view:
button.set_icon('media-playback-start')
- button.set_tooltip(_('Yes'))
+ button.set_tooltip_text(_('Yes'))
else:
button.set_icon('media-playback-stop')
- button.set_tooltip(_('No'))
+ button.set_tooltip_text(_('No'))
def outline_view(self, button):
self.use_outline_view = not self.use_outline_view
self.followme_activity.put_outline_view(self.use_outline_view)
if not self.use_outline_view:
button.set_icon('media-playback-start')
- button.set_tooltip(_('Yes'))
+ button.set_tooltip_text(_('Yes'))
else:
button.set_icon('media-playback-stop')
- button.set_tooltip(_('No'))
+ button.set_tooltip_text(_('No'))
def rects_view(self, button):
self.use_rects_view = not self.use_rects_view
self.followme_activity.put_rects_view(self.use_rects_view)
if not self.use_rects_view:
button.set_icon('media-playback-start')
- button.set_tooltip(_('Yes'))
+ button.set_tooltip_text(_('Yes'))
else:
button.set_icon('media-playback-stop')
- button.set_tooltip(_('No'))
+ button.set_tooltip_text(_('No'))
def put_color(self, color):
self.colorC = color
@@ -513,28 +514,29 @@ class Activity(activity.Activity):
self.followme_activity.mode_calibrating(self.calibrating)
if not self.calibrating:
button.set_icon('media-playback-start')
- button.set_tooltip(_('Start'))
+ button.set_tooltip_text(_('Start'))
else:
button.set_icon('media-playback-stop')
- button.set_tooltip(_('Stop'))
+ button.set_tooltip_text(_('Stop'))
def grid_click(self, button):
self.show_grid = not self.show_grid
self.followme_activity.put_grid(self.show_grid)
-class Combo(gtk.ComboBox):
+class Combo(Gtk.ComboBox):
def __init__(self, options):
- self.liststore = gtk.ListStore(str)
+ self.liststore = Gtk.ListStore(str)
for o in options:
self.liststore.append([o])
- gtk.ComboBox.__init__(self, self.liststore)
-
- cell = gtk.CellRendererText()
+ Gtk.ComboBox.__init__(self)
+ self.set_model(self.liststore)
+
+ cell = Gtk.CellRendererText()
self.pack_start(cell, True)
self.add_attribute(cell, 'text', 0)
diff --git a/activity/activity.info b/activity/activity.info
index 9aff32d..21ced64 100644
--- a/activity/activity.info
+++ b/activity/activity.info
@@ -1,6 +1,6 @@
[Activity]
name = FollowMe Butia
-activity_version = 8
+activity_version = 9
bundle_id = uy.edu.fing.followme
exec = sugar-activity activity.Activity
show_launcher = yes
diff --git a/butiaAPI.py b/butiaAPI.py
index 94332c8..4bb6ca3 100755
--- a/butiaAPI.py
+++ b/butiaAPI.py
@@ -1,8 +1,8 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
-#
+#
# ButiaAPI
-# Copyright (c) 2009, 2010, 2011, 2012 Butiá Team butia@fing.edu.uy
+# Copyright (c) 2009, 2010, 2011, 2012 Butiá Team butia@fing.edu.uy
# Butia is a free open plataform for robotics projects
# www.fing.edu.uy/inco/proyectos/butia
# Facultad de Ingenieria - Universidad de la República - Uruguay
@@ -59,8 +59,8 @@ class robot:
msg = msg +'\n'
ret = ERROR_SENSOR_READ
self.lock.acquire()
- try:
- self.client.send(msg)
+ try:
+ self.client.send(msg)
ret = self.fclient.readline()
ret = ret[:-1]
except:
@@ -76,7 +76,7 @@ class robot:
self.close()
try:
self.client = socket.socket()
- self.client.connect((self.host, self.port))
+ self.client.connect((self.host, self.port))
self.fclient = self.client.makefile()
msg = 'INIT'
#bobot server instance is running, but we have to check for new or remove hardware
@@ -129,7 +129,7 @@ class robot:
return self.doCommand(msg)
#######################################################################
- ### Useful functions
+ ### Useful functions
#######################################################################
# returns if the module_name is present
@@ -193,8 +193,8 @@ class robot:
else:
return self.callModule('ax', 'joint_mode', msg)
- def set_speed(self, idMotor = '0', speed = '0'):
- msg = idMotor + ' ' + speed
+ def set_speed(self, idMotor = '0', speed = '0'):
+ msg = idMotor + ' ' + speed
if self.ver == BUTIA_1:
return self.callModule('ax', 'set_speed', msg) ##TODO implement
else:
@@ -223,11 +223,11 @@ class robot:
def ping(self):
return self.callModule('placa', 'ping')
- # returns the approximate charge of the battery
+ # returns the approximate charge of the battery
def getBatteryCharge(self):
return self.callModule('butia', 'get_volt')
- # returns the firmware version
+ # returns the firmware version
def getVersion(self):
ver = self.callModule('butia', 'read_ver')
if not(ver == ERROR_SENSOR_READ):
diff --git a/followme.py b/followme.py
index f791412..522d624 100755
--- a/followme.py
+++ b/followme.py
@@ -31,7 +31,7 @@ import pygame.camera
from gettext import gettext as _
-class FollowMe(object):
+class FollowMe():
def __init__(self, parent):
@@ -127,7 +127,7 @@ class FollowMe(object):
if self.use_threshold_view:
pygame.transform.threshold(self.captura_aux2, self.captura, color, (threshold[0],threshold[1], threshold[2]), (0,0,0))
- pygame.transform.threshold(self.captura_aux, self.captura_aux2, (0, 0, 0), (10, 10, 10), (255, 255, 255))
+ pygame.transform.threshold(self.captura_aux, self.captura_aux2, (0, 0, 0), (10, 10, 10), (255, 255, 255))
mascara = pygame.mask.from_threshold(self.captura_aux, (255, 255, 255), (10, 10, 10))
else:
mascara = pygame.mask.from_threshold(self.captura, color, (10, 10, 10))
diff --git a/lib/sugargame/canvas.py b/lib/sugargame/canvas.py
index 980cb73..1ce0250 100755
--- a/lib/sugargame/canvas.py
+++ b/lib/sugargame/canvas.py
@@ -1,18 +1,18 @@
import os
-import gtk
-import gobject
+from gi.repository import Gtk
+from gi.repository import GObject
import pygame
import event
CANVAS = None
-class PygameCanvas(gtk.EventBox):
+class PygameCanvas(Gtk.EventBox):
"""
mainwindow is the activity intself.
"""
def __init__(self, mainwindow, pointer_hint = True):
- gtk.EventBox.__init__(self)
+ GObject.GObject.__init__(self)
global CANVAS
assert CANVAS == None, "Only one PygameCanvas can be created, ever."
@@ -23,9 +23,9 @@ class PygameCanvas(gtk.EventBox):
self._mainwindow = mainwindow
- self.set_flags(gtk.CAN_FOCUS)
+ self.set_can_focus(True)
- self._socket = gtk.Socket()
+ self._socket = Gtk.Socket()
self.add(self._socket)
self.show_all()
@@ -34,7 +34,7 @@ class PygameCanvas(gtk.EventBox):
# Sugar activity is not properly created until after its constructor returns.
# If the Pygame main loop is called from the activity constructor, the
# constructor never returns and the activity freezes.
- gobject.idle_add(self._run_pygame_cb, main_fn)
+ GObject.idle_add(self._run_pygame_cb, main_fn)
def _run_pygame_cb(self, main_fn):
assert pygame.display.get_surface() is None, "PygameCanvas.run_pygame can only be called once."
@@ -45,7 +45,7 @@ class PygameCanvas(gtk.EventBox):
pygame.init()
# Restore the default cursor.
- self._socket.window.set_cursor(None)
+ self._socket.props.window.set_cursor(None)
# Initialize the Pygame window.
r = self.get_allocation()
diff --git a/lib/sugargame/event.py b/lib/sugargame/event.py
index 4cc3be8..431a600 100755
--- a/lib/sugargame/event.py
+++ b/lib/sugargame/event.py
@@ -1,5 +1,6 @@
-import gtk
-import gobject
+from gi.repository import Gtk
+from gi.repository import Gdk
+from gi.repository import GObject
import pygame
import pygame.event
import logging
@@ -46,20 +47,20 @@ class Translator(object):
# Enable events
# (add instead of set here because the main window is already realized)
self._mainwindow.add_events(
- gtk.gdk.KEY_PRESS_MASK | \
- gtk.gdk.KEY_RELEASE_MASK \
+ Gdk.EventMask.KEY_PRESS_MASK | \
+ Gdk.EventMask.KEY_RELEASE_MASK \
)
self._inner_evb.set_events(
- gtk.gdk.POINTER_MOTION_MASK | \
- gtk.gdk.POINTER_MOTION_HINT_MASK | \
- gtk.gdk.BUTTON_MOTION_MASK | \
- gtk.gdk.BUTTON_PRESS_MASK | \
- gtk.gdk.BUTTON_RELEASE_MASK
+ Gdk.EventMask.POINTER_MOTION_MASK | \
+ Gdk.EventMask.POINTER_MOTION_HINT_MASK | \
+ Gdk.EventMask.BUTTON_MOTION_MASK | \
+ Gdk.EventMask.BUTTON_PRESS_MASK | \
+ Gdk.EventMask.BUTTON_RELEASE_MASK
)
- self._mainwindow.set_flags(gtk.CAN_FOCUS)
- self._inner_evb.set_flags(gtk.CAN_FOCUS)
+ self._mainwindow.set_can_focus(True)
+ self._inner_evb.set_can_focus(True)
# Callback functions to link the event systems
self._mainwindow.connect('unrealize', self._quit_cb)
@@ -68,7 +69,7 @@ class Translator(object):
self._inner_evb.connect('button_press_event', self._mousedown_cb)
self._inner_evb.connect('button_release_event', self._mouseup_cb)
self._inner_evb.connect('motion-notify-event', self._mousemove_cb)
- self._inner_evb.connect('expose-event', self._expose_cb)
+ self._inner_evb.connect('draw', self._draw_cb)
self._inner_evb.connect('configure-event', self._resize_cb)
# Internal data
@@ -88,7 +89,7 @@ class Translator(object):
pygame.mouse.get_pressed = self._get_mouse_pressed
pygame.mouse.get_pos = self._get_mouse_pos
- def _expose_cb(self, event, widget):
+ def _draw_cb(self, widget, event):
if pygame.display.get_init():
pygame.event.post(pygame.event.Event(pygame.VIDEOEXPOSE))
return True
@@ -133,7 +134,7 @@ class Translator(object):
return mod
def _keyevent(self, widget, event, type):
- key = gtk.gdk.keyval_name(event.keyval)
+ key = Gdk.keyval_name(event.keyval)
if key is None:
# No idea what this key is.
return False
@@ -157,7 +158,7 @@ class Translator(object):
self.__keystate[keycode] = type == pygame.KEYDOWN
if type == pygame.KEYUP:
mod = self._keymods()
- ukey = unichr(gtk.gdk.keyval_to_unicode(event.keyval))
+ ukey = unichr(Gdk.keyval_to_unicode(event.keyval))
if ukey == '\000':
ukey = ''
evt = pygame.event.Event(type, key=keycode, unicode=ukey, mod=mod)
@@ -189,19 +190,19 @@ class Translator(object):
# if this is a hint, then let's get all the necessary
# information, if not it's all we need.
if event.is_hint:
- x, y, state = event.window.get_pointer()
+ win, x, y, state = event.window.get_device_position(event.device)
else:
x = event.x
y = event.y
- state = event.state
+ state = event.get_state()
rel = (x - self.__mouse_pos[0], y - self.__mouse_pos[1])
self.__mouse_pos = (x, y)
self.__button_state = [
- state & gtk.gdk.BUTTON1_MASK and 1 or 0,
- state & gtk.gdk.BUTTON2_MASK and 1 or 0,
- state & gtk.gdk.BUTTON3_MASK and 1 or 0,
+ state & Gdk.ModifierType.BUTTON1_MASK and 1 or 0,
+ state & Gdk.ModifierType.BUTTON2_MASK and 1 or 0,
+ state & Gdk.ModifierType.BUTTON3_MASK and 1 or 0,
]
evt = pygame.event.Event(pygame.MOUSEMOTION,
@@ -224,9 +225,9 @@ class Translator(object):
def _set_repeat(self, delay=None, interval=None):
if delay is not None and self.__repeat[0] is None:
- self.__tick_id = gobject.timeout_add(10, self._tick_cb)
+ self.__tick_id = GObject.timeout_add(10, self._tick_cb)
elif delay is None and self.__repeat[0] is not None:
- gobject.source_remove(self.__tick_id)
+ GObject.source_remove(self.__tick_id)
self.__repeat = (delay, interval)
def _get_mouse_pos(self):
diff --git a/main.py b/main.py
index c260a54..5040560 100755
--- a/main.py
+++ b/main.py
@@ -26,7 +26,9 @@
# Aylen Ricca <ar18_90@hotmail.com>
# Rodrigo Dearmas <piegrande46@hotmail.com>
-import gtk
+import gi
+from gi.repository import Gtk
+
import pygame
from robot import Robot
from followme import FollowMe
@@ -90,16 +92,16 @@ class Main:
self.mode = 'RGB'
self.c = FollowMe(self.parent)
if (self.c.cam == None):
- while gtk.events_pending():
- gtk.main_iteration()
+ while Gtk.events_pending():
+ Gtk.main_iteration()
for event in pygame.event.get():
if event.type == pygame.QUIT:
break
else:
- run = True
+ run = True
while run:
- while gtk.events_pending():
- gtk.main_iteration()
+ while Gtk.events_pending():
+ Gtk.main_iteration()
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
diff --git a/po/en.po b/po/en.po
index 03ce748..d6f1229 100644
--- a/po/en.po
+++ b/po/en.po
@@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-10-24 00:32-0400\n"
-"PO-Revision-Date: 2012-10-24 07:07+0200\n"
+"POT-Creation-Date: 2012-09-27 14:56-0400\n"
+"PO-Revision-Date: 2012-10-08 01:13+0200\n"
"Last-Translator: Chris <cjl@laptop.org>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: en\n"
@@ -34,23 +34,23 @@ msgstr "<Ctrl>Q"
msgid "Calibrate/Follow"
msgstr "Calibrate/Follow"
-#: activity.py:107 activity.py:519
+#: activity.py:107 activity.py:484
msgid "Stop"
msgstr "Stop"
-#: activity.py:118 activity.py:391 activity.py:400 activity.py:409
+#: activity.py:118 activity.py:376 activity.py:385 activity.py:394
msgid "Calibrated color:"
msgstr "Calibrated color:"
-#: activity.py:118 activity.py:194 activity.py:391 activity.py:395
+#: activity.py:118 activity.py:194 activity.py:376 activity.py:380
msgid "Red"
msgstr "Red"
-#: activity.py:133 activity.py:209 activity.py:392 activity.py:396
+#: activity.py:133 activity.py:209 activity.py:377 activity.py:381
msgid "Green"
msgstr "Green"
-#: activity.py:148 activity.py:224 activity.py:393 activity.py:397
+#: activity.py:148 activity.py:224 activity.py:378 activity.py:382
msgid "Blue"
msgstr "Blue"
@@ -62,7 +62,7 @@ msgstr "Calibrate"
msgid "Pixels"
msgstr "Pixels"
-#: activity.py:194 activity.py:395 activity.py:404 activity.py:413
+#: activity.py:194 activity.py:380 activity.py:389 activity.py:398
msgid "Threshold:"
msgstr "Threshold:"
@@ -78,98 +78,89 @@ msgstr "Show size"
msgid "Show grid"
msgstr "Show grid"
-#: activity.py:294
+#: activity.py:299
+msgid "Show captures"
+msgstr "Show captures"
+
+#: activity.py:305 activity.py:494
+msgid "Hide"
+msgstr "Hide"
+
+#: activity.py:309
msgid "Resolution"
msgstr "Resolution"
-#: activity.py:306
+#: activity.py:321
msgid "Color mode"
msgstr "Color mode"
-#: activity.py:323
+#: activity.py:338
msgid "Brightness"
msgstr "Brightness"
-#: activity.py:342
-msgid "Threshold view"
-msgstr "Threshold view"
+#: activity.py:357
+msgid "Show threshold view"
+msgstr "Show threshold view"
-#: activity.py:348 activity.py:363 activity.py:378 activity.py:424
-#: activity.py:434 activity.py:444
+#: activity.py:363 activity.py:409
msgid "Yes"
msgstr "Yes"
-#: activity.py:357
-msgid "Outline"
-msgstr "Outline"
-
-#: activity.py:372
-msgid "Rects"
-msgstr "Rects"
-
-#: activity.py:382
+#: activity.py:367
msgid "Colors"
msgstr "Colors"
-#: activity.py:400 activity.py:404
+#: activity.py:385 activity.py:389
msgid "Luma"
msgstr "Luma"
-#: activity.py:401 activity.py:405
+#: activity.py:386 activity.py:390
msgid "U"
msgstr "U"
-#: activity.py:402 activity.py:406
+#: activity.py:387 activity.py:391
msgid "V"
msgstr "V"
-#: activity.py:409 activity.py:413
+#: activity.py:394 activity.py:398
msgid "Hue"
msgstr "Hue"
-#: activity.py:410 activity.py:414
+#: activity.py:395 activity.py:399
msgid "Saturation"
msgstr "Saturation"
-#: activity.py:411 activity.py:415
+#: activity.py:396 activity.py:400
msgid "Value"
msgstr "Value"
-#: activity.py:427 activity.py:437 activity.py:447
+#: activity.py:412
msgid "No"
msgstr "No"
-#: activity.py:516
+#: activity.py:481
msgid "Start"
msgstr "Start"
-#: followme.py:67
+#: activity.py:497
+msgid "Show"
+msgstr "Show"
+
+#: followme.py:66
+msgid "Error in stop camera"
+msgstr "Error in stop camera"
+
+#: followme.py:78
msgid "Error on initialization of the camera"
msgstr "Error on initialization of the camera"
-#: followme.py:69
+#: followme.py:80
msgid "No cameras was found"
msgstr "No cameras was found"
-#: followme.py:77
-msgid "Error in stop camera"
-msgstr "Error in stop camera"
-
-#: robot.py:67
+#: followme.py:201
msgid "Butia robot was not detected"
msgstr "Butia robot was not detected"
-#~ msgid "Show captures"
-#~ msgstr "Show captures"
-
-#~ msgid "Hide"
-#~ msgstr "Hide"
-
-#~ msgid "Show threshold view"
-#~ msgstr "Show threshold view"
-
-#~ msgid "Show"
-#~ msgstr "Show"
-
#~ msgid "Camera was not found"
#~ msgstr "Camera was not found"
diff --git a/po/pl.po b/po/pl.po
index 639fd08..98c105f 100644
--- a/po/pl.po
+++ b/po/pl.po
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-10-24 00:32-0400\n"
+"POT-Creation-Date: 2012-09-27 14:56-0400\n"
"PO-Revision-Date: 2012-09-14 02:31+0200\n"
"Last-Translator: Kamila <kamilafilipowska@yahoo.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -35,23 +35,23 @@ msgstr "<Ctrl>Q"
msgid "Calibrate/Follow"
msgstr "Skalibruj/Śledź"
-#: activity.py:107 activity.py:519
+#: activity.py:107 activity.py:484
msgid "Stop"
msgstr "Zatrzymaj"
-#: activity.py:118 activity.py:391 activity.py:400 activity.py:409
+#: activity.py:118 activity.py:376 activity.py:385 activity.py:394
msgid "Calibrated color:"
msgstr "Skalibrowany kolor:"
-#: activity.py:118 activity.py:194 activity.py:391 activity.py:395
+#: activity.py:118 activity.py:194 activity.py:376 activity.py:380
msgid "Red"
msgstr "Czerwony"
-#: activity.py:133 activity.py:209 activity.py:392 activity.py:396
+#: activity.py:133 activity.py:209 activity.py:377 activity.py:381
msgid "Green"
msgstr "Zielony"
-#: activity.py:148 activity.py:224 activity.py:393 activity.py:397
+#: activity.py:148 activity.py:224 activity.py:378 activity.py:382
msgid "Blue"
msgstr "Niebieski"
@@ -63,7 +63,7 @@ msgstr "Kalibruj"
msgid "Pixels"
msgstr "Piksele"
-#: activity.py:194 activity.py:395 activity.py:404 activity.py:413
+#: activity.py:194 activity.py:380 activity.py:389 activity.py:398
msgid "Threshold:"
msgstr "Próg:"
@@ -79,95 +79,89 @@ msgstr "Pokaż rozmiar"
msgid "Show grid"
msgstr "Pokaż siatkę"
-#: activity.py:294
+#: activity.py:299
+msgid "Show captures"
+msgstr "Pokaż zrzuty"
+
+#: activity.py:305 activity.py:494
+msgid "Hide"
+msgstr "Ukryj"
+
+#: activity.py:309
msgid "Resolution"
msgstr "Rozdzielczość"
-#: activity.py:306
+#: activity.py:321
msgid "Color mode"
msgstr ""
-#: activity.py:323
+#: activity.py:338
msgid "Brightness"
msgstr ""
-#: activity.py:342
-msgid "Threshold view"
+#: activity.py:357
+msgid "Show threshold view"
msgstr ""
-#: activity.py:348 activity.py:363 activity.py:378 activity.py:424
-#: activity.py:434 activity.py:444
+#: activity.py:363 activity.py:409
msgid "Yes"
msgstr "Tak"
-#: activity.py:357
-msgid "Outline"
-msgstr ""
-
-#: activity.py:372
-msgid "Rects"
-msgstr ""
-
-#: activity.py:382
+#: activity.py:367
msgid "Colors"
msgstr "Kolory"
-#: activity.py:400 activity.py:404
+#: activity.py:385 activity.py:389
msgid "Luma"
msgstr ""
-#: activity.py:401 activity.py:405
+#: activity.py:386 activity.py:390
msgid "U"
msgstr "U"
-#: activity.py:402 activity.py:406
+#: activity.py:387 activity.py:391
msgid "V"
msgstr "V"
-#: activity.py:409 activity.py:413
+#: activity.py:394 activity.py:398
msgid "Hue"
msgstr "Odcień"
-#: activity.py:410 activity.py:414
+#: activity.py:395 activity.py:399
msgid "Saturation"
msgstr "Nasycenie"
-#: activity.py:411 activity.py:415
+#: activity.py:396 activity.py:400
msgid "Value"
msgstr "Wartość"
-#: activity.py:427 activity.py:437 activity.py:447
+#: activity.py:412
msgid "No"
msgstr "Nie"
-#: activity.py:516
+#: activity.py:481
msgid "Start"
msgstr "Rozpocznij"
-#: followme.py:67
+#: activity.py:497
+msgid "Show"
+msgstr "Pokaż"
+
+#: followme.py:66
+msgid "Error in stop camera"
+msgstr ""
+
+#: followme.py:78
msgid "Error on initialization of the camera"
msgstr "Błąd w inicjalizacji kamery"
-#: followme.py:69
+#: followme.py:80
msgid "No cameras was found"
msgstr "Nie znaleziono kamery"
-#: followme.py:77
-msgid "Error in stop camera"
-msgstr ""
-
-#: robot.py:67
+#: followme.py:201
msgid "Butia robot was not detected"
msgstr "Robot Butia nie został wykryty"
-#~ msgid "Show captures"
-#~ msgstr "Pokaż zrzuty"
-
-#~ msgid "Hide"
-#~ msgstr "Ukryj"
-
-#~ msgid "Show"
-#~ msgstr "Pokaż"
-
#~ msgid "Camera was not found"
#~ msgstr "Kamera nie została znaleziona"
diff --git a/po/zh_CN.po b/po/zh_CN.po
index a1f2bfa..89df8c7 100644
--- a/po/zh_CN.po
+++ b/po/zh_CN.po
@@ -6,9 +6,9 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-10-24 00:32-0400\n"
-"PO-Revision-Date: 2012-11-04 10:13+0200\n"
-"Last-Translator: Chris <cjl@laptop.org>\n"
+"POT-Creation-Date: 2012-09-27 14:56-0400\n"
+"PO-Revision-Date: 2012-10-06 05:24+0200\n"
+"Last-Translator: lite <litekok@gmail.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: zh_CN\n"
"MIME-Version: 1.0\n"
@@ -34,23 +34,23 @@ msgstr "<Ctrl>Q"
msgid "Calibrate/Follow"
msgstr "校准/跟随"
-#: activity.py:107 activity.py:519
+#: activity.py:107 activity.py:484
msgid "Stop"
msgstr "停止"
-#: activity.py:118 activity.py:391 activity.py:400 activity.py:409
+#: activity.py:118 activity.py:376 activity.py:385 activity.py:394
msgid "Calibrated color:"
msgstr "校准颜色:"
-#: activity.py:118 activity.py:194 activity.py:391 activity.py:395
+#: activity.py:118 activity.py:194 activity.py:376 activity.py:380
msgid "Red"
msgstr "红"
-#: activity.py:133 activity.py:209 activity.py:392 activity.py:396
+#: activity.py:133 activity.py:209 activity.py:377 activity.py:381
msgid "Green"
msgstr "绿"
-#: activity.py:148 activity.py:224 activity.py:393 activity.py:397
+#: activity.py:148 activity.py:224 activity.py:378 activity.py:382
msgid "Blue"
msgstr "蓝"
@@ -62,7 +62,7 @@ msgstr "校准"
msgid "Pixels"
msgstr "像素"
-#: activity.py:194 activity.py:395 activity.py:404 activity.py:413
+#: activity.py:194 activity.py:380 activity.py:389 activity.py:398
msgid "Threshold:"
msgstr "阈值"
@@ -78,98 +78,89 @@ msgstr "显示大小"
msgid "Show grid"
msgstr "显示网格"
-#: activity.py:294
+#: activity.py:299
+msgid "Show captures"
+msgstr "显示捕获"
+
+#: activity.py:305 activity.py:494
+msgid "Hide"
+msgstr "隐藏"
+
+#: activity.py:309
msgid "Resolution"
msgstr "分辨率"
-#: activity.py:306
+#: activity.py:321
msgid "Color mode"
msgstr "颜色模式"
-#: activity.py:323
+#: activity.py:338
msgid "Brightness"
msgstr "亮度"
-#: activity.py:342
-msgid "Threshold view"
-msgstr "阈值视图"
+#: activity.py:357
+msgid "Show threshold view"
+msgstr "显示阈值视图"
-#: activity.py:348 activity.py:363 activity.py:378 activity.py:424
-#: activity.py:434 activity.py:444
+#: activity.py:363 activity.py:409
msgid "Yes"
msgstr "是"
-#: activity.py:357
-msgid "Outline"
-msgstr "概述"
-
-#: activity.py:372
-msgid "Rects"
-msgstr "方框"
-
-#: activity.py:382
+#: activity.py:367
msgid "Colors"
msgstr "颜色"
-#: activity.py:400 activity.py:404
+#: activity.py:385 activity.py:389
msgid "Luma"
msgstr "亮度"
-#: activity.py:401 activity.py:405
+#: activity.py:386 activity.py:390
msgid "U"
msgstr "U"
-#: activity.py:402 activity.py:406
+#: activity.py:387 activity.py:391
msgid "V"
msgstr "V"
-#: activity.py:409 activity.py:413
+#: activity.py:394 activity.py:398
msgid "Hue"
msgstr "色调"
-#: activity.py:410 activity.py:414
+#: activity.py:395 activity.py:399
msgid "Saturation"
msgstr "饱和"
-#: activity.py:411 activity.py:415
+#: activity.py:396 activity.py:400
msgid "Value"
msgstr "值"
-#: activity.py:427 activity.py:437 activity.py:447
+#: activity.py:412
msgid "No"
msgstr "否"
-#: activity.py:516
+#: activity.py:481
msgid "Start"
msgstr "开始"
-#: followme.py:67
+#: activity.py:497
+msgid "Show"
+msgstr "显示"
+
+#: followme.py:66
+msgid "Error in stop camera"
+msgstr "停止摄像头出错"
+
+#: followme.py:78
msgid "Error on initialization of the camera"
msgstr "摄像头初始化出错"
-#: followme.py:69
+#: followme.py:80
msgid "No cameras was found"
msgstr "没有找到摄像头"
-#: followme.py:77
-msgid "Error in stop camera"
-msgstr "停止摄像头出错"
-
-#: robot.py:67
+#: followme.py:201
msgid "Butia robot was not detected"
msgstr "没检测到机器人布提"
-#~ msgid "Show captures"
-#~ msgstr "显示捕获"
-
-#~ msgid "Hide"
-#~ msgstr "隐藏"
-
-#~ msgid "Show threshold view"
-#~ msgstr "显示阈值视图"
-
-#~ msgid "Show"
-#~ msgstr "显示"
-
#~ msgid "Camera was not found"
#~ msgstr "没找到摄像头"
diff --git a/setup.py b/setup.py
index 77fda74..c17ead5 100755
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,4 @@
#!/usr/bin/env python
-from sugar.activity import bundlebuilder
+from sugar3.activity import bundlebuilder
if __name__ == "__main__":
bundlebuilder.start()