From fcc78032c4b3b62d062ec86783f770b4149329eb Mon Sep 17 00:00:00 2001 From: themanyfaceddemon Date: Fri, 13 Sep 2024 00:37:54 +0300 Subject: [PATCH] Hot fix DMClientApp class --- Code/gui/{start.py => dm_client_app.py} | 36 +++++++++++++------------ Code/main.py | 2 +- 2 files changed, 20 insertions(+), 18 deletions(-) rename Code/gui/{start.py => dm_client_app.py} (80%) diff --git a/Code/gui/start.py b/Code/gui/dm_client_app.py similarity index 80% rename from Code/gui/start.py rename to Code/gui/dm_client_app.py index 38e37a7..f460e34 100644 --- a/Code/gui/start.py +++ b/Code/gui/dm_client_app.py @@ -1,10 +1,8 @@ import atexit - import dearpygui.dearpygui as dpg from dearpygui_async import DearPyGuiAsync from pypresence import Presence from systems.loc import Localization as loc - from .fonts_setup import FontManager @@ -15,6 +13,7 @@ class DMClientApp: def __init__(self): dpg.create_context() FontManager.load_fonts() + dpg.create_viewport( title=loc.get_string("main-app-name"), width=600, @@ -27,12 +26,13 @@ def __init__(self): DMClientApp.rpc.connect() DMClientApp.rpc.update(state="Nya~") - atexit.register(self.rpc.close) + atexit.register(DMClientApp.rpc.close) - self._create_warning_window() + DMClientApp._create_warning_window() @classmethod def _create_warning_window(cls): + """Создание окна предупреждения""" with dpg.window( label="Warning", tag="warning_window", @@ -50,17 +50,9 @@ def _create_warning_window(cls): label=loc.get_string("no_warning_window"), callback=cls._on_no ) - @classmethod - def _on_yes(cls, *args): - dpg.delete_item("warning_window") - cls._create_connect_window() - - @classmethod - def _on_no(cls, *args): - cls.stop() - @classmethod def _create_connect_window(cls): + """Создание окна подключения""" if dpg.does_item_exist("connect_window"): dpg.focus_item("connect_window") return @@ -74,7 +66,6 @@ def _create_connect_window(cls): width=380, ): dpg.add_text(loc.get_string("connect_main_text")) - dpg.add_input_text( hint=loc.get_string("connect_login_hint"), tag="connect_login" ) @@ -89,12 +80,22 @@ def _create_connect_window(cls): dpg.add_input_int( label=loc.get_string("connect_port_lable"), tag="connect_port" ) - dpg.add_button( - label=loc.get_string("connect_button") - ) + dpg.add_button(label=loc.get_string("connect_button")) + + @classmethod + def _on_yes(cls, *args): + """Обработка нажатия кнопки 'Yes' в окне предупреждения""" + dpg.delete_item("warning_window") + cls._create_connect_window() + + @classmethod + def _on_no(cls, *args): + """Обработка нажатия кнопки 'No' в окне предупреждения""" + cls.stop() @classmethod def run(cls): + """Запуск основного цикла приложения""" dpg.show_viewport() cls._dpg_async.run() dpg.start_dearpygui() @@ -102,4 +103,5 @@ def run(cls): @classmethod def stop(cls): + """Остановка основного цикла приложения""" dpg.stop_dearpygui() diff --git a/Code/main.py b/Code/main.py index 4c5d9bc..682aa2a 100644 --- a/Code/main.py +++ b/Code/main.py @@ -3,7 +3,7 @@ from api import * # noqa: F403 from DMBotNetwork import Client -from gui.start import DMClientApp +from gui.dm_client_app import DMClientApp from root_path import ROOT_PATH from systems.loc import Localization as loc