Skip to content

Commit

Permalink
Hot fix DMClientApp class
Browse files Browse the repository at this point in the history
  • Loading branch information
themanyfaceddemon committed Sep 12, 2024
1 parent 215bfda commit fcc7803
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
36 changes: 19 additions & 17 deletions Code/gui/start.py → Code/gui/dm_client_app.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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,
Expand All @@ -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",
Expand All @@ -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
Expand All @@ -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"
)
Expand All @@ -89,17 +80,28 @@ 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()
dpg.destroy_context()

@classmethod
def stop(cls):
"""Остановка основного цикла приложения"""
dpg.stop_dearpygui()
2 changes: 1 addition & 1 deletion Code/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit fcc7803

Please sign in to comment.