From e3ef7191aad6e4e151708e6e7c5514a54e970b38 Mon Sep 17 00:00:00 2001 From: Lawrence Hudson Date: Thu, 8 Dec 2016 20:04:12 +0000 Subject: [PATCH] [#95] Consistent box outline width --- inselect/gui/views/boxes/box_item.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/inselect/gui/views/boxes/box_item.py b/inselect/gui/views/boxes/box_item.py index 4f42faa..24aa52d 100644 --- a/inselect/gui/views/boxes/box_item.py +++ b/inselect/gui/views/boxes/box_item.py @@ -1,3 +1,5 @@ +import sys + from itertools import chain from qtpy.QtCore import Qt, QRect, QRectF @@ -16,6 +18,12 @@ class BoxItem(QGraphicsRectItem): # Might be some relevant stuff here: # http://stackoverflow.com/questions/10590881/events-and-signals-in-qts-qgraphicsitem-how-is-this-supposed-to-work + # The width of the box (in pixels) drawn around the box. + # A width of 1 on Mac OS X is too thin. 1.5 on Windows causes artefacts - + # the top and left edges might appear thicker than the bottom and right + # edges. + BOX_WIDTH = 1.5 if 'darwin' == sys.platform else 1 + def __init__(self, x, y, w, h, isvalid, parent=None): super(BoxItem, self).__init__(x, y, w, h, parent) self.setFlags(QGraphicsItem.ItemIsFocusable | @@ -59,7 +67,7 @@ def paint(self, painter, option, widget=None): # Cosmetic pens "...draw strokes that have a constant width # regardless of any transformations applied to the QPainter they are # used with." - pen = QPen(outline_colour, 1.5, Qt.SolidLine) + pen = QPen(outline_colour, self.BOX_WIDTH, Qt.SolidLine) pen.setCosmetic(True) painter.setPen(pen)