self.pushed = False
self.callback = callback
+ def render_label(self, color):
+ return self.parent.font.render(self.label, True, color)
+
def draw(self):
if not self.pushed:
- frame_color = "gray"
- fs = self.parent.font.render(self.label, True, "gray")
+ frame_color = label_color = "gray"
else:
pygame.draw.rect(self.parent.surf, "darkgray", self.rect)
frame_color = "lightgray"
- fs = self.parent.font.render(self.label, True, "black")
+ label_color = "black"
+ fs = self.render_label(label_color)
pygame.draw.rect(self.parent.surf, frame_color, self.rect, 8)
fs_size = fs.get_size()
center = self.rect.center
from xrandr import XrandrConf
+class IconifyButton(Button):
+ """
+ Place an underscore in a 64 pixel high button where it's visible
+ With the 96 size font, underscores kind of fall out of the visible area
+ """
+
+ def render_label(self, color):
+ fs = super().render_label(color)
+ fs_rect = fs.get_rect()
+ y_offset = 28
+ fs = fs.subsurface(
+ pygame.Rect(
+ (fs_rect.left, fs_rect.top + y_offset),
+ (fs_rect.width, fs_rect.height - y_offset),
+ )
+ )
+ return fs
+
+
+
class ZenbookConf(FPSMixin, UIParent):
BACKGROUND_COLOR = 0x333333
"×",
self.quit,
),
+ IconifyButton(
+ self,
+ pygame.Rect((window_size[0] - 256, 0), (128, 64)),
+ "_",
+ self.iconify,
+ ),
)
)
def quit(self):
self.running = False
+ def iconify(self):
+ pygame.display.iconify()
+
if __name__ == "__main__":
ZenbookConf().run()