Skip to content

Commit

Permalink
[#95] Consistent box outline width
Browse files Browse the repository at this point in the history
  • Loading branch information
quicklizard99 committed Dec 8, 2016
1 parent 815ae99 commit e3ef719
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion inselect/gui/views/boxes/box_item.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

from itertools import chain

from qtpy.QtCore import Qt, QRect, QRectF
Expand All @@ -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 |
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit e3ef719

Please sign in to comment.