diff --git a/g13gui/bitwidgets/rectangle.py b/g13gui/bitwidgets/rectangle.py index 2d7b15e..19f5d19 100644 --- a/g13gui/bitwidgets/rectangle.py +++ b/g13gui/bitwidgets/rectangle.py @@ -2,11 +2,20 @@ from g13gui.bitwidgets.widget import Widget class Rectangle(Widget): - def __init__(self, x, y, w, h, fill=True): + def __init__(self, x, y, w, h, fill=True, outline=0): Widget.__init__(self) self.position = (x, y) self.bounds = (w, h) self.fill = fill + self._outline = outline + + @property + def outline(self): + return self._outline + + @outline.setter + def outline(self, value): + self.setAttribute('outline', value) def draw(self, ctx): if self._visible: @@ -14,4 +23,5 @@ class Rectangle(Widget): self._position[0] + self._bounds[0], self._position[1] + self._bounds[1]) ctx.rectangle(points, - fill=self._fill) + fill=self._fill, + outline=self._outline) diff --git a/g13gui/bitwidgets/rectangle_tests.py b/g13gui/bitwidgets/rectangle_tests.py index 7cac429..b6a4437 100644 --- a/g13gui/bitwidgets/rectangle_tests.py +++ b/g13gui/bitwidgets/rectangle_tests.py @@ -25,7 +25,16 @@ class RectangleTests(unittest.TestCase): def testRect(self): self.dd.name = 'testRect' ctx = self.display.getContext() - rect = Rectangle(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT - 1, fill=True) + rect = Rectangle(0, 0, DISPLAY_WIDTH - 1, DISPLAY_HEIGHT - 1) + rect.show() + rect.draw(ctx) + + self.display.commit() + + def testRectUnfilled(self): + self.dd.name = 'testRectUnfilled' + ctx = self.display.getContext() + rect = Rectangle(0, 0, DISPLAY_WIDTH - 1, DISPLAY_HEIGHT - 1, fill=False, outline=1) rect.show() rect.draw(ctx)