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-12-25 19:42:54 (GMT)
committer Alan Aguiar <alanjas@hotmail.com>2013-12-25 19:42:54 (GMT)
commit56d4b9766964c12cfa56bfcb96207b110e9442a9 (patch)
treedad7099d1973bd32d939c701020533db0b26d880
parente8a66fcf4d85d976e2f82829564188e389681f52 (diff)
add save/export to py function
-rwxr-xr-xactivity.py20
-rwxr-xr-xconozco.py11
-rw-r--r--points_list.py4
-rw-r--r--save_util.py29
4 files changed, 52 insertions, 12 deletions
diff --git a/activity.py b/activity.py
index 0f94306..a1e7e26 100755
--- a/activity.py
+++ b/activity.py
@@ -17,6 +17,7 @@ from gettext import gettext as _
import sugargame.canvas
import conozco
from points_list import Data
+from save_util import save
class Activity(activity.Activity):
@@ -47,10 +48,10 @@ class Activity(activity.Activity):
activity_button.show()
# new pic button
- new_game = ToolButton('new-pic')
- new_game.connect('clicked', self._new_picture)
- new_game.set_tooltip(_('New picture'))
- toolbar_box.toolbar.insert(new_game, -1)
+ new_pic = ToolButton('new-pic')
+ new_pic.connect('clicked', self._new_picture)
+ new_pic.set_tooltip(_('New picture'))
+ toolbar_box.toolbar.insert(new_pic, -1)
# add / remove point buttons
add_point = ToolButton("row-insert")
@@ -63,6 +64,12 @@ class Activity(activity.Activity):
rem_point.set_tooltip(_("Remove the selected point"))
toolbar_box.toolbar.insert(rem_point, -1)
+ # save list button
+ save = ToolButton('filesave')
+ save.connect('clicked', self._save)
+ save.set_tooltip(_('New picture'))
+ toolbar_box.toolbar.insert(save, -1)
+
# separator and stop button
separator = gtk.SeparatorToolItem()
separator.props.draw = False
@@ -107,7 +114,9 @@ class Activity(activity.Activity):
self._pygamecanvas.grab_focus()
self._pygamecanvas.run_pygame(self.actividad.principal)
-
+ def _save(self, widget):
+ l = self.labels_and_values.get_info()
+ save(l)
def _new_picture(self, widget):
try:
@@ -124,7 +133,6 @@ class Activity(activity.Activity):
self._image = pygame.image.load(f)
self.actividad.set_background(self._image)
-
def _add_point(self, widget, label="", value="City", dx='0', dy='-14'):
pos = self.labels_and_values.add_value(label, value, dx, dy)
diff --git a/conozco.py b/conozco.py
index 30f6124..75ac5b8 100755
--- a/conozco.py
+++ b/conozco.py
@@ -483,11 +483,12 @@ class Conozco():
self.pantalla.blit(self.fondo, (shift_x, shift_y))
for p in l:
name = p[0]
- pos = p[1]
- dx = int(p[2] * scale)
- dy = int(p[3] * scale)
- pos_n = (pos[0] + dx, pos[1] + dy)
- pos_c = (pos[0] - 8, pos[1] - 8)
+ x = p[1]
+ y = p[2]
+ dx = int(p[3] * scale)
+ dy = int(p[4] * scale)
+ pos_n = (x + dx, y + dy)
+ pos_c = (x - 8, y - 8)
self.showName(name, pos_n, self.fuente9)
self.pantalla.blit(self.simboloCiudad, pos_c)
diff --git a/points_list.py b/points_list.py
index 53e05da..b14574a 100644
--- a/points_list.py
+++ b/points_list.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
import gtk
import gobject
@@ -120,7 +122,7 @@ class Data(gtk.TreeView):
dx = int(row[2])
dy = int(row[3])
if status:
- l.append((name, pos, dx, dy))
+ l.append((name, pos[0], pos[1], dx, dy))
return l
def _validate_pos(self, pos):
diff --git a/save_util.py b/save_util.py
new file mode 100644
index 0000000..656c130
--- /dev/null
+++ b/save_util.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from gettext import gettext as _
+
+
+def save(l):
+ f = open('salida.py', 'w')
+ # encabezados
+ f.write("# -*- coding: utf-8 -*-\n")
+ f.write("\n")
+ f.write("from gettext import gettext as _\n")
+ f.write("\n")
+ f.write("CITIES = [\n")
+ first = True
+ for r in l:
+ # (_('Bahía Blanca'), 386, 451, 2, -10, -14),
+ if first:
+ first = False
+ else:
+ f.write(',\n')
+
+ lin = " (_('" + str(r[0]) + "'), " + str(r[1]) + ", " + str(r[2])
+ lin = lin + ", 2, " + str(r[3]) + ", " + str(r[4]) + ")"
+
+ f.write(lin)
+ f.write('\n')
+ f.write(']')
+ f.close()