From ece18aea4da1630a47116e995e000c1f2d77191c Mon Sep 17 00:00:00 2001 From: Lowa Date: Sun, 16 Feb 2025 02:24:40 +0300 Subject: [PATCH] Add About window to application menu - Import and integrate AboutWindow class - Create new "Help" menu with "About Program" option - Add `open_about()` method to display About window - Enhance application's help and information accessibility --- .gitignore | 2 +- ComConfigCopy.py | 11 ++++++ about_window.py | 100 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 about_window.py diff --git a/.gitignore b/.gitignore index 674ec4b..c234d52 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,6 @@ Configs/Eltex MES2424 AC - Сеть FTTB 2G, доп.txt Configs/конфиг доп 3750-52 с айпи 172.17.141.133 .txt DALL·E 2024-12-29 01.01.02 - Square vector logo_ A clean and minimalistic app icon for serial port management software. The design prominently features a simplified rectangular CO.ico test.py -__pycache__/TFTPServer.cpython-312.pyc +__pycache__/ Firmware/1.jpg Firmware/2 diff --git a/ComConfigCopy.py b/ComConfigCopy.py index b40b80c..467c80c 100644 --- a/ComConfigCopy.py +++ b/ComConfigCopy.py @@ -36,6 +36,7 @@ from tkinter import ttk import serial import serial.tools.list_ports from serial.serialutil import SerialException +from about_window import AboutWindow # from TFTPServer import TFTPServerThread # Создаем необходимые папки @@ -590,6 +591,11 @@ class SerialAppGUI(tk.Tk): file_menu.add_separator() file_menu.add_command(label="Выход", command=self.quit) + # Меню "Справка" + help_menu = tk.Menu(menubar, tearoff=0) + menubar.add_cascade(label="Справка", menu=help_menu) + help_menu.add_command(label="О программе", command=self.open_about) + def open_settings(self): settings_window = SettingsWindow(self, self.settings, self.on_settings_changed) settings_window.transient(self) @@ -812,6 +818,11 @@ class SerialAppGUI(tk.Tk): logging.error(f"Ошибка сохранения файла: {e}", exc_info=True) messagebox.showerror("Ошибка", f"Не удалось сохранить файл:\n{e}") + def open_about(self): + about_window = AboutWindow(self) + about_window.transient(self) + about_window.grab_set() + # ========================== # Парсер аргументов (не используется) # ========================== diff --git a/about_window.py b/about_window.py new file mode 100644 index 0000000..21e1781 --- /dev/null +++ b/about_window.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import tkinter as tk +from tkinter import ttk, BOTH, X, BOTTOM +import webbrowser + +class AboutWindow(tk.Toplevel): + def __init__(self, parent): + super().__init__(parent) + self.title("О программе") + self.geometry("400x300") + self.resizable(False, False) + + # Создаем фрейм + about_frame = ttk.Frame(self, padding="20") + about_frame.pack(fill=BOTH, expand=True) + + # Заголовок + ttk.Label( + about_frame, + text="ComConfigCopy", + font=("Segoe UI", 16, "bold") + ).pack(pady=(0, 10)) + + # Описание + ttk.Label( + about_frame, + text="Программа для копирования конфигураций на коммутаторы", + wraplength=350 + ).pack(pady=(0, 20)) + + # Версия + ttk.Label( + about_frame, + text="Версия 1.0", + font=("Segoe UI", 10) + ).pack(pady=(0, 20)) + + # Контактная информация + contact_frame = ttk.Frame(about_frame) + contact_frame.pack(fill=X, pady=(0, 20)) + + # Исходный код + ttk.Label( + contact_frame, + text="Исходный код:", + font=("Segoe UI", 10, "bold") + ).pack(anchor="w") + + source_link = ttk.Label( + contact_frame, + text="https://gitea.filow.ru/LowaSC/ComConfigCopy", + cursor="hand2", + foreground="blue" + ) + source_link.pack(anchor="w") + source_link.bind("", lambda e: self.open_url("https://gitea.filow.ru/LowaSC/ComConfigCopy")) + + # Контакты + ttk.Label( + contact_frame, + text="\nКонтакты:", + font=("Segoe UI", 10, "bold") + ).pack(anchor="w") + + ttk.Label( + contact_frame, + text="Email: LowaWorkMail@gmail.com" + ).pack(anchor="w") + + telegram_link = ttk.Label( + contact_frame, + text="Telegram: @LowaSC", + cursor="hand2", + foreground="blue" + ) + telegram_link.pack(anchor="w") + telegram_link.bind("", lambda e: self.open_url("https://t.me/LowaSC")) + + # Кнопка закрытия + ttk.Button( + about_frame, + text="Закрыть", + command=self.destroy + ).pack(side=BOTTOM, pady=(20, 0)) + + # Центрируем окно + self.center_window() + + def center_window(self): + self.update_idletasks() + width = self.winfo_width() + height = self.winfo_height() + x = (self.winfo_screenwidth() // 2) - (width // 2) + y = (self.winfo_screenheight() // 2) - (height // 2) + self.geometry(f"{width}x{height}+{x}+{y}") + + def open_url(self, url): + webbrowser.open(url) \ No newline at end of file