class Frame(object): live = False def __init__(self, client, area=None, ord=None, offset=None, height=None): self.client = client self.ord = ord self.offset = offset self.height = height @property def width(self): return self.area.width def prop(key): @liveprop def prop(self): for area in self.tag.index: for frame in area.frames: if frame.client == self.client: return getattr(frame, key) return prop offset = prop('area') offset = prop('ord') offset = prop('offset') height = prop('height') def grow(self, dir, amount=None): self.area.tag.grow(self, dir, amount) def nudge(self, dir, amount=None): self.area.tag.nudge(self, dir, amount)
class Area(object): def __init__(self, tag, ord, screen='sel', offset=sentinel, width=sentinel, height=sentinel, frames=sentinel): self.tag = tag if ':' in str(ord): screen, ord = ord.split(':', 2) self.ord = str(ord) self.screen = str(screen) self.offset = offset self.width = width self.height = height self.frames = frames def prop(key): @liveprop def prop(self): for area in self.tag.index: if str(area.ord) == str(self.ord): return getattr(area, key) return prop offset = prop('offset') width = prop('width') height = prop('height') frames = prop('frames') @property def spec(self): if self.screen is not None: return '%s:%s' % (self.screen, self.ord) return self.ord @property def mode(self): for k, v in self.tag.iteritems(): if k == 'colmode': v = v.split(' ') if v[0] == self.ord: return v[1] @mode.setter def mode(self, val): self.tag['colmode %s' % self.spec] = val def grow(self, dir, amount=None): self.tag.grow(self, dir, amount) def nudge(self, dir, amount=None): self.tag.nudge(self, dir, amount)