88 lines
3.2 KiB
Python
88 lines
3.2 KiB
Python
import tkinter as tk
|
|
from tkinter import ttk
|
|
|
|
from shared_libs.common_tools import Tooltip
|
|
from shared_libs.wp_app_config import Msg
|
|
from tunnel import Tunnel
|
|
|
|
|
|
class Controls(ttk.Frame):
|
|
def __init__(self, container, image_manager, tooltip_state, import_callback, delete_callback, start_stop_callback, **kwargs):
|
|
super().__init__(container, **kwargs)
|
|
self.image_manager = image_manager
|
|
self.tooltip_state = tooltip_state
|
|
|
|
self.columnconfigure(0, weight=1)
|
|
self.rowconfigure(0, weight=1)
|
|
self.rowconfigure(1, weight=1)
|
|
self.rowconfigure(2, weight=1)
|
|
self.rowconfigure(3, weight=1)
|
|
|
|
self.btn_stst = ttk.Button(
|
|
self,
|
|
image=self.image_manager.get_icon("vpn_start_large"),
|
|
command=start_stop_callback,
|
|
padding=0,
|
|
)
|
|
self.btn_stst.grid(column=0, row=0, sticky="ew")
|
|
Tooltip(self.btn_stst, Msg.TTIP["start_tl"],
|
|
state_var=self.tooltip_state)
|
|
|
|
self.btn_i = ttk.Button(
|
|
self,
|
|
image=self.image_manager.get_icon("import_large"),
|
|
command=import_callback,
|
|
padding=0,
|
|
)
|
|
self.btn_i.grid(column=0, row=1, sticky="ew")
|
|
Tooltip(self.btn_i, Msg.TTIP["import_tl"],
|
|
state_var=self.tooltip_state)
|
|
|
|
self.btn_tr = ttk.Button(
|
|
self,
|
|
image=self.image_manager.get_icon("trash_large"),
|
|
command=delete_callback,
|
|
padding=0,
|
|
)
|
|
self.btn_tr.grid(column=0, row=2, sticky="ew")
|
|
Tooltip(self.btn_tr, Msg.TTIP["trash_tl"],
|
|
state_var=self.tooltip_state)
|
|
|
|
self.btn_exp = ttk.Button(
|
|
self,
|
|
image=self.image_manager.get_icon("export_large"),
|
|
command=lambda: Tunnel.export(),
|
|
padding=0,
|
|
)
|
|
self.btn_exp.grid(column=0, row=3, sticky="ew")
|
|
Tooltip(self.btn_exp, Msg.TTIP["export_tl"],
|
|
state_var=self.tooltip_state)
|
|
|
|
def set_start_stop_button_state(self, is_active, list_box_size):
|
|
if is_active:
|
|
self.btn_stst.config(
|
|
image=self.image_manager.get_icon("vpn_stop_large"))
|
|
Tooltip(self.btn_stst,
|
|
Msg.TTIP["stop_tl"], state_var=self.tooltip_state)
|
|
else:
|
|
self.btn_stst.config(
|
|
image=self.image_manager.get_icon("vpn_start_large"))
|
|
if list_box_size == 0:
|
|
Tooltip(self.btn_stst,
|
|
Msg.TTIP["empty_list"], state_var=self.tooltip_state)
|
|
else:
|
|
Tooltip(self.btn_stst,
|
|
Msg.TTIP["start_tl"], state_var=self.tooltip_state)
|
|
|
|
def update_tooltips(self, list_box_size):
|
|
if list_box_size == 0:
|
|
Tooltip(self.btn_tr,
|
|
Msg.TTIP["trash_tl_info"], state_var=self.tooltip_state)
|
|
Tooltip(self.btn_exp,
|
|
Msg.TTIP["export_tl_info"], state_var=self.tooltip_state)
|
|
else:
|
|
Tooltip(self.btn_tr, Msg.TTIP["trash_tl"],
|
|
state_var=self.tooltip_state)
|
|
Tooltip(self.btn_exp,
|
|
Msg.TTIP["export_tl"], state_var=self.tooltip_state)
|