diff --git a/prettyqt/core/line.py b/prettyqt/core/line.py index 5c2766ce6..22f4d65a0 100644 --- a/prettyqt/core/line.py +++ b/prettyqt/core/line.py @@ -4,14 +4,32 @@ class Line(QtCore.QLine): + def __repr__(self): + return f"Line({repr(self.get_p1())}, {repr(self.get_p2())})" + + def __iter__(self): + yield self.get_p1() + yield self.get_p2() + def __getitem__(self, index): if index == 0: - return core.Point(self.p1()) + return self.get_p1() elif index == 1: - return core.Point(self.p2()) + return self.get_p2() def __setitem__(self, index, value): if index == 0: self.setP1(value) elif index == 1: self.setP2(value) + + def get_p1(self): + return core.Point(self.p1()) + + def get_p2(self): + return core.Point(self.p2()) + + +if __name__ == "__main__": + line = Line(core.Point(0, 0), core.Point(2, 2)) + print(repr(line)) diff --git a/prettyqt/core/linef.py b/prettyqt/core/linef.py index 825be417b..9d676ba65 100644 --- a/prettyqt/core/linef.py +++ b/prettyqt/core/linef.py @@ -4,14 +4,32 @@ class LineF(QtCore.QLineF): + def __repr__(self): + return f"LineF({repr(self.get_p1())}, {repr(self.get_p1())})" + + def __iter__(self): + yield self.get_p1() + yield self.get_p2() + def __getitem__(self, index): if index == 0: - return core.PointF(self.p1()) + return self.get_p1() elif index == 1: - return core.PointF(self.p2()) + return self.get_p2() def __setitem__(self, index, value): if index == 0: self.setP1(value) elif index == 1: self.setP2(value) + + def get_p1(self): + return core.PointF(self.p1()) + + def get_p2(self): + return core.PointF(self.p2()) + + +if __name__ == "__main__": + line = LineF(core.Point(0, 0), core.Point(2, 2)) + print(repr(line)) diff --git a/prettyqt/core/rect.py b/prettyqt/core/rect.py index 69aab1532..0b65697f3 100644 --- a/prettyqt/core/rect.py +++ b/prettyqt/core/rect.py @@ -6,3 +6,8 @@ class Rect(QtCore.QRect): def __repr__(self): return f"Rect({self.x()}, {self.y()}, {self.width()}, {self.height()})" + + +if __name__ == "__main__": + rect = Rect(0, 2, 5, 5) + print(repr(rect)) diff --git a/prettyqt/core/rectf.py b/prettyqt/core/rectf.py index e6de7db7e..87fcd78c4 100644 --- a/prettyqt/core/rectf.py +++ b/prettyqt/core/rectf.py @@ -6,3 +6,8 @@ class RectF(QtCore.QRectF): def __repr__(self): return f"RectF({self.x()}, {self.y()}, {self.width()}, {self.height()})" + + +if __name__ == "__main__": + rect = RectF(0, 2, 5, 5) + print(repr(rect))