replaced match case with dictionary

This commit is contained in:
BarsTiger
2022-05-19 09:00:10 +03:00
parent b0bbf6021b
commit f09c425a83

View File

@@ -62,7 +62,7 @@ def initialize_pusher() -> None:
receiver.connect() receiver.connect()
def open_menu() -> None: def open_menu(*args) -> None:
""" """
Animates the menu to open and close, using animation from config Animates the menu to open and close, using animation from config
:return: :return:
@@ -87,23 +87,17 @@ def handle_menu_click(text: str) -> None:
:param text: :param text:
:return: :return:
""" """
match text: index = {
case "Menu": "Menu": [open_menu, None],
open_menu() "Devices": [ui.pagesWidget.setCurrentIndex, 1],
case "Devices": "Screenshot": [ui.pagesWidget.setCurrentIndex, 2],
ui.pagesWidget.setCurrentIndex(1) "Wallpaper": [ui.pagesWidget.setCurrentIndex, 3],
case "Screenshot": "Console": [ui.pagesWidget.setCurrentIndex, 4],
ui.pagesWidget.setCurrentIndex(2) "Python": [ui.pagesWidget.setCurrentIndex, 5],
case "Wallpaper": "Download": [ui.pagesWidget.setCurrentIndex, 6],
ui.pagesWidget.setCurrentIndex(3) "Settings": [ui.pagesWidget.setCurrentIndex, 7]
case "Console": }
ui.pagesWidget.setCurrentIndex(4) index[text][0](index[text][1])
case "Python":
ui.pagesWidget.setCurrentIndex(5)
case "Download":
ui.pagesWidget.setCurrentIndex(6)
case "Settings":
ui.pagesWidget.setCurrentIndex(7)
def handle_connection_to_server(connection) -> None: def handle_connection_to_server(connection) -> None: