Oleg42-prog / scrolls

Useful solutions/templates/patterns
0 stars 0 forks source link

Verbose ColorTrackbars' child classes #8

Closed Oleg42-prog closed 7 months ago

Oleg42-prog commented 7 months ago

Creating child classes based on ColorTrackbars is time-consuming:

class HSVTrackbars(ColorTrackbars):

    def __init__(self, window_name):
        super().__init__(window_name, 'hsv')

    @property
    def h(self):
        return self.get_bounds('h')

    @property
    def s(self):
        return self.get_bounds('s')

    @property
    def v(self):
        return self.get_bounds('v')
class RGBTrackbars(ColorTrackbars):

    def __init__(self, window_name):
        super().__init__(window_name, 'rgb')

    @property
    def r(self):
        return self.get_bounds('r')

    @property
    def g(self):
        return self.get_bounds('g')

    @property
    def b(self):
        return self.get_bounds('b')
Oleg42-prog commented 7 months ago

I propose to use dynamic properties