From ff96838b081b20f7ed4277f7074ecf76a860be28 Mon Sep 17 00:00:00 2001 From: Agustin Zubiaga Date: Fri, 04 May 2012 00:21:44 +0000 Subject: PEP8 fixes --- diff --git a/dialogs.py b/dialogs.py index 15b6668..68d7e51 100644 --- a/dialogs.py +++ b/dialogs.py @@ -17,18 +17,14 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA from gettext import gettext as _ -import os -import time import gobject import gtk -import webkit from sugar.graphics import style from sugar.graphics.toolbutton import ToolButton from sugar.graphics.icon import Icon -from gettext import gettext as _ class _DialogWindow(gtk.Window): @@ -38,7 +34,6 @@ class _DialogWindow(gtk.Window): super(_DialogWindow, self).__init__() self.set_border_width(style.LINE_WIDTH) - offset = style.GRID_CELL_SIZE width = gtk.gdk.screen_width() - style.GRID_CELL_SIZE * 2 height = gtk.gdk.screen_height() - style.GRID_CELL_SIZE * 2 self.set_size_request(width, height) @@ -137,7 +132,7 @@ class ScoreDialog(_DialogWindow): time_cell = gtk.CellRendererText() time_column = gtk.TreeViewColumn(_("Score")) - + time_column.pack_start(time_cell) time_column.set_attributes(time_cell, text=0) @@ -148,5 +143,5 @@ class ScoreDialog(_DialogWindow): for i in scores: score, date = i.split(",") liststore.append([score, date]) - + scrollwin.add_with_viewport(treeview) diff --git a/terronesweeper.py b/terronesweeper.py index 0e00b08..2099812 100644 --- a/terronesweeper.py +++ b/terronesweeper.py @@ -27,7 +27,6 @@ import time import random import json -import gettext from gettext import gettext as _ import gtk @@ -295,7 +294,7 @@ class TerronesTable(gtk.Table): if bb[0].flag: image = gtk.Image() pixbuf = gtk.gdk.pixbuf_new_from_file_at_size( - "icons/terron-flag-ok.svg" if bb[1] else "icons/terron-flag-bad.svg", + "icons/terron-flag-ok.svg" if bb[1] else "icons/terron-flag-bad.svg", bb[0].get_allocation()[-2] - 10, bb[0].get_allocation()[-1] - 10) image.set_from_pixbuf(pixbuf) @@ -415,7 +414,7 @@ class TerronesWeeper(activity.Activity): self.label.set_text(self.label.get_text()) # Save score: - self.score.append("%s, %s" % (self.time, + self.score.append("%s, %s" % (self.time, time.strftime("%d/%m/%y - %H:%M"))) self.alerting = self._alert_user(_("CONGRATULATIONS"), @@ -533,4 +532,3 @@ class TerronesWeeper(activity.Activity): json.dump(tuple(self.score), jfile) finally: jfile.close() - diff --git a/timer.py b/timer.py index 95c2d6b..c631c72 100644 --- a/timer.py +++ b/timer.py @@ -2,82 +2,85 @@ # -*- coding: UTF-8 -*- # # TerronesWeeper Activity - timer.py -# -# Copyright 2011 Daniel Francis , Agustín Zubiaga -# +# +# Copyright 2011 Daniel Francis , +# Agustín Zubiaga +# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. -# -# +# +# import gobject + class Timer(gobject.GObject): - + __gsignals__ = {"time-changed": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, - (gobject.TYPE_STRING,)),} - + (gobject.TYPE_STRING,))} + def __init__(self): - + gobject.GObject.__init__(self) - + self.time = "00:00:00" self.seconds = 0 self.minutes = 0 - + self.timeout = None - + def start(self): self.timeout = gobject.timeout_add(1000, self.update_time) - + def stop(self): if self.timeout: gobject.source_remove(self.timeout) - + def update_time(self): self.seconds += 1 - + if int(str(float(self.seconds / 60)).split(".")[-1]) > 0: self.minutes += 1 self.seconds = 0 - + else: - if self.seconds / 60 >= 1: + if self.seconds / 60 >= 1: self.minutes += 1 self.seconds = 0 - + minutes = str(self.minutes) seconds = str(self.seconds) - + if self.minutes < 10: minutes = "0" + str(self.minutes) - + if self.seconds < 10: seconds = "0" + str(self.seconds) - + self.time = "%s:%s" % (minutes, seconds) - + self.emit("time-changed", self.time) - + return True - + def reset_timer(self, start=False): self.stop() self.minutes = 0 self.seconds = 0 self.time = "00:00:00" - - if start: self.start() + + if start: + self.start() -- cgit v0.9.1