self.clock.tick(60)
+class FPSMixin:
+ FPS_COLOR = "yellow"
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.current_fps = None
+
+ def update(self):
+ super().update()
+ new_fps = int(self.clock.get_fps())
+ if self.current_fps != new_fps:
+ self.current_fps = new_fps
+ self.dirty = True
+
+ def draw(self):
+ super().draw()
+ surf_size = self.surf.get_size()
+ fs = self.font.render(f"{int(self.current_fps)} FPS", True, self.FPS_COLOR)
+ fs_size = fs.get_size()
+ self.surf.blit(
+ fs, (surf_size[0] - fs_size[0] - 7, surf_size[1] - fs_size[1] - 7)
+ )
+
+
class UIChild:
def __init__(self, parent):
self.parent = parent
import pygame
from bluetooth import BluetoothConf
-from ui import Button, Icon, IconButton, Switch, UIParent
+from ui import Button, FPSMixin, Icon, IconButton, Switch, UIParent
from vector_assets import (
bluetooth,
laptop_double,
from xrandr import XrandrConf
-class FPSMixin:
- FPS_COLOR = "yellow"
-
- def __init__(self, *args, **kwargs):
- super().__init__(*args, **kwargs)
- self.current_fps = None
-
- def update(self):
- super().update()
- new_fps = int(self.clock.get_fps())
- if self.current_fps != new_fps:
- self.current_fps = new_fps
- self.dirty = True
-
- def draw(self):
- super().draw()
- surf_size = self.surf.get_size()
- fs = self.font.render(f"{int(self.current_fps)} FPS", True, self.FPS_COLOR)
- fs_size = fs.get_size()
- self.surf.blit(
- fs, (surf_size[0] - fs_size[0] - 7, surf_size[1] - fs_size[1] - 7)
- )
-
-
class ZenbookConf(FPSMixin, UIParent):
BACKGROUND_COLOR = 0x333333