Improve interactive tab buttons with Unicode icons
- Add Unicode icons to the connect, disconnect and send buttons in the interactive tab
This commit is contained in:
@@ -832,8 +832,22 @@ class SerialAppGUI(tk.Tk):
|
|||||||
def create_interactive_tab(self, frame):
|
def create_interactive_tab(self, frame):
|
||||||
control_frame = ttk.Frame(frame)
|
control_frame = ttk.Frame(frame)
|
||||||
control_frame.pack(fill=X, pady=5)
|
control_frame.pack(fill=X, pady=5)
|
||||||
ttk.Button(control_frame, text="Подключиться", command=self.connect_device).pack(side=LEFT, padx=5)
|
|
||||||
ttk.Button(control_frame, text="Отключиться", command=self.disconnect_device).pack(side=LEFT, padx=5)
|
# Кнопка подключения с иконкой
|
||||||
|
connect_btn = ttk.Button(
|
||||||
|
control_frame,
|
||||||
|
text="⚡ Подключиться", # Unicode символ для "молнии"
|
||||||
|
command=self.connect_device
|
||||||
|
)
|
||||||
|
connect_btn.pack(side=LEFT, padx=5)
|
||||||
|
|
||||||
|
# Кнопка отключения с иконкой
|
||||||
|
disconnect_btn = ttk.Button(
|
||||||
|
control_frame,
|
||||||
|
text="✕ Отключиться", # Unicode символ для "крестика"
|
||||||
|
command=self.disconnect_device
|
||||||
|
)
|
||||||
|
disconnect_btn.pack(side=LEFT, padx=5)
|
||||||
|
|
||||||
self.interactive_text = CustomText(frame, wrap="word", height=20)
|
self.interactive_text = CustomText(frame, wrap="word", height=20)
|
||||||
self.interactive_text.pack(fill=BOTH, expand=True, padx=5, pady=5)
|
self.interactive_text.pack(fill=BOTH, expand=True, padx=5, pady=5)
|
||||||
@@ -843,7 +857,14 @@ class SerialAppGUI(tk.Tk):
|
|||||||
ttk.Label(input_frame, text="Команда:").pack(side=LEFT, padx=5)
|
ttk.Label(input_frame, text="Команда:").pack(side=LEFT, padx=5)
|
||||||
self.command_entry = CustomEntry(input_frame, width=50)
|
self.command_entry = CustomEntry(input_frame, width=50)
|
||||||
self.command_entry.pack(side=LEFT, padx=5)
|
self.command_entry.pack(side=LEFT, padx=5)
|
||||||
ttk.Button(input_frame, text="Отправить", command=self.send_command).pack(side=LEFT, padx=5)
|
|
||||||
|
# Кнопка отправки с иконкой
|
||||||
|
send_btn = ttk.Button(
|
||||||
|
input_frame,
|
||||||
|
text="➤ Отправить", # Unicode символ для "стрелки"
|
||||||
|
command=self.send_command
|
||||||
|
)
|
||||||
|
send_btn.pack(side=LEFT, padx=5)
|
||||||
|
|
||||||
# Подключение к устройству
|
# Подключение к устройству
|
||||||
def connect_device(self):
|
def connect_device(self):
|
||||||
@@ -1318,13 +1339,6 @@ class SerialAppGUI(tk.Tk):
|
|||||||
)
|
)
|
||||||
self.tftp_indicator.pack(side=tk.LEFT)
|
self.tftp_indicator.pack(side=tk.LEFT)
|
||||||
|
|
||||||
# Создаем всплывающие подсказки
|
|
||||||
self.tooltip = None
|
|
||||||
self.connection_indicator_frame.bind('<Enter>', self.show_connection_tooltip)
|
|
||||||
self.connection_indicator_frame.bind('<Leave>', self.hide_connection_tooltip)
|
|
||||||
self.tftp_indicator_frame.bind('<Enter>', self.show_tftp_tooltip)
|
|
||||||
self.tftp_indicator_frame.bind('<Leave>', self.hide_connection_tooltip)
|
|
||||||
|
|
||||||
ttk.Separator(self.status_bar, orient=tk.VERTICAL).pack(side=tk.LEFT, fill=tk.Y, padx=5)
|
ttk.Separator(self.status_bar, orient=tk.VERTICAL).pack(side=tk.LEFT, fill=tk.Y, padx=5)
|
||||||
|
|
||||||
# Остальные элементы статус бара...
|
# Остальные элементы статус бара...
|
||||||
@@ -1346,57 +1360,6 @@ class SerialAppGUI(tk.Tk):
|
|||||||
self.version_label = ttk.Label(self.status_bar, text=f"Версия: {VERSION}", padding=(5, 2))
|
self.version_label = ttk.Label(self.status_bar, text=f"Версия: {VERSION}", padding=(5, 2))
|
||||||
self.version_label.pack(side=tk.RIGHT)
|
self.version_label.pack(side=tk.RIGHT)
|
||||||
|
|
||||||
def show_connection_tooltip(self, event):
|
|
||||||
x = event.widget.winfo_rootx()
|
|
||||||
y = event.widget.winfo_rooty() + 20
|
|
||||||
|
|
||||||
# Удаляем предыдущий tooltip если есть
|
|
||||||
self.hide_connection_tooltip(event)
|
|
||||||
|
|
||||||
self.tooltip = tk.Toplevel(self)
|
|
||||||
self.tooltip.wm_overrideredirect(True)
|
|
||||||
self.tooltip.wm_geometry(f"+{x}+{y}")
|
|
||||||
|
|
||||||
label = ttk.Label(
|
|
||||||
self.tooltip,
|
|
||||||
text="Состояние COM порта: " +
|
|
||||||
("Подключено" if self.connection else "Отключено"),
|
|
||||||
justify=tk.LEFT,
|
|
||||||
background="#ffffe0",
|
|
||||||
relief=tk.SOLID,
|
|
||||||
borderwidth=1,
|
|
||||||
padding=(5, 2)
|
|
||||||
)
|
|
||||||
label.pack()
|
|
||||||
|
|
||||||
def show_tftp_tooltip(self, event):
|
|
||||||
x = event.widget.winfo_rootx()
|
|
||||||
y = event.widget.winfo_rooty() + 20
|
|
||||||
|
|
||||||
# Удаляем предыдущий tooltip если есть
|
|
||||||
self.hide_connection_tooltip(event)
|
|
||||||
|
|
||||||
self.tooltip = tk.Toplevel(self)
|
|
||||||
self.tooltip.wm_overrideredirect(True)
|
|
||||||
self.tooltip.wm_geometry(f"+{x}+{y}")
|
|
||||||
|
|
||||||
label = ttk.Label(
|
|
||||||
self.tooltip,
|
|
||||||
text="Состояние TFTP сервера: " +
|
|
||||||
("Запущен" if self.tftp_server and self.tftp_server.running else "Остановлен"),
|
|
||||||
justify=tk.LEFT,
|
|
||||||
background="#ffffe0",
|
|
||||||
relief=tk.SOLID,
|
|
||||||
borderwidth=1,
|
|
||||||
padding=(5, 2)
|
|
||||||
)
|
|
||||||
label.pack()
|
|
||||||
|
|
||||||
def hide_connection_tooltip(self, event):
|
|
||||||
if self.tooltip:
|
|
||||||
self.tooltip.destroy()
|
|
||||||
self.tooltip = None
|
|
||||||
|
|
||||||
# Обновляем метод update_status_bar
|
# Обновляем метод update_status_bar
|
||||||
def update_status_bar(self):
|
def update_status_bar(self):
|
||||||
# Обновляем индикатор подключения COM порта
|
# Обновляем индикатор подключения COM порта
|
||||||
|
|||||||
Reference in New Issue
Block a user