Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2012-02-11 14:28:09 (GMT)
committer Walter Bender <walter.bender@gmail.com>2012-02-11 14:28:09 (GMT)
commit16b7781aefa6c8c2f826ef90c433ac0bff0ff0bc (patch)
treebc686ee155b103630588eff2f95424983a42e16f
parent81acff08c7fcb54f84c6c3868d8e5cb90f327ecd (diff)
final? fix in refactoring of calc_dpi, some pep8 cleanups
-rw-r--r--RulerActivity.py2
-rw-r--r--show_rulers.py12
-rw-r--r--util.py9
3 files changed, 11 insertions, 12 deletions
diff --git a/RulerActivity.py b/RulerActivity.py
index b3b012b..5396726 100644
--- a/RulerActivity.py
+++ b/RulerActivity.py
@@ -55,7 +55,7 @@ _logger = logging.getLogger("ruler-activity")
from gettext import gettext as _
-from util import get_hardware, calc_dpi
+from util import calc_dpi
import show_rulers
import show_grids
import show_checkers
diff --git a/show_rulers.py b/show_rulers.py
index 8d32132..a4d5857 100644
--- a/show_rulers.py
+++ b/show_rulers.py
@@ -39,9 +39,10 @@ class ScreenOfRulers():
self.draw_ruler_pair(c, dpi, mm(dpi, 20))
- # only calculate offsets if on an OLPC XO-1, 1.5, 1.75
- if self.hw[0:2] == 'xo' and dpi == 200: # Not applicable to XO 3.0
- offset_of_xo_side_from_screen = mm(dpi, -38.5) #XXX needs checking
+ # Only calculate offsets if on an OLPC XO-1, 1.5, 1.75
+ # Not applicable to XO 3.0
+ if self.hw[0:2] == 'xo' and dpi in [200, 201]:
+ offset_of_xo_side_from_screen = mm(dpi, -38.5)
c.move_to(offset_of_xo_side_from_screen, mm(dpi, 65))
self.draw_cm_ruler(c, dpi, 180)
@@ -51,7 +52,7 @@ class ScreenOfRulers():
self.font, mm(dpi, 4))
c.restore()
- offset_of_molding_from_screen = mm(dpi, -0.4) #XXX +- 0.2 ??
+ offset_of_molding_from_screen = mm(dpi, -0.4)
c.move_to(offset_of_molding_from_screen, mm(dpi, 95))
self.draw_cm_ruler(c, dpi, 150)
@@ -61,7 +62,6 @@ class ScreenOfRulers():
self.draw_cm_ruler(c, dpi, int(nw / 10 * 10))
def draw_ruler_pair(self, c, dpi, y):
-
c.move_to(mm(dpi, 10), y)
self.connect_rulers(c, dpi)
@@ -90,7 +90,6 @@ class ScreenOfRulers():
c.restore()
def draw_cm_ruler(self, c, dpi, width=130):
-
c.save()
c.set_line_cap(cairo.LINE_CAP_SQUARE)
c.translate(*c.get_current_point())
@@ -114,7 +113,6 @@ class ScreenOfRulers():
c.restore()
def draw_mm_ruler(self, c, dpi, width=130):
-
c.save()
c.set_line_cap(cairo.LINE_CAP_SQUARE)
c.translate(*c.get_current_point())
diff --git a/util.py b/util.py
index 4f9e76f..ee6e509 100644
--- a/util.py
+++ b/util.py
@@ -84,13 +84,14 @@ def calc_dpi():
(status, output) = commands.getstatusoutput('/usr/bin/xdpyinfo')
if status == 0:
strings = output[find(output, 'dimensions:'):].split()
- w = int(strings[1].split('x')[0]) # e.g., 1280x800
+ w = int(strings[1].split('x')[0]) # e.g., 1280x800
mm = int(strings[3][1:].split('x')[0]) # e.g., (339x212)
return int((w * 25.4 / mm) + 0.5), True
else:
# just in case the above fails
return 96, False
+
#
# Cairo-related utilities
#
@@ -113,8 +114,8 @@ def write(c, text, name, size, centered=False, at_top=False):
font.set_size(int(round(size * pango.SCALE)))
lo = pc.create_layout()
lo.set_font_description(font)
- lo.set_text("X")
- extent = [x/pango.SCALE for x in lo.get_extents()[1]]
+ lo.set_text('X')
+ extent = [x / pango.SCALE for x in lo.get_extents()[1]]
ex, ey = extent[2], extent[3]
baseline_offset = -ey
if not at_top:
@@ -123,7 +124,7 @@ def write(c, text, name, size, centered=False, at_top=False):
lo = pc.create_layout()
lo.set_font_description(font)
lo.set_text(text)
- extent =[x/pango.SCALE for x in lo.get_extents()[1]]
+ extent = [x / pango.SCALE for x in lo.get_extents()[1]]
ex, ey = extent[2], extent[3]
if centered:
c.rel_move_to(-ex / 2, 0)