Commit d88f54ae authored by Martin Drechsler's avatar Martin Drechsler

created a file with pyqtgraph subclasses

parent e54ea7ca
from pyqtgraph import ROI
class CustomRectangularROI(ROI):
"""
Rectangular ROI subclass with a single scale handle at the top-right corner.
============== =============================================================
**Arguments**
pos (length-2 sequence) The position of the ROI origin.
See ROI().
size (length-2 sequence) The size of the ROI. See ROI().
centered (bool) If True, scale handles affect the ROI relative to its
center, rather than its origin.
sideScalers (bool) If True, extra scale handles are added at the top and
right edges.
\**args All extra keyword arguments are passed to ROI()
============== =============================================================
"""
def __init__(self, pos, size = [8, 8], centered=False, sideScalers=False):
#ROI.__init__(self, pos, size, **args)
super().__init__(pos, size, centered, sideScalers)
## handles scaling horizontally around center
self.addScaleHandle([1, 0.5], [0.5, 0.5])
self.addScaleHandle([0, 0.5], [0.5, 0.5])
## handles scaling vertically from opposite edge
self.addScaleHandle([0.5, 0], [0.5, 1])
self.addScaleHandle([0.5, 1], [0.5, 0])
## handles scaling both vertically and horizontally
self.addScaleHandle([1, 1], [0, 0])
self.addScaleHandle([0, 0], [1, 1])
self.sigRegionChangeFinished.connect(self.correct_scaling)
def correct_scaling(self):
x, y = self.pos()[0], self.pos()[1]
print(x, y)
if x%8 != 0 or y%8 != 0:
self.setPos((x//8)*8, (y//8)*8)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment