def _test_orientation_compatibility(self, horizontal): if horizontal: if not self.orientations & ORIENTATION_HORIZONTAL: raise confreader.ConfigError( self.__class__.__name__ + " is not compatible with the orientation of the bar.") elif not self.orientations & ORIENTATION_VERTICAL: raise confreader.ConfigError( self.__class__.__name__ + " is not compatible with the orientation of the bar.")
def _configure(self, qtile, screen): Gap._configure(self, qtile, screen) if self.margin: if isinstance(self.margin, int): self.margin = [self.margin] * 4 if self.horizontal: self.x += self.margin[3] self.width -= self.margin[1] + self.margin[3] self.length = self.width if self.size == self.initial_size: self.size += self.margin[0] + self.margin[2] if self.screen.top is self: self.y += self.margin[0] else: self.y -= self.margin[2] else: self.y += self.margin[0] self.height -= self.margin[0] + self.margin[2] self.length = self.height self.size += self.margin[1] + self.margin[3] if self.screen.left is self: self.x += self.margin[3] else: self.x -= self.margin[1] stretches = 0 for w in self.widgets: # Executing _test_orientation_compatibility later, for example in # the _configure() method of each widget, would still pass # test/test_bar.py but a segfault would be raised when nosetests is # about to exit w._test_orientation_compatibility(self.horizontal) if w.length_type == STRETCH: stretches += 1 if stretches > 1: raise confreader.ConfigError("Only one STRETCH widget allowed!") self.window = window.Internal.create(self.qtile, self.x, self.y, self.width, self.height, self.opacity) self.drawer = drawer.Drawer(self.qtile, self.window.window.wid, self.width, self.height) self.drawer.clear(self.background) self.window.handle_Expose = self.handle_Expose self.window.handle_ButtonPress = self.handle_ButtonPress self.window.handle_ButtonRelease = self.handle_ButtonRelease qtile.windows_map[self.window.window.wid] = self.window self.window.unhide() for idx, i in enumerate(self.widgets): if i.configured: i = i.create_mirror() self.widgets[idx] = i qtile.register_widget(i) i._configure(qtile, self) self._resize(self.length, self.widgets)
def __init__(self, length, **config): """ length: bar.STRETCH, bar.CALCULATED, or a specified length. """ CommandObject.__init__(self) self.name = self.__class__.__name__.lower() if "name" in config: self.name = config["name"] configurable.Configurable.__init__(self, **config) self.add_defaults(_Widget.defaults) if length in (bar.CALCULATED, bar.STRETCH): self.length_type = length self.length = 0 elif isinstance(length, int): self.length_type = bar.STATIC self.length = length else: raise confreader.ConfigError("Widget width must be an int") self.configured = False self._futures: list[asyncio.TimerHandle] = []