Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2013-04-12 12:15:17 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2013-04-12 12:15:17 (GMT)
commit1d8e91935e60b83e71f9c9ac9cf0eff8f72eb624 (patch)
tree66d4a0bc666f02e7019ceafd13a9ea3d5a2d3065
parent5b0b4bf9e55eed42d8dd138d5b8cf438c27cd2dc (diff)
Pep8 fixes
Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
-rw-r--r--fontcombobox.py2
-rw-r--r--globos.py80
-rw-r--r--historietaactivity.py107
-rw-r--r--toolbar.py65
4 files changed, 131 insertions, 123 deletions
diff --git a/fontcombobox.py b/fontcombobox.py
index 9de5e34..a7515bd 100644
--- a/fontcombobox.py
+++ b/fontcombobox.py
@@ -19,7 +19,7 @@ from gi.repository import Gtk
from gi.repository import GObject
FONT_BLACKLIST = ['cmex10', 'cmmi10', 'cmr10', 'cmsy10', 'esint10', 'eufm10',
- 'msam10', 'msbm10', 'rsfs10', 'wasy10']
+ 'msam10', 'msbm10', 'rsfs10', 'wasy10']
class FontComboBox(Gtk.ComboBox):
diff --git a/globos.py b/globos.py
index 2c03ef8..9ede3ea 100644
--- a/globos.py
+++ b/globos.py
@@ -39,6 +39,7 @@ def _set_screen_dpi():
_set_screen_dpi()
+
class Globo:
def __init__(self, box, x, y, ancho=DEFAULT_GLOBE_WIDTH,
@@ -66,7 +67,7 @@ class Globo:
ancho_text, alto_text = self.calc_area_texto(self.ancho, self.alto)
#es el contenedor del texto
self.texto = CuadroTexto(self, ancho_text, alto_text,
- font_name)
+ font_name)
def set_selected(self, selected):
logging.error('Set selected %s', selected)
@@ -81,7 +82,7 @@ class Globo:
context.set_line_width(2)
context.scale(self.ancho / (self.radio * 1.0),
- self.alto / (self.radio * 1.0))
+ self.alto / (self.radio * 1.0))
x = self.x * self.radio / (self.ancho * 1.0)
y = self.y * self.radio / (self.alto * 1.0)
@@ -90,32 +91,32 @@ class Globo:
context.arc(x, y, self.radio, 100 / (180.0) * math.pi,
80 / (180.0) * math.pi)
- context.line_to( \
- x + self.punto[0] * self.radio / (self.ancho * 1.0),
- y + self.radio + \
- self.punto[1] * self.radio / (self.alto * 1.0))
+ context.line_to(
+ x + self.punto[0] * self.radio / (self.ancho * 1.0),
+ y + self.radio +
+ self.punto[1] * self.radio / (self.alto * 1.0))
elif self.direccion == DIR_DER:
context.arc(x, y, self.radio,
10 / 180.0 * math.pi, 350 / 180.0 * math.pi)
context.line_to(x + self.radio +
- self.punto[0] * self.radio / (self.ancho * 1.0), \
+ self.punto[0] * self.radio / (self.ancho * 1.0),
y + self.punto[1] * self.radio / (self.alto * 1.0))
elif self.direccion == DIR_IZQ:
context.arc(x, y, self.radio, 190 / 180.0 * math.pi,
530 / 180.0 * math.pi)
context.line_to(x - self.radio -
- self.punto[0] * self.radio / (self.ancho * 1.0), \
+ self.punto[0] * self.radio / (self.ancho * 1.0),
y + self.punto[1] * self.radio / (self.alto * 1.0))
else:
context.arc(x, y, self.radio,
280 / 180.0 * math.pi, 620 / 180.0 * math.pi)
- context.line_to( \
- x + self.punto[0] * self.radio / (self.ancho * 1.0),\
- y - self.radio -
- self.punto[1] * self.radio / (self.alto * 1.0))
+ context.line_to(
+ x + self.punto[0] * self.radio / (self.ancho * 1.0),
+ y - self.radio -
+ self.punto[1] * self.radio / (self.alto * 1.0))
context.close_path()
context.set_source_rgb(1, 1, 1)
@@ -144,7 +145,7 @@ class Globo:
# rectangulo alrededor del globo
context.set_source_rgb(1, 1, 1)
context.rectangle(self.x - self.ancho, self.y - self.alto,
- 2 * self.ancho, 2 * self.alto)
+ 2 * self.ancho, 2 * self.alto)
context.stroke_preserve()
context.set_source_rgb(0, 0, 0)
context.set_dash([2])
@@ -156,8 +157,8 @@ class Globo:
context.set_line_width(ANCHO_LINEAS_CONTROLES)
context.set_source_rgb(1, 1, 1)
context.rectangle(self.x - self.ancho - (SIZE_RESIZE_AREA / 2),
- self.y - self.alto - (SIZE_RESIZE_AREA / 2),
- SIZE_RESIZE_AREA, SIZE_RESIZE_AREA)
+ self.y - self.alto - (SIZE_RESIZE_AREA / 2),
+ SIZE_RESIZE_AREA, SIZE_RESIZE_AREA)
context.stroke_preserve()
context.set_source_rgb(0, 0, 0)
context.set_dash([2])
@@ -249,7 +250,7 @@ class Globo:
def is_selec_tam(self, x, y):
width = SIZE_RESIZE_AREA / 2
if self.x - self.ancho - width < x < self.x - self.ancho + width and \
- self.y - self.alto - width < y < self.y - self.alto + width:
+ self.y - self.alto - width < y < self.y - self.alto + width:
return True
else:
return False
@@ -258,7 +259,7 @@ class Globo:
width = SIZE_RESIZE_AREA / 2
x_circle, y_circle = self.get_circle_position()
return x_circle - width < x < x_circle + width and \
- y_circle - width < y < y_circle + width
+ y_circle - width < y < y_circle + width
def mover_punto(self, x, y, rect):
if self.direccion == DIR_ABAJO:
@@ -428,13 +429,13 @@ class Rectangulo(Globo):
ancho_text, alto_text = self.calc_area_texto(self.ancho, self.alto)
self.texto = CuadroTexto(self, ancho_text, alto_text,
- font_name)
+ font_name)
def imprimir(self, context):
#imprimimos el rectangulo
context.set_line_width(3)
context.rectangle(self.x - self.ancho, self.y - self.alto,
- 2 * self.ancho, 2 * self.alto)
+ 2 * self.ancho, 2 * self.alto)
context.set_source_rgb(1, 1, 1)
context.fill_preserve()
context.set_source_rgb(0, 0, 0)
@@ -452,16 +453,17 @@ class Rectangulo(Globo):
context.set_line_width(ANCHO_LINEAS_CONTROLES)
context.set_source_rgb(1, 1, 1)
context.rectangle(self.x - self.ancho - 2, self.y - self.alto - 2,
- 2 * self.ancho + 4, 2 * self.alto + 4)
+ 2 * self.ancho + 4, 2 * self.alto + 4)
context.stroke_preserve()
context.set_source_rgb(0, 0, 0)
context.set_dash([2])
context.stroke()
context.set_source_rgb(1, 1, 1)
- context.rectangle(self.x - self.ancho - (SIZE_RESIZE_AREA / 2),
- self.y - self.alto - (SIZE_RESIZE_AREA / 2),
- SIZE_RESIZE_AREA, SIZE_RESIZE_AREA)
+ context.rectangle(
+ self.x - self.ancho - (SIZE_RESIZE_AREA / 2),
+ self.y - self.alto - (SIZE_RESIZE_AREA / 2),
+ SIZE_RESIZE_AREA, SIZE_RESIZE_AREA)
context.stroke_preserve()
context.set_source_rgb(0, 0, 0)
context.set_dash([2])
@@ -511,7 +513,7 @@ class Nube(Globo):
ancho_text, alto_text = self.calc_area_texto(self.ancho, self.alto)
self.texto = CuadroTexto(self, ancho_text, alto_text,
- font_name)
+ font_name)
def imprimir(self, context):
@@ -605,16 +607,16 @@ class Nube(Globo):
def get_second_circle_position(self):
if self.direccion == DIR_ABAJO:
return self.x + self.punto[0] / 2, \
- self.y + self.alto + self.punto[1] / 2
+ self.y + self.alto + self.punto[1] / 2
elif self.direccion == DIR_DER:
return self.x + self.ancho + self.punto[0] / 2, \
- self.y + self.punto[1] / 2
+ self.y + self.punto[1] / 2
elif self.direccion == DIR_IZQ:
return self.x - self.ancho - self.punto[0] / 2, \
- self.y + self.punto[1] / 2
+ self.y + self.punto[1] / 2
else:
return self.x + self.punto[0] / 2, \
- self.y - self.alto - self.punto[1] / 2
+ self.y - self.alto - self.punto[1] / 2
class Grito(Globo):
@@ -640,18 +642,18 @@ class Grito(Globo):
ancho_text, alto_text = self.calc_area_texto(self.ancho, self.alto)
self.texto = CuadroTexto(self, ancho_text, alto_text,
- font_name)
+ font_name)
def imprimir(self, context):
context.save()
- self.draw_exclamation(context, self.x, self.y,
- self.ancho, self.alto, self.direccion, self.punto)
+ self.draw_exclamation(context, self.x, self.y, self.ancho, self.alto,
+ self.direccion, self.punto)
# se dibuja el correspondiente texto
self.texto.imprimir(context)
self.dibujar_controles(context)
- def draw_exclamation(self, cr, x_cen, y_cen,
- width, height, direction, punto):
+ def draw_exclamation(self, cr, x_cen, y_cen, width, height, direction,
+ punto):
points = []
steps = 24
@@ -756,7 +758,7 @@ class Imagen(Globo):
if self.direccion == DIR_ARRIBA:
context.rotate(3.14) # 180 degrees
context.translate(-self.icon_buffer.width,
- -self.icon_buffer.height)
+ -self.icon_buffer.height)
elif self.direccion == DIR_IZQ:
context.rotate(3.14 / 2.0) # 90 degrees
@@ -780,7 +782,7 @@ class Imagen(Globo):
context.set_line_width(ANCHO_LINEAS_CONTROLES)
context.set_source_rgb(1, 1, 1)
context.rectangle(self.x - self.ancho, self.y - self.alto,
- 2 * self.ancho, 2 * self.alto)
+ 2 * self.ancho, 2 * self.alto)
context.stroke_preserve()
context.set_source_rgb(0, 0, 0)
context.set_dash([2])
@@ -840,11 +842,11 @@ class CuadroTexto:
tbuffer.set_text(unicode(self.text))
self._box.textview.modify_font(Pango.FontDescription(
- self.font_description))
+ self.font_description))
self.set_dimension(self.ancho, self.alto)
self._size_alloc_id = self._box.textviewbox.connect(
- 'size_allocate', self._textview_size_allocate)
+ 'size_allocate', self._textview_size_allocate)
self.mover_a(self._globe.x, self._globe.y)
self._box.textviewbox.show_all()
self._box.textview.grab_focus()
@@ -873,7 +875,7 @@ class CuadroTexto:
pango_layout.set_alignment(Pango.Alignment.CENTER)
pango_layout.set_font_description(Pango.FontDescription(
- self.font_description))
+ self.font_description))
pango_layout.set_text(unicode(self.text), len(unicode(self.text)))
@@ -907,7 +909,7 @@ class CuadroTexto:
self.alto = alto
if self._in_edition:
self._box.textviewbox.set_size_request(self.ancho * 2,
- self.alto * 2)
+ self.alto * 2)
def _textview_size_allocate(self, widget, alloc):
if self._in_edition:
diff --git a/historietaactivity.py b/historietaactivity.py
index 1a389c3..c988e87 100644
--- a/historietaactivity.py
+++ b/historietaactivity.py
@@ -30,7 +30,6 @@ from sugar3.graphics.alert import Alert
from sugar3.graphics.icon import Icon
import dbus
import logging
-import inspect
class HistorietaActivity(activity.Activity):
@@ -117,8 +116,7 @@ class HistorietaActivity(activity.Activity):
activity_toolbar.insert(save_as_pdf, -1)
save_as_pdf.show()
- activity_button.page.title.connect("focus-in-event",
- self.on_title)
+ activity_button.page.title.connect("focus-in-event", self.on_title)
scrolled = Gtk.ScrolledWindow()
scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.ALWAYS)
@@ -148,7 +146,7 @@ class HistorietaActivity(activity.Activity):
# quiero que al ingresar al titulo se des seleccione el globo seleccionado
def on_title(self, widget, event):
print "Ingresando al titulo"
- if (self.page.get_active_box() != None):
+ if self.page.get_active_box() is not None:
box = self.page.get_active_box()
self.page.set_active_box(None)
box.glob_press = False
@@ -198,7 +196,7 @@ class HistorietaActivity(activity.Activity):
#logging.error("image_width %d image_height %d" %
# (image_width, image_height))
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32,
- image_width + 1, image_height + 1)
+ image_width + 1, image_height + 1)
ctx = cairo.Context(surface)
ctx.set_source_rgb(1, 1, 1)
@@ -216,7 +214,8 @@ class HistorietaActivity(activity.Activity):
column = (posi + 1) - (reng * 2)
#logging.error("reng %d column %d" % (reng, column))
ctx.rectangle(column * box.width, y_posi,
- (column + 1) * box.width, y_posi + box.height)
+ (column + 1) * box.width,
+ y_posi + box.height)
ctx.set_source_rgb(0, 0, 0)
ctx.stroke()
ctx.translate(column * box.width, y_posi)
@@ -233,7 +232,7 @@ class HistorietaActivity(activity.Activity):
posi = posi + 1
temp_file_name = os.path.join(self.get_activity_root(), 'instance',
- 'tmp-%i.png' % time.time())
+ 'tmp-%i.png' % time.time())
surface.write_to_png(temp_file_name)
#logging.error("temp file name %s" % (temp_file_name))
@@ -244,7 +243,7 @@ class HistorietaActivity(activity.Activity):
self.dl_jobject.metadata['keep'] = '0'
self.dl_jobject.metadata['buddies'] = ''
self.dl_jobject.metadata['icon-color'] = \
- profile.get_color().to_string()
+ profile.get_color().to_string()
self.dl_jobject.metadata['mime_type'] = 'image/png'
self.dl_jobject.metadata['title'] = \
@@ -259,7 +258,7 @@ class HistorietaActivity(activity.Activity):
datastore.write(self.dl_jobject, transfer_ownership=True)
self._object_id = self.dl_jobject.object_id
self._show_journal_alert(_('Success'),
- _('A image was created in the Journal'))
+ _('A image was created in the Journal'))
def _save_as_pdf(self, widget):
if not len(self.page.boxs) > 1:
@@ -270,7 +269,7 @@ class HistorietaActivity(activity.Activity):
file_obj = open(file_name, 'w')
surface = cairo.PDFSurface(file_obj, self.page.boxs[1].width,
- self.page.boxs[1].height)
+ self.page.boxs[1].height)
context = cairo.Context(surface)
for box in self.page.boxs[1:]:
@@ -282,7 +281,7 @@ class HistorietaActivity(activity.Activity):
jobject = datastore.create()
jobject.metadata['icon-color'] = \
- profile.get_color().to_string()
+ profile.get_color().to_string()
jobject.metadata['mime_type'] = 'application/pdf'
jobject.metadata['title'] = \
@@ -296,16 +295,17 @@ class HistorietaActivity(activity.Activity):
self._object_id = jobject.object_id
self._show_journal_alert(_('Success'),
- _('A PDF was created in the Journal'))
+ _('A PDF was created in the Journal'))
def _show_journal_alert(self, title, msg):
_stop_alert = Alert()
_stop_alert.props.title = title
_stop_alert.props.msg = msg
_stop_alert.add_button(Gtk.ResponseType.APPLY,
- _('Show in Journal'), Icon(icon_name='zoom-activity'))
+ _('Show in Journal'),
+ Icon(icon_name='zoom-activity'))
_stop_alert.add_button(Gtk.ResponseType.OK, _('Ok'),
- Icon(icon_name='dialog-ok'))
+ Icon(icon_name='dialog-ok'))
# Remove other alerts
for alert in self._alerts:
self.remove_alert(alert)
@@ -331,20 +331,19 @@ class HistorietaActivity(activity.Activity):
scale_y = preview_height / float(height)
scale = min(scale_x, scale_y)
- pixbuf2 = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB,
- pixbuf.get_has_alpha(),
- pixbuf.get_bits_per_sample(),
- preview_width, preview_height)
+ pixbuf2 = GdkPixbuf.Pixbuf.new(
+ GdkPixbuf.Colorspace.RGB, pixbuf.get_has_alpha(),
+ pixbuf.get_bits_per_sample(), preview_width, preview_height)
pixbuf2.fill(style.COLOR_WHITE.get_int())
margin_x = int((preview_width - (width * scale)) / 2)
margin_y = int((preview_height - (height * scale)) / 2)
pixbuf.scale(pixbuf2, margin_x, margin_y,
- preview_width - (margin_x * 2),
- preview_height - (margin_y * 2),
- margin_x, margin_y, scale, scale,
- GdkPixbuf.InterpType.BILINEAR)
+ preview_width - (margin_x * 2),
+ preview_height - (margin_y * 2),
+ margin_x, margin_y, scale, scale,
+ GdkPixbuf.InterpType.BILINEAR)
succes, preview_data = pixbuf2.save_to_bufferv('png', [], [])
return dbus.ByteArray(preview_data)
@@ -358,8 +357,8 @@ class HistorietaActivity(activity.Activity):
for box in self.page.boxs:
box.set_globo_activo(None)
- self._key_press_signal_id = self.connect('key_press_event',
- self._slideview.key_press_cb)
+ self._key_press_signal_id = self.connect(
+ 'key_press_event', self._slideview.key_press_cb)
else:
self._notebook.set_current_page(0)
if self._key_press_signal_id is not None:
@@ -390,7 +389,7 @@ class Page(Gtk.VBox):
self.selected_font_name = globos.DEFAULT_FONT
logging.error('SCREEN WIDTH %d DEF_SPACING %d', SCREEN_WIDTH,
- DEF_SPACING)
+ DEF_SPACING)
# Agrego cuadro titulo
self.title_box = ComicBox(self, None, 0)
@@ -424,12 +423,12 @@ class Page(Gtk.VBox):
if self._active_box == box:
return
box_anterior = None
- if (self._active_box != None):
+ if self._active_box is not None:
box_anterior = self._active_box
self._active_box = box
- if (box != None):
+ if box is not None:
box.redraw()
- if (box_anterior != None):
+ if box_anterior is not None:
for g in box_anterior.globos:
g.set_selected(False)
box_anterior.redraw()
@@ -439,8 +438,8 @@ class Page(Gtk.VBox):
def get_globo_activo(self):
box = self.get_active_box()
- if box != None:
- if (box.get_globo_activo() != None):
+ if box is not None:
+ if box.get_globo_activo() is not None:
return box.get_globo_activo()
return None
@@ -453,7 +452,7 @@ class ComicBox(Gtk.EventBox):
self._page = page
self.modify_bg(Gtk.StateType.NORMAL,
- style.COLOR_WHITE.get_gdk_color())
+ style.COLOR_WHITE.get_gdk_color())
self.fixed = Gtk.Fixed()
self.add(self.fixed)
@@ -465,7 +464,7 @@ class ComicBox(Gtk.EventBox):
self.textview.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
self.textview.set_justification(Gtk.Justification.CENTER)
self.textview.modify_bg(Gtk.StateType.NORMAL,
- style.COLOR_WHITE.get_gdk_color())
+ style.COLOR_WHITE.get_gdk_color())
self._textview_x = 0
self._textview_y = 0
@@ -473,10 +472,11 @@ class ComicBox(Gtk.EventBox):
self.textviewbox.pack_start(self.textview, True, False, 0)
#se agregan los eventos de pulsacion y movimiento del raton
- self._drawingarea.add_events(Gdk.EventMask.POINTER_MOTION_MASK |
- Gdk.EventMask.BUTTON_PRESS_MASK |
- Gdk.EventMask.BUTTON_RELEASE_MASK |
- Gdk.EventMask.BUTTON_MOTION_MASK)
+ self._drawingarea.add_events(
+ Gdk.EventMask.POINTER_MOTION_MASK |
+ Gdk.EventMask.BUTTON_PRESS_MASK |
+ Gdk.EventMask.BUTTON_RELEASE_MASK |
+ Gdk.EventMask.BUTTON_MOTION_MASK)
#self.globos es una lista que contiene los globos de ese cuadro
self.globos = []
@@ -533,8 +533,9 @@ class ComicBox(Gtk.EventBox):
def get_globo_activo(self):
return self._globo_activo
- def add_globo(self, xpos, ypos, gmodo="normal", \
- gdireccion=globos.DIR_ABAJO, font_name=globos.DEFAULT_FONT):
+ def add_globo(self, xpos, ypos, gmodo="normal",
+ gdireccion=globos.DIR_ABAJO,
+ font_name=globos.DEFAULT_FONT):
#agrega un globo al cuadro
globo = globos.Globo(self, x=xpos, y=ypos, modo=gmodo,
direccion=gdireccion, font_name=font_name)
@@ -545,7 +546,7 @@ class ComicBox(Gtk.EventBox):
def add_rectangulo(self, xpos, ypos, font_name=globos.DEFAULT_FONT):
#agrega un cuadro de texto al cuadro
self.globos.append(globos.Rectangulo(self, x=xpos, y=ypos,
- font_name=font_name))
+ font_name=font_name))
self.redraw()
def add_nube(self, xpos, ypos, font_name=globos.DEFAULT_FONT):
@@ -589,9 +590,9 @@ class ComicBox(Gtk.EventBox):
self.image_height = 0
- instance_path = os.path.join(activity.get_activity_root(), \
- 'instance')
- if (self.image == None) and (self.image_name != ''):
+ instance_path = os.path.join(activity.get_activity_root(),
+ 'instance')
+ if self.image is None and (self.image_name != ''):
# si la imagen no tiene el path viene del archivo
# de historieta ya grabado,
# si viene con path, es una imagen que se tomo del journal
@@ -605,13 +606,14 @@ class ComicBox(Gtk.EventBox):
scale = (self.width) / (1.0 * width_pxb)
self.image_height = int(scale * height_pxb)
self.image = ctx.get_target().create_similar(
- cairo.CONTENT_COLOR_ALPHA, self.width, self.image_height)
+ cairo.CONTENT_COLOR_ALPHA, self.width, self.image_height)
if (scale != 1):
# falta tener en cuenta el caso de una imagen
# que venga del journal y tenga el tamanio justo,
# es decir con scale = 1
- pixb_scaled = pixbuf.scale_simple(int(self.width),
+ pixb_scaled = pixbuf.scale_simple(
+ int(self.width),
int(self.image_height), GdkPixbuf.InterpType.BILINEAR)
ct = cairo.Context(self.image)
Gdk.cairo_set_source_pixbuf(ct, pixb_scaled, 0, 0)
@@ -621,7 +623,7 @@ class ComicBox(Gtk.EventBox):
# print instance_path
image_file_name = 'image' + str(self.posi) + '.png'
self.image.write_to_png(os.path.join(instance_path,
- image_file_name))
+ image_file_name))
# grabamos el nombre de la imagen sin el path
self.image_name = image_file_name
else:
@@ -665,15 +667,16 @@ class ComicBox(Gtk.EventBox):
self._page.set_active_box(self)
#Verifica si al pulsar el mouse se hizo sobre algun globo
- if self._globo_activo != None:
+ if self._globo_activo is not None:
if self._globo_activo.is_selec_tam(event.x, event.y) or \
- (self._globo_activo.get_cursor_type(event.x, event.y) != None):
+ self._globo_activo.get_cursor_type(event.x, event.y) \
+ is not None:
self.is_dimension = True
elif self._globo_activo.is_selec_punto(event.x, event.y):
self.is_punto = True
if (not self.is_dimension) and not (self.is_punto):
- if self._globo_activo != None:
+ if self._globo_activo is not None:
#self.glob_press.is_selec(event.x,event.y)
self._globo_activo.set_selected(False)
self.glob_press = False
@@ -696,7 +699,7 @@ class ComicBox(Gtk.EventBox):
self.is_punto = False
def mouse_move(self, widget, event):
- if self._globo_activo != None:
+ if self._globo_activo is not None:
cursor_type = self._globo_activo.get_cursor_type(event.x, event.y)
cursor = None
if cursor_type is not None:
@@ -706,15 +709,15 @@ class ComicBox(Gtk.EventBox):
def moving(self, widget, event):
if self.is_dimension:
self._globo_activo.set_dimension(event.x, event.y,
- self.get_allocation())
+ self.get_allocation())
self.redraw()
elif self.is_punto:
self._globo_activo.mover_punto(event.x, event.y,
- self.get_allocation())
+ self.get_allocation())
self.redraw()
elif self.glob_press:
self._globo_activo.mover_a(event.x, event.y,
- self.get_allocation())
+ self.get_allocation())
self.redraw()
def move_textview(self, x, y):
diff --git a/toolbar.py b/toolbar.py
index 94f74f4..f6b77c7 100644
--- a/toolbar.py
+++ b/toolbar.py
@@ -22,7 +22,7 @@ import logging
import os
import time
# Gtk3
-from gi.repository import Gtk, Gdk, GdkPixbuf
+from gi.repository import Gtk, Gdk
from sugar3.graphics.icon import Icon
from sugar3.graphics.toolbutton import ToolButton
from sugar3.graphics.toggletoolbutton import ToggleToolButton
@@ -53,7 +53,7 @@ class TextButtonColor(ColorToolButton):
def set_text_color(self, color):
globo_activo = self._page.get_globo_activo()
- if (globo_activo != None):
+ if globo_activo is not None:
texto = globo_activo.texto
texto.color = (color.red, color.green, color.blue)
self._page.get_active_box().redraw()
@@ -76,9 +76,10 @@ class GlobesManager():
self.add_photo.set_tooltip(_('Add Photo'))
toolbar.insert(self.add_photo, -1)
- self._globes = {'globe': _('Globe'), 'think': _('Think'),
- 'whisper': _('Whisper'),
- 'exclamation': _('Exclamation'), 'box': _('Box')}
+ self._globes = {
+ 'globe': _('Globe'), 'think': _('Think'),
+ 'whisper': _('Whisper'), 'exclamation': _('Exclamation'),
+ 'box': _('Box')}
self._globes_menu = RadioMenuButton(icon_name='globe')
self._globes_menu.props.tooltip = _('Add a globe')
@@ -93,8 +94,9 @@ class GlobesManager():
# lineas de movimiento
# Agregar aqui el nombre de archivo de una linea de moviemiento
- self._lines = {'curves': _('Curves'), 'straight': _('Straight'),
- 'highlight': _('Highlight'), 'idea': _('Idea')}
+ self._lines = {
+ 'curves': _('Curves'), 'straight': _('Straight'),
+ 'highlight': _('Highlight'), 'idea': _('Idea')}
self._lines_menu = RadioMenuButton(icon_name='curves')
self._lines_menu.props.tooltip = _('Choose a movement line')
@@ -137,24 +139,24 @@ class GlobesManager():
selected_font_name = self._activity.page.selected_font_name
if globe == 'globe':
- self._page.get_active_box().add_globo(60, 60,
- font_name=selected_font_name)
+ self._page.get_active_box().add_globo(
+ 60, 60, font_name=selected_font_name)
if globe == 'think':
- self._page.get_active_box().add_nube(60, 60,
- font_name=selected_font_name)
+ self._page.get_active_box().add_nube(
+ 60, 60, font_name=selected_font_name)
if globe == 'whisper':
- self._page.get_active_box().add_globo(60, 60, gmodo="despacio",
- font_name=selected_font_name)
+ self._page.get_active_box().add_globo(
+ 60, 60, gmodo="despacio", font_name=selected_font_name)
if globe == 'exclamation':
- self._page.get_active_box().add_grito(60, 60,
- font_name=selected_font_name)
+ self._page.get_active_box().add_grito(
+ 60, 60, font_name=selected_font_name)
if globe == 'box':
- self._page.get_active_box().add_rectangulo(60, 60,
- font_name=selected_font_name)
+ self._page.get_active_box().add_rectangulo(
+ 60, 60, font_name=selected_font_name)
def __add_photo_clicked_cb(self, button):
self.add_image()
@@ -163,7 +165,7 @@ class GlobesManager():
print "girando"
#veo cual es el globo seleccionado y o giro
box = self._page.get_active_box()
- if (box.get_globo_activo() != None):
+ if box.get_globo_activo() is not None:
print "globo activo",
globe = box.get_globo_activo()
if globe.girar():
@@ -172,7 +174,7 @@ class GlobesManager():
def borrar(self, boton):
print "borrando"
box = self._page.get_active_box()
- if (box.get_globo_activo() != None):
+ if box.get_globo_activo() is not None:
print "borrando globo"
# Do no remove the title globe
if box.get_globo_activo() == box.title_globe:
@@ -207,13 +209,14 @@ class GlobesManager():
result = chooser.run()
if result == Gtk.ResponseType.ACCEPT:
logging.error('ObjectChooser: %r' %
- chooser.get_selected_object())
+ chooser.get_selected_object())
jobject = chooser.get_selected_object()
if jobject and jobject.file_path:
- logging.error("imagen seleccionada: %s", jobject.file_path)
+ logging.error("imagen seleccionada: %s",
+ jobject.file_path)
tempfile_name = \
os.path.join(self._activity.get_activity_root(),
- 'instance', 'tmp%i' % time.time())
+ 'instance', 'tmp%i' % time.time())
os.link(jobject.file_path, tempfile_name)
logging.error("tempfile_name: %s", tempfile_name)
self._page.add_box_from_journal_image(tempfile_name)
@@ -263,16 +266,16 @@ class TextToolbar(Gtk.Toolbar):
# tamanio
self._font_size_icon = Icon(icon_name="format-text-size",
- icon_size=Gtk.IconSize.LARGE_TOOLBAR)
+ icon_size=Gtk.IconSize.LARGE_TOOLBAR)
tool_item = Gtk.ToolItem()
tool_item.add(self._font_size_icon)
self.insert(tool_item, -1)
self._font_size_combo = ComboBox()
- self._font_sizes = ['8', '10', '12', '14', '16', '20', '22', '24', \
- '26', '28', '36', '48', '72']
- self._font_size_changed_id = self._font_size_combo.connect('changed',
- self._font_size_changed_cb)
+ self._font_sizes = ['8', '10', '12', '14', '16', '20', '22', '24',
+ '26', '28', '36', '48', '72']
+ self._font_size_changed_id = self._font_size_combo.connect(
+ 'changed', self._font_size_changed_cb)
for i, s in enumerate(self._font_sizes):
self._font_size_combo.append_item(i, s, None)
if s == '10':
@@ -283,8 +286,8 @@ class TextToolbar(Gtk.Toolbar):
# font
self._font_combo = FontComboBox()
self._font_combo.set_font_name(globos.DEFAULT_FONT)
- self._fonts_changed_id = self._font_combo.connect('changed',
- self._font_changed_cb)
+ self._fonts_changed_id = self._font_combo.connect(
+ 'changed', self._font_changed_cb)
tool_item = ToolComboBox(self._font_combo)
self.insert(tool_item, -1)
@@ -357,7 +360,7 @@ class TextToolbar(Gtk.Toolbar):
self.setToggleButtonState(self._bold, globeText.bold, self._bold_id)
# seteo italic
self.setToggleButtonState(self._italic, globeText.italic,
- self._italic_id)
+ self._italic_id)
# color
self._text_color.set_color(Gdk.Color(*globeText.color))
# font size
@@ -366,7 +369,7 @@ class TextToolbar(Gtk.Toolbar):
self._font_size_combo.handler_block(self._font_size_changed_id)
self._font_size_combo.set_active(i)
self._font_size_combo.handler_unblock(
- self._font_size_changed_id)
+ self._font_size_changed_id)
break
# font seleccionada