From f09c425a839d609f3f38342c68fc9fd832aac47c Mon Sep 17 00:00:00 2001 From: BarsTiger Date: Thu, 19 May 2022 09:00:10 +0300 Subject: [PATCH] replaced match case with dictionary --- admin/daunRat_admin.py | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/admin/daunRat_admin.py b/admin/daunRat_admin.py index 1781a15..10d4bf4 100644 --- a/admin/daunRat_admin.py +++ b/admin/daunRat_admin.py @@ -62,7 +62,7 @@ def initialize_pusher() -> None: receiver.connect() -def open_menu() -> None: +def open_menu(*args) -> None: """ Animates the menu to open and close, using animation from config :return: @@ -87,23 +87,17 @@ def handle_menu_click(text: str) -> None: :param text: :return: """ - match text: - case "Menu": - open_menu() - case "Devices": - ui.pagesWidget.setCurrentIndex(1) - case "Screenshot": - ui.pagesWidget.setCurrentIndex(2) - case "Wallpaper": - ui.pagesWidget.setCurrentIndex(3) - case "Console": - ui.pagesWidget.setCurrentIndex(4) - case "Python": - ui.pagesWidget.setCurrentIndex(5) - case "Download": - ui.pagesWidget.setCurrentIndex(6) - case "Settings": - ui.pagesWidget.setCurrentIndex(7) + index = { + "Menu": [open_menu, None], + "Devices": [ui.pagesWidget.setCurrentIndex, 1], + "Screenshot": [ui.pagesWidget.setCurrentIndex, 2], + "Wallpaper": [ui.pagesWidget.setCurrentIndex, 3], + "Console": [ui.pagesWidget.setCurrentIndex, 4], + "Python": [ui.pagesWidget.setCurrentIndex, 5], + "Download": [ui.pagesWidget.setCurrentIndex, 6], + "Settings": [ui.pagesWidget.setCurrentIndex, 7] + } + index[text][0](index[text][1]) def handle_connection_to_server(connection) -> None: