From: mar77i Date: Thu, 26 Dec 2024 19:11:35 +0000 (+0100) Subject: vectors.X.draw() takes color for the second arg, not pos. add icon and window title X-Git-Url: https://git.mar77i.info/?a=commitdiff_plain;h=6765d75c156e589adf145c7297b43d1d68abfdfb;p=zenbook_conf vectors.X.draw() takes color for the second arg, not pos. add icon and window title --- diff --git a/vectors.py b/vectors.py index 55a024c..6db406e 100644 --- a/vectors.py +++ b/vectors.py @@ -189,9 +189,6 @@ class StrokeRoundLine(Polygon): self.width * max(unit), ) - def draw(self, surf, pos): - super().draw(surf, pos) - class Shapes(Shape): def __init__(self, shapes): @@ -202,9 +199,9 @@ class Shapes(Shape): raise NotImplementedError return Shapes([s.fit(pos, unit) for s in self.shapes]) - def draw(self, surf, pos): + def draw(self, surf, color): for shape in self.shapes: - shape.draw(surf, pos) + shape.draw(surf, color) class StrokePath: @@ -270,9 +267,6 @@ class StrokeCircle(StrokePath): self.width * max(unit), ) - def draw(self, surf, pos): - super().draw(surf, pos) - class StrokeCircleSegment(StrokeCircle): def __init__(self, center, radius, start_angle, end_angle, width): diff --git a/zenbook_conf.py b/zenbook_conf.py index 8a39983..8460cd0 100755 --- a/zenbook_conf.py +++ b/zenbook_conf.py @@ -47,8 +47,11 @@ class ZenbookConf(FPSMixin, UIParent): def __init__(self): pygame.init() + pygame.display.set_icon(self.get_icon()) + pygame.display.set_caption("Zenbook Config") + window_size = (1536, 1200) super().__init__( - pygame.display.set_mode((1536, 1200)), pygame.font.Font(None, size=96), + pygame.display.set_mode(window_size), pygame.font.Font(None, size=96), ) self.xrandr_conf = XrandrConf() self.xinput_conf = XinputConf(self.xrandr_conf) @@ -143,9 +146,22 @@ class ZenbookConf(FPSMixin, UIParent): "Re-apply", partial(self.xinput_conf.reapply_by_type, "stylus") ), + Button( + self, + pygame.Rect((window_size[0] - 128, 0), (128, 64)), + "×", + self.quit, + ), ) ) + def get_icon(self): + surf = pygame.Surface((512, 512), pygame.SRCALPHA, 32) + surf.fill(0x0) + v = 512 // 22 + laptop_single.fit((0, 0), (v, v)).draw(surf, "white") + return pygame.transform.scale(surf, (32, 32)) + def laptop_cb(self, name, bt_switch, touch_switch, stylus_switch): self.xrandr_conf.update(name) if name != "single": @@ -163,6 +179,9 @@ class ZenbookConf(FPSMixin, UIParent): def laptop_is_active(self, name): return self.xrandr_conf.is_active(name) + def quit(self): + self.running = False + if __name__ == "__main__": ZenbookConf().run()