From b8b2cb61f4535ab96838386ce57325ba8db2e6e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Rudowicz?= Date: Wed, 11 Sep 2024 22:05:26 +0200 Subject: [PATCH] Add ability to hide the mouse cursor --- menu.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/menu.py b/menu.py index df7186f..035598a 100644 --- a/menu.py +++ b/menu.py @@ -186,7 +186,8 @@ class App: SHOW_REQUEST_MESSAGE_FOR_AT_LEAST_S = 5 IGNORE_EVENTS_FOR_TICKS_AFTER_SCREENSAVER = 5 - def __init__(self, actions: List[Action], theme: Dict, fullscreen: bool, screensaver_delay: int): + def __init__(self, actions: List[Action], theme: Dict, fullscreen: bool, screensaver_delay: int, + hide_cursor: bool): pygame.init() info = pygame.display.Info() flags = 0 @@ -201,6 +202,8 @@ class App: self.task_q = Queue() self.screensaver = ClockScreensaver() self.TICKS_UNTIL_SCREENSAVER = screensaver_delay * self.FPS + if hide_cursor: + pygame.mouse.set_visible(False) def get_screen_rect(self) -> pygame.Rect: return pygame.Rect(0, 0, self.screen.get_width(), self.screen.get_height()) @@ -317,6 +320,7 @@ if __name__ == '__main__': parser.add_argument("--no-fullscreen", help="Fullscreen", action='store_true') parser.add_argument("--screensaver-delay", help="Screensaver delay, in seconds. Default=30", type=int, default=30) + parser.add_argument("--no-cursor", help="Hide the mouse cursor", action='store_true') args = parser.parse_args() url_defs: List[Action] = [] @@ -325,5 +329,5 @@ if __name__ == '__main__': url_defs = get_url_defs(data) app = App(url_defs, theme=data["theme"], fullscreen=not args.no_fullscreen, - screensaver_delay=args.screensaver_delay) + screensaver_delay=args.screensaver_delay, hide_cursor=args.no_cursor) app.loop()