ui fixes expand widget on x and y works
This commit is contained in:
73
ui/tunnel_details.py
Normal file
73
ui/tunnel_details.py
Normal file
@@ -0,0 +1,73 @@
|
||||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
|
||||
from shared_libs.common_tools import ConfigManager
|
||||
from shared_libs.wp_app_config import Msg
|
||||
|
||||
|
||||
class TunnelDetails(ttk.Frame):
|
||||
def __init__(self, container, **kwargs):
|
||||
super().__init__(container, **kwargs)
|
||||
|
||||
self.columnconfigure(0, weight=1)
|
||||
self.rowconfigure(0, weight=1)
|
||||
self.rowconfigure(1, weight=1)
|
||||
self.rowconfigure(2, weight=1)
|
||||
|
||||
self.active_frame = ttk.LabelFrame(self, text=Msg.STR["active_tunnel"])
|
||||
self.active_frame.grid(column=0, row=0, sticky="nsew", padx=10, pady=5)
|
||||
self.active_frame.columnconfigure(0, weight=1)
|
||||
self.active_frame.rowconfigure(0, weight=1)
|
||||
|
||||
self.interface_frame = ttk.LabelFrame(self, text=Msg.STR["interface"])
|
||||
self.interface_frame.grid(column=0, row=1, sticky="nsew", padx=10, pady=5)
|
||||
self.interface_frame.columnconfigure(0, weight=1)
|
||||
self.interface_frame.rowconfigure(0, weight=1)
|
||||
self.interface_frame.rowconfigure(1, weight=1)
|
||||
|
||||
self.peer_frame = ttk.LabelFrame(self, text=Msg.STR["peer"])
|
||||
self.peer_frame.grid(column=0, row=2, sticky="nsew", padx=10, pady=5)
|
||||
self.peer_frame.columnconfigure(0, weight=1)
|
||||
self.peer_frame.rowconfigure(0, weight=1)
|
||||
|
||||
self.str_var = tk.StringVar()
|
||||
self.add_var = tk.StringVar()
|
||||
self.dns_var = tk.StringVar()
|
||||
self.enp_var = tk.StringVar()
|
||||
|
||||
self.lb_tunnel = None
|
||||
self.color_label()
|
||||
|
||||
self.address_label = ttk.Label(self.interface_frame, textvariable=self.add_var, foreground="#0071ff")
|
||||
self.address_label.grid(column=0, row=0, sticky="nsew", padx=10, pady=(0, 20))
|
||||
self.address_label.config(font=("Ubuntu", 9))
|
||||
|
||||
self.dns_label = ttk.Label(self.interface_frame, textvariable=self.dns_var, foreground="#0071ff")
|
||||
self.dns_label.grid(column=0, row=1, sticky="nsew", padx=10, pady=(0, 20))
|
||||
self.dns_label.config(font=("Ubuntu", 9))
|
||||
|
||||
self.endpoint_label = ttk.Label(self.peer_frame, textvariable=self.enp_var, foreground="#0071ff")
|
||||
self.endpoint_label.grid(column=0, row=0, sticky="nsew", padx=10, pady=(0, 30))
|
||||
self.endpoint_label.config(font=("Ubuntu", 9))
|
||||
|
||||
def color_label(self):
|
||||
if self.lb_tunnel:
|
||||
self.lb_tunnel.destroy()
|
||||
|
||||
foreground = "yellow" if ConfigManager.get("theme") != "light" else "green"
|
||||
self.lb_tunnel = ttk.Label(self.active_frame, textvariable=self.str_var, foreground=foreground)
|
||||
self.lb_tunnel.config(font=("Ubuntu", 11, "bold"))
|
||||
self.lb_tunnel.grid(column=0, row=0, padx=10, pady=(0, 10), sticky="nsew")
|
||||
|
||||
def update_details(self, active_tunnel_name, tunnel_data):
|
||||
self.str_var.set(active_tunnel_name)
|
||||
if active_tunnel_name and tunnel_data and active_tunnel_name in tunnel_data:
|
||||
values = tunnel_data[active_tunnel_name]
|
||||
self.add_var.set(f"Address: {values.get('Address', '')}")
|
||||
self.dns_var.set(f" DNS: {values.get('DNS', '')}")
|
||||
self.enp_var.set(f"Endpoint: {values.get('Endpoint', '')}")
|
||||
else:
|
||||
self.add_var.set("")
|
||||
self.dns_var.set("")
|
||||
self.enp_var.set("")
|
||||
self.color_label()
|
Reference in New Issue
Block a user