Enhance status bar with TFTP server indicator
- Add TFTP server status indicator to the status bar - Implement tooltip for TFTP server status - Update status bar update method to reflect TFTP server state - Improve status bar layout with separate frames for indicators
This commit is contained in:
@@ -1158,6 +1158,9 @@ class SerialAppGUI(tk.Tk):
|
||||
# Запускаем периодическое обновление информации о передачах
|
||||
self.update_transfers_periodically()
|
||||
|
||||
# Обновляем статус бар после запуска сервера
|
||||
self.update_status_bar()
|
||||
|
||||
except Exception as e:
|
||||
self.append_tftp_log(f"[ERROR] Ошибка запуска сервера: {str(e)}")
|
||||
messagebox.showerror("Ошибка", f"Не удалось запустить TFTP сервер: {str(e)}")
|
||||
@@ -1206,6 +1209,9 @@ class SerialAppGUI(tk.Tk):
|
||||
for item in self.transfers_tree.get_children():
|
||||
self.transfers_tree.delete(item)
|
||||
|
||||
# Обновляем статус бар после остановки сервера
|
||||
self.update_status_bar()
|
||||
|
||||
except Exception as e:
|
||||
self.append_tftp_log(f"[ERROR] Ошибка остановки сервера: {str(e)}")
|
||||
messagebox.showerror("Ошибка", f"Не удалось остановить TFTP сервер: {str(e)}")
|
||||
@@ -1278,21 +1284,46 @@ class SerialAppGUI(tk.Tk):
|
||||
self.status_bar = ttk.Frame(self)
|
||||
self.status_bar.pack(side=tk.BOTTOM, fill=tk.X)
|
||||
|
||||
# Создаем индикатор состояния используя символ
|
||||
# Создаем фрейм для индикаторов
|
||||
indicators_frame = ttk.Frame(self.status_bar)
|
||||
indicators_frame.pack(side=tk.LEFT)
|
||||
|
||||
# Индикатор подключения к коммутатору
|
||||
self.connection_indicator_frame = ttk.Frame(indicators_frame)
|
||||
self.connection_indicator_frame.pack(side=tk.LEFT)
|
||||
|
||||
ttk.Label(self.connection_indicator_frame, text="COM:", padding=(5, 2)).pack(side=tk.LEFT)
|
||||
self.connection_indicator = ttk.Label(
|
||||
self.status_bar,
|
||||
text="⬤", # Используем символ ЧЕРНЫЙ КРУГ (U+2B24)
|
||||
font=("Segoe UI", 10), # Уменьшаем размер для лучшего выравнивания
|
||||
width=2, # Фиксированная ширина для стабильного положения
|
||||
anchor='center', # Центрируем символ
|
||||
padding=(5, 2) # Добавляем вертикальный отступ для выравнивания с текстом
|
||||
self.connection_indicator_frame,
|
||||
text="⬤",
|
||||
font=("Segoe UI", 10),
|
||||
width=2,
|
||||
anchor='center',
|
||||
padding=(2, 2)
|
||||
)
|
||||
self.connection_indicator.pack(side=tk.LEFT)
|
||||
|
||||
# Создаем всплывающую подсказку
|
||||
# Индикатор TFTP сервера
|
||||
self.tftp_indicator_frame = ttk.Frame(indicators_frame)
|
||||
self.tftp_indicator_frame.pack(side=tk.LEFT, padx=10)
|
||||
|
||||
ttk.Label(self.tftp_indicator_frame, text="TFTP:", padding=(5, 2)).pack(side=tk.LEFT)
|
||||
self.tftp_indicator = ttk.Label(
|
||||
self.tftp_indicator_frame,
|
||||
text="⬤",
|
||||
font=("Segoe UI", 10),
|
||||
width=2,
|
||||
anchor='center',
|
||||
padding=(2, 2)
|
||||
)
|
||||
self.tftp_indicator.pack(side=tk.LEFT)
|
||||
|
||||
# Создаем всплывающие подсказки
|
||||
self.tooltip = None
|
||||
self.connection_indicator.bind('<Enter>', self.show_connection_tooltip)
|
||||
self.connection_indicator.bind('<Leave>', self.hide_connection_tooltip)
|
||||
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)
|
||||
|
||||
@@ -1315,11 +1346,9 @@ class SerialAppGUI(tk.Tk):
|
||||
self.version_label = ttk.Label(self.status_bar, text=f"Версия: {VERSION}", padding=(5, 2))
|
||||
self.version_label.pack(side=tk.RIGHT)
|
||||
|
||||
# Добавляем методы для управления всплывающей подсказкой
|
||||
def show_connection_tooltip(self, event):
|
||||
x, y, _, _ = self.connection_indicator.bbox("insert")
|
||||
x += self.connection_indicator.winfo_rootx() + 25
|
||||
y += self.connection_indicator.winfo_rooty() + 20
|
||||
x = event.widget.winfo_rootx()
|
||||
y = event.widget.winfo_rooty() + 20
|
||||
|
||||
# Удаляем предыдущий tooltip если есть
|
||||
self.hide_connection_tooltip(event)
|
||||
@@ -1330,7 +1359,7 @@ class SerialAppGUI(tk.Tk):
|
||||
|
||||
label = ttk.Label(
|
||||
self.tooltip,
|
||||
text="Состояние подключения: " +
|
||||
text="Состояние COM порта: " +
|
||||
("Подключено" if self.connection else "Отключено"),
|
||||
justify=tk.LEFT,
|
||||
background="#ffffe0",
|
||||
@@ -1340,6 +1369,29 @@ class SerialAppGUI(tk.Tk):
|
||||
)
|
||||
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()
|
||||
@@ -1347,11 +1399,17 @@ class SerialAppGUI(tk.Tk):
|
||||
|
||||
# Обновляем метод update_status_bar
|
||||
def update_status_bar(self):
|
||||
# Обновляем индикатор подключения
|
||||
# Обновляем индикатор подключения COM порта
|
||||
if self.connection:
|
||||
self.connection_indicator.configure(text="⬤", foreground='green')
|
||||
else:
|
||||
self.connection_indicator.configure(text="⬤", foreground='red')
|
||||
|
||||
# Обновляем индикатор TFTP сервера
|
||||
if self.tftp_server and self.tftp_server.running:
|
||||
self.tftp_indicator.configure(text="⬤", foreground='green')
|
||||
else:
|
||||
self.tftp_indicator.configure(text="⬤", foreground='red')
|
||||
|
||||
# Остальные обновления статус бара
|
||||
port = self.settings.get("port", "Не выбран")
|
||||
|
||||
Reference in New Issue
Block a user