From da22beca69fc5dde0a4e0ef79f818a11be70a8cd Mon Sep 17 00:00:00 2001 From: IMDelewer Date: Tue, 17 Mar 2026 15:50:38 +0300 Subject: [PATCH] fix: apply all requested changes from PR review --- windows.py | 42 +++++------------------------------------- 1 file changed, 5 insertions(+), 37 deletions(-) diff --git a/windows.py b/windows.py index 33dab3a..99b489e 100644 --- a/windows.py +++ b/windows.py @@ -14,22 +14,9 @@ import asyncio as _asyncio from pathlib import Path from typing import Dict, Optional -try: - import pystray -except Exception: - pystray = None - -try: - import customtkinter as ctk -except Exception: - ctk = None - -try: - from PIL import Image, ImageDraw, ImageFont -except Exception: - Image = None - ImageDraw = None - ImageFont = None +import pystray +import customtkinter as ctk +from PIL import Image, ImageDraw, ImageFont import proxy.tg_ws_proxy as tg_ws_proxy @@ -278,23 +265,11 @@ def restart_proxy(): def _show_error(text: str, title: str = "TG WS Proxy — Ошибка"): - if sys.platform == "win32": - try: - ctypes.windll.user32.MessageBoxW(0, text, title, 0x10) - return - except Exception: - pass - print(f"{title}: {text}", file=sys.stderr) + ctypes.windll.user32.MessageBoxW(0, text, title, 0x10) def _show_info(text: str, title: str = "TG WS Proxy"): - if sys.platform == "win32": - try: - ctypes.windll.user32.MessageBoxW(0, text, title, 0x40) - return - except Exception: - pass - print(f"{title}: {text}", file=sys.stdout) + ctypes.windll.user32.MessageBoxW(0, text, title, 0x40) def _on_open_in_telegram(icon=None, item=None): @@ -682,13 +657,6 @@ def run_tray(): log.info("Config: %s", _config) log.info("Log file: %s", LOG_FILE) - if ctk is None: - _show_error( - "Для tray-режима требуется tkinter (Tcl/Tk).\n\n" - "Windows: переустановите Python с включённым Tcl/Tk.\n" - "Linux: установите пакет python3-tk / tk.") - return - if pystray is None or Image is None: log.error("pystray or Pillow not installed; " "running in console mode")