2020-02-25 19:38:58 +00:00
|
|
|
import logging
|
2019-11-11 18:57:26 +00:00
|
|
|
import tkinter as tk
|
2021-03-19 23:54:24 +00:00
|
|
|
from pathlib import Path
|
2020-02-26 18:43:01 +00:00
|
|
|
from tkinter import filedialog, ttk
|
2020-06-22 19:04:33 +01:00
|
|
|
from typing import TYPE_CHECKING, Dict, List, Optional, Set, Tuple
|
2019-11-11 18:57:26 +00:00
|
|
|
|
2019-12-10 06:50:26 +00:00
|
|
|
import grpc
|
2020-06-22 19:04:33 +01:00
|
|
|
from PIL.ImageTk import PhotoImage
|
2019-12-10 06:50:26 +00:00
|
|
|
|
2021-04-24 06:51:35 +01:00
|
|
|
from core.api.grpc.wrappers import Node, NodeServiceData, ServiceValidationMode
|
2021-02-19 05:04:16 +00:00
|
|
|
from core.gui import images
|
2020-01-09 00:48:04 +00:00
|
|
|
from core.gui.dialogs.copyserviceconfig import CopyServiceConfigDialog
|
2019-12-19 17:30:21 +00:00
|
|
|
from core.gui.dialogs.dialog import Dialog
|
2021-02-19 05:04:16 +00:00
|
|
|
from core.gui.images import ImageEnum
|
2019-12-19 17:30:21 +00:00
|
|
|
from core.gui.themes import FRAME_PAD, PADX, PADY
|
|
|
|
from core.gui.widgets import CodeText, ListboxScroll
|
2019-11-11 18:57:26 +00:00
|
|
|
|
2021-04-22 05:09:35 +01:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2020-01-13 23:31:41 +00:00
|
|
|
if TYPE_CHECKING:
|
|
|
|
from core.gui.app import Application
|
2020-06-22 19:04:33 +01:00
|
|
|
from core.gui.coreclient import CoreClient
|
2020-01-13 23:31:41 +00:00
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
ICON_SIZE: int = 16
|
2020-05-19 07:25:42 +01:00
|
|
|
|
2019-11-11 18:57:26 +00:00
|
|
|
|
2019-12-19 17:50:58 +00:00
|
|
|
class ServiceConfigDialog(Dialog):
|
2020-01-14 19:06:52 +00:00
|
|
|
def __init__(
|
2020-07-28 08:03:15 +01:00
|
|
|
self, master: tk.BaseWidget, app: "Application", service_name: str, node: Node
|
2020-06-22 19:04:33 +01:00
|
|
|
) -> None:
|
2019-12-12 00:21:37 +00:00
|
|
|
title = f"{service_name} Service"
|
2020-05-05 06:50:59 +01:00
|
|
|
super().__init__(app, title, master=master)
|
2020-06-22 19:04:33 +01:00
|
|
|
self.core: "CoreClient" = app.core
|
2020-07-28 08:03:15 +01:00
|
|
|
self.node: Node = node
|
2020-06-22 19:04:33 +01:00
|
|
|
self.service_name: str = service_name
|
|
|
|
self.radiovar: tk.IntVar = tk.IntVar(value=2)
|
|
|
|
self.metadata: str = ""
|
|
|
|
self.filenames: List[str] = []
|
|
|
|
self.dependencies: List[str] = []
|
|
|
|
self.executables: List[str] = []
|
|
|
|
self.startup_commands: List[str] = []
|
|
|
|
self.validation_commands: List[str] = []
|
|
|
|
self.shutdown_commands: List[str] = []
|
|
|
|
self.default_startup: List[str] = []
|
|
|
|
self.default_validate: List[str] = []
|
|
|
|
self.default_shutdown: List[str] = []
|
|
|
|
self.validation_mode: Optional[ServiceValidationMode] = None
|
|
|
|
self.validation_time: Optional[int] = None
|
|
|
|
self.validation_period: Optional[float] = None
|
|
|
|
self.directory_entry: Optional[ttk.Entry] = None
|
|
|
|
self.default_directories: List[str] = []
|
|
|
|
self.temp_directories: List[str] = []
|
2021-02-19 17:31:58 +00:00
|
|
|
self.documentnew_img: PhotoImage = self.app.get_enum_icon(
|
2021-02-19 07:07:55 +00:00
|
|
|
ImageEnum.DOCUMENTNEW, width=ICON_SIZE
|
2020-06-22 19:04:33 +01:00
|
|
|
)
|
2021-02-19 17:31:58 +00:00
|
|
|
self.editdelete_img: PhotoImage = self.app.get_enum_icon(
|
2021-02-19 07:07:55 +00:00
|
|
|
ImageEnum.EDITDELETE, width=ICON_SIZE
|
2020-06-22 19:04:33 +01:00
|
|
|
)
|
|
|
|
self.notebook: Optional[ttk.Notebook] = None
|
|
|
|
self.metadata_entry: Optional[ttk.Entry] = None
|
|
|
|
self.filename_combobox: Optional[ttk.Combobox] = None
|
|
|
|
self.dir_list: Optional[ListboxScroll] = None
|
|
|
|
self.startup_commands_listbox: Optional[tk.Listbox] = None
|
|
|
|
self.shutdown_commands_listbox: Optional[tk.Listbox] = None
|
|
|
|
self.validate_commands_listbox: Optional[tk.Listbox] = None
|
|
|
|
self.validation_time_entry: Optional[ttk.Entry] = None
|
|
|
|
self.validation_mode_entry: Optional[ttk.Entry] = None
|
|
|
|
self.service_file_data: Optional[CodeText] = None
|
|
|
|
self.validation_period_entry: Optional[ttk.Entry] = None
|
|
|
|
self.original_service_files: Dict[str, str] = {}
|
2020-07-26 04:27:11 +01:00
|
|
|
self.default_config: Optional[NodeServiceData] = None
|
2020-06-22 19:04:33 +01:00
|
|
|
self.temp_service_files: Dict[str, str] = {}
|
|
|
|
self.modified_files: Set[str] = set()
|
|
|
|
self.has_error: bool = False
|
2020-02-05 23:53:14 +00:00
|
|
|
self.load()
|
|
|
|
if not self.has_error:
|
2020-02-05 23:09:33 +00:00
|
|
|
self.draw()
|
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def load(self) -> None:
|
2019-12-10 06:50:26 +00:00
|
|
|
try:
|
2021-04-27 18:49:52 +01:00
|
|
|
self.core.start_session(definition=True)
|
2020-01-07 20:32:45 +00:00
|
|
|
default_config = self.app.core.get_node_service(
|
2020-07-28 08:03:15 +01:00
|
|
|
self.node.id, self.service_name
|
2020-01-07 20:32:45 +00:00
|
|
|
)
|
2020-01-07 21:36:04 +00:00
|
|
|
self.default_startup = default_config.startup[:]
|
|
|
|
self.default_validate = default_config.validate[:]
|
|
|
|
self.default_shutdown = default_config.shutdown[:]
|
2020-02-26 18:43:01 +00:00
|
|
|
self.default_directories = default_config.dirs[:]
|
2020-07-28 08:03:15 +01:00
|
|
|
custom_service_config = self.node.service_configs.get(self.service_name)
|
2020-02-27 18:57:22 +00:00
|
|
|
self.default_config = default_config
|
2020-02-26 23:43:31 +00:00
|
|
|
service_config = (
|
|
|
|
custom_service_config if custom_service_config else default_config
|
|
|
|
)
|
2020-01-07 20:32:45 +00:00
|
|
|
self.dependencies = service_config.dependencies[:]
|
|
|
|
self.executables = service_config.executables[:]
|
2019-12-10 06:50:26 +00:00
|
|
|
self.metadata = service_config.meta
|
2020-01-07 20:32:45 +00:00
|
|
|
self.filenames = service_config.configs[:]
|
|
|
|
self.startup_commands = service_config.startup[:]
|
|
|
|
self.validation_commands = service_config.validate[:]
|
|
|
|
self.shutdown_commands = service_config.shutdown[:]
|
2019-12-10 06:50:26 +00:00
|
|
|
self.validation_mode = service_config.validation_mode
|
|
|
|
self.validation_time = service_config.validation_timer
|
2020-02-26 18:43:01 +00:00
|
|
|
self.temp_directories = service_config.dirs[:]
|
2019-12-10 06:50:26 +00:00
|
|
|
self.original_service_files = {
|
|
|
|
x: self.app.core.get_node_service_file(
|
2020-07-28 08:03:15 +01:00
|
|
|
self.node.id, self.service_name, x
|
2019-12-10 06:50:26 +00:00
|
|
|
)
|
2020-02-26 16:31:28 +00:00
|
|
|
for x in default_config.configs
|
2019-12-10 06:50:26 +00:00
|
|
|
}
|
2020-01-07 20:32:45 +00:00
|
|
|
self.temp_service_files = dict(self.original_service_files)
|
2020-04-21 18:31:20 +01:00
|
|
|
|
2020-07-28 08:03:15 +01:00
|
|
|
file_configs = self.node.service_file_configs.get(self.service_name, {})
|
2020-04-21 18:31:20 +01:00
|
|
|
for file, data in file_configs.items():
|
2020-02-26 23:43:31 +00:00
|
|
|
self.temp_service_files[file] = data
|
2019-12-10 06:50:26 +00:00
|
|
|
except grpc.RpcError as e:
|
2020-05-03 20:42:56 +01:00
|
|
|
self.app.show_grpc_exception("Get Node Service Error", e)
|
2020-02-05 23:53:14 +00:00
|
|
|
self.has_error = True
|
2019-11-13 17:09:53 +00:00
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def draw(self) -> None:
|
2019-12-12 00:21:37 +00:00
|
|
|
self.top.columnconfigure(0, weight=1)
|
|
|
|
self.top.rowconfigure(1, weight=1)
|
|
|
|
|
|
|
|
# draw metadata
|
2019-11-13 18:45:43 +00:00
|
|
|
frame = ttk.Frame(self.top)
|
2020-08-02 18:36:14 +01:00
|
|
|
frame.grid(sticky=tk.EW, pady=PADY)
|
2019-12-12 00:21:37 +00:00
|
|
|
frame.columnconfigure(1, weight=1)
|
|
|
|
label = ttk.Label(frame, text="Meta-data")
|
2020-08-02 18:36:14 +01:00
|
|
|
label.grid(row=0, column=0, sticky=tk.W, padx=PADX)
|
2019-12-12 00:21:37 +00:00
|
|
|
self.metadata_entry = ttk.Entry(frame, textvariable=self.metadata)
|
2020-08-02 18:36:14 +01:00
|
|
|
self.metadata_entry.grid(row=0, column=1, sticky=tk.EW)
|
2019-11-13 17:30:49 +00:00
|
|
|
|
2019-12-12 00:21:37 +00:00
|
|
|
# draw notebook
|
|
|
|
self.notebook = ttk.Notebook(self.top)
|
2020-08-02 18:36:14 +01:00
|
|
|
self.notebook.grid(sticky=tk.NSEW, pady=PADY)
|
2019-12-12 00:21:37 +00:00
|
|
|
self.draw_tab_files()
|
|
|
|
self.draw_tab_directories()
|
|
|
|
self.draw_tab_startstop()
|
|
|
|
self.draw_tab_configuration()
|
2019-11-11 18:57:26 +00:00
|
|
|
|
2019-12-12 00:21:37 +00:00
|
|
|
self.draw_buttons()
|
2019-11-11 18:57:26 +00:00
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def draw_tab_files(self) -> None:
|
2019-12-12 00:21:37 +00:00
|
|
|
tab = ttk.Frame(self.notebook, padding=FRAME_PAD)
|
2020-08-02 18:36:14 +01:00
|
|
|
tab.grid(sticky=tk.NSEW)
|
2019-12-12 00:21:37 +00:00
|
|
|
tab.columnconfigure(0, weight=1)
|
|
|
|
self.notebook.add(tab, text="Files")
|
2019-11-11 18:57:26 +00:00
|
|
|
|
2019-11-13 16:38:08 +00:00
|
|
|
label = ttk.Label(
|
2019-12-12 00:21:37 +00:00
|
|
|
tab, text="Config files and scripts that are generated for this service."
|
2019-11-11 18:57:26 +00:00
|
|
|
)
|
2019-12-12 00:21:37 +00:00
|
|
|
label.grid()
|
2019-11-11 18:57:26 +00:00
|
|
|
|
2019-12-12 00:21:37 +00:00
|
|
|
frame = ttk.Frame(tab)
|
2020-08-02 18:36:14 +01:00
|
|
|
frame.grid(sticky=tk.EW, pady=PADY)
|
2019-12-12 00:21:37 +00:00
|
|
|
frame.columnconfigure(1, weight=1)
|
|
|
|
label = ttk.Label(frame, text="File Name")
|
2020-08-02 18:36:14 +01:00
|
|
|
label.grid(row=0, column=0, padx=PADX, sticky=tk.W)
|
2020-02-25 19:38:58 +00:00
|
|
|
self.filename_combobox = ttk.Combobox(frame, values=self.filenames)
|
2019-11-13 17:09:53 +00:00
|
|
|
self.filename_combobox.bind(
|
|
|
|
"<<ComboboxSelected>>", self.display_service_file_data
|
|
|
|
)
|
2020-08-02 18:36:14 +01:00
|
|
|
self.filename_combobox.grid(row=0, column=1, sticky=tk.EW, padx=PADX)
|
2020-02-25 19:38:58 +00:00
|
|
|
button = ttk.Button(
|
|
|
|
frame, image=self.documentnew_img, command=self.add_filename
|
|
|
|
)
|
2019-12-12 00:21:37 +00:00
|
|
|
button.grid(row=0, column=2, padx=PADX)
|
2020-02-26 16:31:28 +00:00
|
|
|
button = ttk.Button(
|
|
|
|
frame, image=self.editdelete_img, command=self.delete_filename
|
|
|
|
)
|
2019-11-11 18:57:26 +00:00
|
|
|
button.grid(row=0, column=3)
|
|
|
|
|
2019-12-12 00:21:37 +00:00
|
|
|
frame = ttk.Frame(tab)
|
2020-08-02 18:36:14 +01:00
|
|
|
frame.grid(sticky=tk.EW, pady=PADY)
|
2019-12-12 00:21:37 +00:00
|
|
|
frame.columnconfigure(1, weight=1)
|
2019-11-13 16:38:08 +00:00
|
|
|
button = ttk.Radiobutton(
|
2019-11-11 18:57:26 +00:00
|
|
|
frame,
|
|
|
|
variable=self.radiovar,
|
2019-12-12 00:21:37 +00:00
|
|
|
text="Copy Source File",
|
2019-11-12 00:34:41 +00:00
|
|
|
value=1,
|
2019-12-12 00:21:37 +00:00
|
|
|
state=tk.DISABLED,
|
2019-11-11 18:57:26 +00:00
|
|
|
)
|
2020-08-02 18:36:14 +01:00
|
|
|
button.grid(row=0, column=0, sticky=tk.W, padx=PADX)
|
2019-11-13 16:38:08 +00:00
|
|
|
entry = ttk.Entry(frame, state=tk.DISABLED)
|
2020-08-02 18:36:14 +01:00
|
|
|
entry.grid(row=0, column=1, sticky=tk.EW, padx=PADX)
|
2021-02-19 05:04:16 +00:00
|
|
|
image = images.from_enum(ImageEnum.FILEOPEN, width=images.BUTTON_SIZE)
|
2019-11-13 16:38:08 +00:00
|
|
|
button = ttk.Button(frame, image=image)
|
|
|
|
button.image = image
|
2019-11-11 18:57:26 +00:00
|
|
|
button.grid(row=0, column=2)
|
|
|
|
|
2019-12-12 00:21:37 +00:00
|
|
|
frame = ttk.Frame(tab)
|
2020-08-02 18:36:14 +01:00
|
|
|
frame.grid(sticky=tk.EW, pady=PADY)
|
2019-12-12 00:21:37 +00:00
|
|
|
frame.columnconfigure(0, weight=1)
|
2019-11-13 16:38:08 +00:00
|
|
|
button = ttk.Radiobutton(
|
2019-11-11 18:57:26 +00:00
|
|
|
frame,
|
|
|
|
variable=self.radiovar,
|
2019-12-12 00:21:37 +00:00
|
|
|
text="Use text below for file contents",
|
2019-11-12 00:34:41 +00:00
|
|
|
value=2,
|
2019-11-11 18:57:26 +00:00
|
|
|
)
|
2020-08-02 18:36:14 +01:00
|
|
|
button.grid(row=0, column=0, sticky=tk.EW)
|
2021-02-19 05:04:16 +00:00
|
|
|
image = images.from_enum(ImageEnum.FILEOPEN, width=images.BUTTON_SIZE)
|
2019-11-13 16:38:08 +00:00
|
|
|
button = ttk.Button(frame, image=image)
|
|
|
|
button.image = image
|
2019-11-11 18:57:26 +00:00
|
|
|
button.grid(row=0, column=1)
|
2021-02-19 05:04:16 +00:00
|
|
|
image = images.from_enum(ImageEnum.DOCUMENTSAVE, width=images.BUTTON_SIZE)
|
2019-11-13 16:38:08 +00:00
|
|
|
button = ttk.Button(frame, image=image)
|
|
|
|
button.image = image
|
2019-11-11 18:57:26 +00:00
|
|
|
button.grid(row=0, column=2)
|
|
|
|
|
2019-12-12 00:21:37 +00:00
|
|
|
self.service_file_data = CodeText(tab)
|
2020-08-02 18:36:14 +01:00
|
|
|
self.service_file_data.grid(sticky=tk.NSEW)
|
2019-12-12 00:21:37 +00:00
|
|
|
tab.rowconfigure(self.service_file_data.grid_info()["row"], weight=1)
|
2019-11-14 23:20:07 +00:00
|
|
|
if len(self.filenames) > 0:
|
|
|
|
self.filename_combobox.current(0)
|
2019-12-17 18:01:25 +00:00
|
|
|
self.service_file_data.text.delete(1.0, "end")
|
|
|
|
self.service_file_data.text.insert(
|
2019-11-16 01:05:03 +00:00
|
|
|
"end", self.temp_service_files[self.filenames[0]]
|
|
|
|
)
|
2019-12-17 18:01:25 +00:00
|
|
|
self.service_file_data.text.bind(
|
|
|
|
"<FocusOut>", self.update_temp_service_file_data
|
|
|
|
)
|
2019-11-13 18:51:16 +00:00
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def draw_tab_directories(self) -> None:
|
2019-12-12 00:21:37 +00:00
|
|
|
tab = ttk.Frame(self.notebook, padding=FRAME_PAD)
|
2020-08-02 18:36:14 +01:00
|
|
|
tab.grid(sticky=tk.NSEW)
|
2019-12-12 00:21:37 +00:00
|
|
|
tab.columnconfigure(0, weight=1)
|
2020-04-23 17:06:56 +01:00
|
|
|
tab.rowconfigure(2, weight=1)
|
2019-12-12 00:21:37 +00:00
|
|
|
self.notebook.add(tab, text="Directories")
|
|
|
|
|
2019-11-13 16:38:08 +00:00
|
|
|
label = ttk.Label(
|
2019-12-12 00:21:37 +00:00
|
|
|
tab,
|
2019-11-11 18:57:26 +00:00
|
|
|
text="Directories required by this service that are unique for each node.",
|
|
|
|
)
|
2020-08-02 18:36:14 +01:00
|
|
|
label.grid(row=0, column=0, sticky=tk.EW)
|
2020-02-26 18:43:01 +00:00
|
|
|
frame = ttk.Frame(tab, padding=FRAME_PAD)
|
|
|
|
frame.columnconfigure(0, weight=1)
|
2020-08-02 18:36:14 +01:00
|
|
|
frame.grid(row=1, column=0, sticky=tk.NSEW)
|
2020-02-26 18:43:01 +00:00
|
|
|
var = tk.StringVar(value="")
|
|
|
|
self.directory_entry = ttk.Entry(frame, textvariable=var)
|
2020-08-02 18:36:14 +01:00
|
|
|
self.directory_entry.grid(row=0, column=0, sticky=tk.EW, padx=PADX)
|
2020-02-26 18:43:01 +00:00
|
|
|
button = ttk.Button(frame, text="...", command=self.find_directory_button)
|
2020-08-02 18:36:14 +01:00
|
|
|
button.grid(row=0, column=1, sticky=tk.EW)
|
2020-02-26 18:43:01 +00:00
|
|
|
self.dir_list = ListboxScroll(tab)
|
2020-08-02 18:36:14 +01:00
|
|
|
self.dir_list.grid(row=2, column=0, sticky=tk.NSEW, pady=PADY)
|
2020-02-26 18:43:01 +00:00
|
|
|
self.dir_list.listbox.bind("<<ListboxSelect>>", self.directory_select)
|
|
|
|
for d in self.temp_directories:
|
|
|
|
self.dir_list.listbox.insert("end", d)
|
|
|
|
|
|
|
|
frame = ttk.Frame(tab)
|
2020-08-02 18:36:14 +01:00
|
|
|
frame.grid(row=3, column=0, sticky=tk.NSEW)
|
2020-02-26 18:43:01 +00:00
|
|
|
frame.columnconfigure(0, weight=1)
|
|
|
|
frame.columnconfigure(1, weight=1)
|
|
|
|
button = ttk.Button(frame, text="Add", command=self.add_directory)
|
2020-08-02 18:36:14 +01:00
|
|
|
button.grid(row=0, column=0, sticky=tk.EW, padx=PADX)
|
2020-02-26 18:43:01 +00:00
|
|
|
button = ttk.Button(frame, text="Remove", command=self.remove_directory)
|
2020-08-02 18:36:14 +01:00
|
|
|
button.grid(row=0, column=1, sticky=tk.EW)
|
2019-12-12 00:21:37 +00:00
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def draw_tab_startstop(self) -> None:
|
2019-12-12 00:21:37 +00:00
|
|
|
tab = ttk.Frame(self.notebook, padding=FRAME_PAD)
|
2020-08-02 18:36:14 +01:00
|
|
|
tab.grid(sticky=tk.NSEW)
|
2019-12-12 00:21:37 +00:00
|
|
|
tab.columnconfigure(0, weight=1)
|
|
|
|
for i in range(3):
|
|
|
|
tab.rowconfigure(i, weight=1)
|
2019-12-16 22:17:05 +00:00
|
|
|
self.notebook.add(tab, text="Startup/Shutdown")
|
2020-01-14 19:06:52 +00:00
|
|
|
commands = []
|
2019-11-11 18:57:26 +00:00
|
|
|
# tab 3
|
2019-11-12 00:34:41 +00:00
|
|
|
for i in range(3):
|
|
|
|
label_frame = None
|
|
|
|
if i == 0:
|
2019-12-12 00:21:37 +00:00
|
|
|
label_frame = ttk.LabelFrame(
|
2019-12-16 22:17:05 +00:00
|
|
|
tab, text="Startup Commands", padding=FRAME_PAD
|
2019-12-12 00:21:37 +00:00
|
|
|
)
|
2019-11-13 17:09:53 +00:00
|
|
|
commands = self.startup_commands
|
2019-11-12 00:34:41 +00:00
|
|
|
elif i == 1:
|
2019-12-12 00:21:37 +00:00
|
|
|
label_frame = ttk.LabelFrame(
|
2019-12-16 22:17:05 +00:00
|
|
|
tab, text="Shutdown Commands", padding=FRAME_PAD
|
2019-12-12 00:21:37 +00:00
|
|
|
)
|
2019-11-13 17:09:53 +00:00
|
|
|
commands = self.shutdown_commands
|
2019-11-12 00:34:41 +00:00
|
|
|
elif i == 2:
|
2019-12-12 00:21:37 +00:00
|
|
|
label_frame = ttk.LabelFrame(
|
2019-12-16 22:17:05 +00:00
|
|
|
tab, text="Validation Commands", padding=FRAME_PAD
|
2019-12-12 00:21:37 +00:00
|
|
|
)
|
2019-11-13 17:09:53 +00:00
|
|
|
commands = self.validation_commands
|
2019-11-12 00:34:41 +00:00
|
|
|
label_frame.columnconfigure(0, weight=1)
|
2019-12-12 00:21:37 +00:00
|
|
|
label_frame.rowconfigure(1, weight=1)
|
2020-08-02 18:36:14 +01:00
|
|
|
label_frame.grid(row=i, column=0, sticky=tk.NSEW, pady=PADY)
|
2019-12-12 00:21:37 +00:00
|
|
|
|
2019-11-13 16:38:08 +00:00
|
|
|
frame = ttk.Frame(label_frame)
|
2020-08-02 18:36:14 +01:00
|
|
|
frame.grid(row=0, column=0, sticky=tk.NSEW, pady=PADY)
|
2019-11-12 00:34:41 +00:00
|
|
|
frame.columnconfigure(0, weight=1)
|
2019-11-13 16:38:08 +00:00
|
|
|
entry = ttk.Entry(frame, textvariable=tk.StringVar())
|
2019-12-12 00:21:37 +00:00
|
|
|
entry.grid(row=0, column=0, stick="ew", padx=PADX)
|
2019-11-13 16:38:08 +00:00
|
|
|
button = ttk.Button(frame, image=self.documentnew_img)
|
2019-11-12 00:34:41 +00:00
|
|
|
button.bind("<Button-1>", self.add_command)
|
2020-08-02 18:36:14 +01:00
|
|
|
button.grid(row=0, column=1, sticky=tk.EW, padx=PADX)
|
2019-11-13 16:38:08 +00:00
|
|
|
button = ttk.Button(frame, image=self.editdelete_img)
|
2020-08-02 18:36:14 +01:00
|
|
|
button.grid(row=0, column=2, sticky=tk.EW)
|
2019-11-12 00:34:41 +00:00
|
|
|
button.bind("<Button-1>", self.delete_command)
|
2019-12-16 22:17:05 +00:00
|
|
|
listbox_scroll = ListboxScroll(label_frame)
|
2019-11-12 00:34:41 +00:00
|
|
|
listbox_scroll.listbox.bind("<<ListboxSelect>>", self.update_entry)
|
2019-11-13 17:09:53 +00:00
|
|
|
for command in commands:
|
|
|
|
listbox_scroll.listbox.insert("end", command)
|
2019-11-12 00:34:41 +00:00
|
|
|
listbox_scroll.listbox.config(height=4)
|
2020-08-02 18:36:14 +01:00
|
|
|
listbox_scroll.grid(row=1, column=0, sticky=tk.NSEW)
|
2019-11-12 00:34:41 +00:00
|
|
|
if i == 0:
|
|
|
|
self.startup_commands_listbox = listbox_scroll.listbox
|
|
|
|
elif i == 1:
|
|
|
|
self.shutdown_commands_listbox = listbox_scroll.listbox
|
|
|
|
elif i == 2:
|
|
|
|
self.validate_commands_listbox = listbox_scroll.listbox
|
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def draw_tab_configuration(self) -> None:
|
2019-12-12 00:21:37 +00:00
|
|
|
tab = ttk.Frame(self.notebook, padding=FRAME_PAD)
|
2020-08-02 18:36:14 +01:00
|
|
|
tab.grid(sticky=tk.NSEW)
|
2019-12-12 00:21:37 +00:00
|
|
|
tab.columnconfigure(0, weight=1)
|
2020-08-02 18:36:14 +01:00
|
|
|
self.notebook.add(tab, text="Configuration", sticky=tk.NSEW)
|
2019-11-12 00:34:41 +00:00
|
|
|
|
2019-12-12 00:21:37 +00:00
|
|
|
frame = ttk.Frame(tab)
|
2020-08-02 18:36:14 +01:00
|
|
|
frame.grid(sticky=tk.EW, pady=PADY)
|
2019-12-12 00:21:37 +00:00
|
|
|
frame.columnconfigure(1, weight=1)
|
2019-11-11 18:57:26 +00:00
|
|
|
|
2019-12-12 00:21:37 +00:00
|
|
|
label = ttk.Label(frame, text="Validation Time")
|
2020-08-02 18:36:14 +01:00
|
|
|
label.grid(row=0, column=0, sticky=tk.W, padx=PADX)
|
2019-12-12 00:21:37 +00:00
|
|
|
self.validation_time_entry = ttk.Entry(frame)
|
|
|
|
self.validation_time_entry.insert("end", self.validation_time)
|
|
|
|
self.validation_time_entry.config(state=tk.DISABLED)
|
2020-08-02 18:36:14 +01:00
|
|
|
self.validation_time_entry.grid(row=0, column=1, sticky=tk.EW, pady=PADY)
|
2019-12-12 00:21:37 +00:00
|
|
|
|
|
|
|
label = ttk.Label(frame, text="Validation Mode")
|
2020-08-02 18:36:14 +01:00
|
|
|
label.grid(row=1, column=0, sticky=tk.W, padx=PADX)
|
2020-03-23 05:57:50 +00:00
|
|
|
if self.validation_mode == ServiceValidationMode.BLOCKING:
|
2019-12-12 00:21:37 +00:00
|
|
|
mode = "BLOCKING"
|
2020-03-23 05:57:50 +00:00
|
|
|
elif self.validation_mode == ServiceValidationMode.NON_BLOCKING:
|
2019-12-12 00:21:37 +00:00
|
|
|
mode = "NON_BLOCKING"
|
|
|
|
else:
|
|
|
|
mode = "TIMER"
|
|
|
|
self.validation_mode_entry = ttk.Entry(
|
|
|
|
frame, textvariable=tk.StringVar(value=mode)
|
2019-11-11 18:57:26 +00:00
|
|
|
)
|
2019-12-12 00:21:37 +00:00
|
|
|
self.validation_mode_entry.insert("end", mode)
|
|
|
|
self.validation_mode_entry.config(state=tk.DISABLED)
|
2020-08-02 18:36:14 +01:00
|
|
|
self.validation_mode_entry.grid(row=1, column=1, sticky=tk.EW, pady=PADY)
|
2019-12-12 00:21:37 +00:00
|
|
|
|
|
|
|
label = ttk.Label(frame, text="Validation Period")
|
2020-08-02 18:36:14 +01:00
|
|
|
label.grid(row=2, column=0, sticky=tk.W, padx=PADX)
|
2019-12-12 00:21:37 +00:00
|
|
|
self.validation_period_entry = ttk.Entry(
|
|
|
|
frame, state=tk.DISABLED, textvariable=tk.StringVar()
|
|
|
|
)
|
2020-08-02 18:36:14 +01:00
|
|
|
self.validation_period_entry.grid(row=2, column=1, sticky=tk.EW, pady=PADY)
|
2019-12-12 00:21:37 +00:00
|
|
|
|
2019-12-16 22:17:05 +00:00
|
|
|
label_frame = ttk.LabelFrame(tab, text="Executables", padding=FRAME_PAD)
|
2020-08-02 18:36:14 +01:00
|
|
|
label_frame.grid(sticky=tk.NSEW, pady=PADY)
|
2019-12-16 22:17:05 +00:00
|
|
|
label_frame.columnconfigure(0, weight=1)
|
|
|
|
label_frame.rowconfigure(0, weight=1)
|
|
|
|
listbox_scroll = ListboxScroll(label_frame)
|
2020-08-02 18:36:14 +01:00
|
|
|
listbox_scroll.grid(sticky=tk.NSEW)
|
2019-12-12 00:21:37 +00:00
|
|
|
tab.rowconfigure(listbox_scroll.grid_info()["row"], weight=1)
|
|
|
|
for executable in self.executables:
|
|
|
|
listbox_scroll.listbox.insert("end", executable)
|
|
|
|
|
2019-12-16 22:17:05 +00:00
|
|
|
label_frame = ttk.LabelFrame(tab, text="Dependencies", padding=FRAME_PAD)
|
2020-08-02 18:36:14 +01:00
|
|
|
label_frame.grid(sticky=tk.NSEW, pady=PADY)
|
2019-12-16 22:17:05 +00:00
|
|
|
label_frame.columnconfigure(0, weight=1)
|
|
|
|
label_frame.rowconfigure(0, weight=1)
|
|
|
|
listbox_scroll = ListboxScroll(label_frame)
|
2020-08-02 18:36:14 +01:00
|
|
|
listbox_scroll.grid(sticky=tk.NSEW)
|
2019-12-12 00:21:37 +00:00
|
|
|
tab.rowconfigure(listbox_scroll.grid_info()["row"], weight=1)
|
|
|
|
for dependency in self.dependencies:
|
|
|
|
listbox_scroll.listbox.insert("end", dependency)
|
2019-11-11 18:57:26 +00:00
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def draw_buttons(self) -> None:
|
2019-11-13 18:45:43 +00:00
|
|
|
frame = ttk.Frame(self.top)
|
2020-08-02 18:36:14 +01:00
|
|
|
frame.grid(sticky=tk.EW)
|
2019-12-12 00:21:37 +00:00
|
|
|
for i in range(4):
|
|
|
|
frame.columnconfigure(i, weight=1)
|
2019-11-13 16:38:08 +00:00
|
|
|
button = ttk.Button(frame, text="Apply", command=self.click_apply)
|
2020-08-02 18:36:14 +01:00
|
|
|
button.grid(row=0, column=0, sticky=tk.EW, padx=PADX)
|
2020-01-07 20:32:45 +00:00
|
|
|
button = ttk.Button(frame, text="Defaults", command=self.click_defaults)
|
2020-08-02 18:36:14 +01:00
|
|
|
button.grid(row=0, column=1, sticky=tk.EW, padx=PADX)
|
2020-01-09 00:48:04 +00:00
|
|
|
button = ttk.Button(frame, text="Copy...", command=self.click_copy)
|
2020-08-02 18:36:14 +01:00
|
|
|
button.grid(row=0, column=2, sticky=tk.EW, padx=PADX)
|
2019-11-13 16:38:08 +00:00
|
|
|
button = ttk.Button(frame, text="Cancel", command=self.destroy)
|
2020-08-02 18:36:14 +01:00
|
|
|
button.grid(row=0, column=3, sticky=tk.EW)
|
2019-11-11 18:57:26 +00:00
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def add_filename(self) -> None:
|
2020-02-25 19:38:58 +00:00
|
|
|
filename = self.filename_combobox.get()
|
|
|
|
if filename not in self.filename_combobox["values"]:
|
|
|
|
self.filename_combobox["values"] += (filename,)
|
|
|
|
self.filename_combobox.set(filename)
|
|
|
|
self.temp_service_files[filename] = self.service_file_data.text.get(
|
|
|
|
1.0, "end"
|
|
|
|
)
|
|
|
|
else:
|
2021-04-22 05:09:35 +01:00
|
|
|
logger.debug("file already existed")
|
2019-11-12 00:34:41 +00:00
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def delete_filename(self) -> None:
|
2020-02-26 16:31:28 +00:00
|
|
|
cbb = self.filename_combobox
|
|
|
|
filename = cbb.get()
|
|
|
|
if filename in cbb["values"]:
|
|
|
|
cbb["values"] = tuple([x for x in cbb["values"] if x != filename])
|
|
|
|
cbb.set("")
|
|
|
|
self.service_file_data.text.delete(1.0, "end")
|
|
|
|
self.temp_service_files.pop(filename, None)
|
|
|
|
if filename in self.modified_files:
|
|
|
|
self.modified_files.remove(filename)
|
2019-11-12 00:34:41 +00:00
|
|
|
|
2020-02-26 16:31:28 +00:00
|
|
|
@classmethod
|
2020-06-22 19:04:33 +01:00
|
|
|
def add_command(cls, event: tk.Event) -> None:
|
2019-11-12 00:34:41 +00:00
|
|
|
frame_contains_button = event.widget.master
|
|
|
|
listbox = frame_contains_button.master.grid_slaves(row=1, column=0)[0].listbox
|
|
|
|
command_to_add = frame_contains_button.grid_slaves(row=0, column=0)[0].get()
|
|
|
|
if command_to_add == "":
|
|
|
|
return
|
|
|
|
for cmd in listbox.get(0, tk.END):
|
|
|
|
if cmd == command_to_add:
|
|
|
|
return
|
|
|
|
listbox.insert(tk.END, command_to_add)
|
|
|
|
|
2020-02-26 16:31:28 +00:00
|
|
|
@classmethod
|
2020-06-22 19:04:33 +01:00
|
|
|
def update_entry(cls, event: tk.Event) -> None:
|
2019-11-12 00:34:41 +00:00
|
|
|
listbox = event.widget
|
|
|
|
current_selection = listbox.curselection()
|
|
|
|
if len(current_selection) > 0:
|
|
|
|
cmd = listbox.get(current_selection[0])
|
|
|
|
entry = listbox.master.master.grid_slaves(row=0, column=0)[0].grid_slaves(
|
|
|
|
row=0, column=0
|
|
|
|
)[0]
|
|
|
|
entry.delete(0, "end")
|
|
|
|
entry.insert(0, cmd)
|
|
|
|
|
2020-02-26 16:31:28 +00:00
|
|
|
@classmethod
|
2020-06-22 19:04:33 +01:00
|
|
|
def delete_command(cls, event: tk.Event) -> None:
|
2019-11-12 00:34:41 +00:00
|
|
|
button = event.widget
|
|
|
|
frame_contains_button = button.master
|
|
|
|
listbox = frame_contains_button.master.grid_slaves(row=1, column=0)[0].listbox
|
|
|
|
current_selection = listbox.curselection()
|
|
|
|
if len(current_selection) > 0:
|
|
|
|
listbox.delete(current_selection[0])
|
|
|
|
entry = frame_contains_button.grid_slaves(row=0, column=0)[0]
|
|
|
|
entry.delete(0, tk.END)
|
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def click_apply(self) -> None:
|
2020-02-25 19:38:58 +00:00
|
|
|
if (
|
2020-02-26 16:31:28 +00:00
|
|
|
not self.is_custom_command()
|
2020-02-25 19:38:58 +00:00
|
|
|
and not self.is_custom_service_file()
|
|
|
|
and not self.has_new_files()
|
2020-02-26 23:43:31 +00:00
|
|
|
and not self.is_custom_directory()
|
2020-02-25 19:38:58 +00:00
|
|
|
):
|
2020-07-28 08:03:15 +01:00
|
|
|
self.node.service_configs.pop(self.service_name, None)
|
2020-02-27 18:57:22 +00:00
|
|
|
self.current_service_color("")
|
2020-01-07 21:36:04 +00:00
|
|
|
self.destroy()
|
|
|
|
return
|
2021-04-24 06:51:35 +01:00
|
|
|
files = set(self.filenames)
|
|
|
|
if (
|
|
|
|
self.is_custom_command()
|
|
|
|
or self.has_new_files()
|
|
|
|
or self.is_custom_directory()
|
|
|
|
):
|
|
|
|
startup, validate, shutdown = self.get_commands()
|
|
|
|
files = set(self.filename_combobox["values"])
|
|
|
|
service_data = NodeServiceData(
|
|
|
|
configs=list(files),
|
|
|
|
dirs=self.temp_directories,
|
|
|
|
startup=startup,
|
|
|
|
validate=validate,
|
|
|
|
shutdown=shutdown,
|
|
|
|
)
|
|
|
|
logger.info("setting service data: %s", service_data)
|
|
|
|
self.node.service_configs[self.service_name] = service_data
|
|
|
|
for file in self.modified_files:
|
|
|
|
if file not in files:
|
|
|
|
continue
|
|
|
|
file_configs = self.node.service_file_configs.setdefault(
|
|
|
|
self.service_name, {}
|
|
|
|
)
|
|
|
|
file_configs[file] = self.temp_service_files[file]
|
|
|
|
self.current_service_color("green")
|
2019-11-16 01:05:03 +00:00
|
|
|
self.destroy()
|
2019-11-13 17:09:53 +00:00
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def display_service_file_data(self, event: tk.Event) -> None:
|
2020-02-26 23:43:31 +00:00
|
|
|
filename = self.filename_combobox.get()
|
2019-12-17 18:01:25 +00:00
|
|
|
self.service_file_data.text.delete(1.0, "end")
|
|
|
|
self.service_file_data.text.insert("end", self.temp_service_files[filename])
|
2019-11-16 01:05:03 +00:00
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def update_temp_service_file_data(self, event: tk.Event) -> None:
|
2019-11-16 01:05:03 +00:00
|
|
|
filename = self.filename_combobox.get()
|
2020-02-26 23:43:31 +00:00
|
|
|
self.temp_service_files[filename] = self.service_file_data.text.get(1.0, "end")
|
2020-02-25 19:38:58 +00:00
|
|
|
if self.temp_service_files[filename] != self.original_service_files.get(
|
|
|
|
filename, ""
|
|
|
|
):
|
2019-11-16 01:05:03 +00:00
|
|
|
self.modified_files.add(filename)
|
|
|
|
else:
|
|
|
|
self.modified_files.discard(filename)
|
2019-11-11 18:57:26 +00:00
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def is_custom_command(self) -> bool:
|
2020-02-26 16:31:28 +00:00
|
|
|
startup, validate, shutdown = self.get_commands()
|
2020-01-07 21:36:04 +00:00
|
|
|
return (
|
2020-02-26 16:31:28 +00:00
|
|
|
set(self.default_startup) != set(startup)
|
|
|
|
or set(self.default_validate) != set(validate)
|
|
|
|
or set(self.default_shutdown) != set(shutdown)
|
2020-01-07 21:36:04 +00:00
|
|
|
)
|
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def has_new_files(self) -> bool:
|
2020-02-25 19:38:58 +00:00
|
|
|
return set(self.filenames) != set(self.filename_combobox["values"])
|
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def is_custom_service_file(self) -> bool:
|
2020-01-09 16:54:15 +00:00
|
|
|
return len(self.modified_files) > 0
|
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def is_custom_directory(self) -> bool:
|
2020-02-26 23:43:31 +00:00
|
|
|
return set(self.default_directories) != set(self.dir_list.listbox.get(0, "end"))
|
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def click_defaults(self) -> None:
|
2020-02-27 18:57:22 +00:00
|
|
|
"""
|
|
|
|
clears out any custom configuration permanently
|
|
|
|
"""
|
|
|
|
# clear coreclient data
|
2020-07-28 08:03:15 +01:00
|
|
|
self.node.service_configs.pop(self.service_name, None)
|
|
|
|
file_configs = self.node.service_file_configs.pop(self.service_name, {})
|
2020-04-21 18:31:20 +01:00
|
|
|
file_configs.pop(self.service_name, None)
|
2020-01-07 20:32:45 +00:00
|
|
|
self.temp_service_files = dict(self.original_service_files)
|
2020-02-27 18:57:22 +00:00
|
|
|
self.modified_files.clear()
|
|
|
|
|
|
|
|
# reset files tab
|
|
|
|
files = list(self.default_config.configs[:])
|
|
|
|
self.filenames = files
|
|
|
|
self.filename_combobox.config(values=files)
|
2020-01-07 20:32:45 +00:00
|
|
|
self.service_file_data.text.delete(1.0, "end")
|
2020-02-27 18:57:22 +00:00
|
|
|
if len(files) > 0:
|
|
|
|
filename = files[0]
|
|
|
|
self.filename_combobox.set(filename)
|
|
|
|
self.service_file_data.text.insert("end", self.temp_service_files[filename])
|
|
|
|
|
|
|
|
# reset commands
|
2020-01-07 20:32:45 +00:00
|
|
|
self.startup_commands_listbox.delete(0, tk.END)
|
|
|
|
self.validate_commands_listbox.delete(0, tk.END)
|
|
|
|
self.shutdown_commands_listbox.delete(0, tk.END)
|
2020-01-07 23:30:19 +00:00
|
|
|
for cmd in self.default_startup:
|
2020-01-07 20:32:45 +00:00
|
|
|
self.startup_commands_listbox.insert(tk.END, cmd)
|
2020-01-07 23:30:19 +00:00
|
|
|
for cmd in self.default_validate:
|
2020-01-07 20:32:45 +00:00
|
|
|
self.validate_commands_listbox.insert(tk.END, cmd)
|
2020-01-07 23:30:19 +00:00
|
|
|
for cmd in self.default_shutdown:
|
2020-01-07 20:32:45 +00:00
|
|
|
self.shutdown_commands_listbox.insert(tk.END, cmd)
|
2019-11-11 18:57:26 +00:00
|
|
|
|
2020-02-27 18:57:22 +00:00
|
|
|
# reset directories
|
|
|
|
self.directory_entry.delete(0, "end")
|
|
|
|
self.dir_list.listbox.delete(0, "end")
|
|
|
|
self.temp_directories = list(self.default_directories)
|
|
|
|
for d in self.default_directories:
|
|
|
|
self.dir_list.listbox.insert("end", d)
|
|
|
|
|
|
|
|
self.current_service_color("")
|
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def click_copy(self) -> None:
|
2020-06-24 00:11:39 +01:00
|
|
|
file_name = self.filename_combobox.get()
|
|
|
|
dialog = CopyServiceConfigDialog(
|
2020-07-28 08:03:15 +01:00
|
|
|
self.app, self, self.node.name, self.service_name, file_name
|
2020-06-24 00:11:39 +01:00
|
|
|
)
|
2020-01-09 00:48:04 +00:00
|
|
|
dialog.show()
|
2020-01-09 16:54:15 +00:00
|
|
|
|
2020-02-26 23:43:31 +00:00
|
|
|
@classmethod
|
2020-01-13 20:03:13 +00:00
|
|
|
def append_commands(
|
2020-02-26 23:43:31 +00:00
|
|
|
cls, commands: List[str], listbox: tk.Listbox, to_add: List[str]
|
2020-06-22 19:04:33 +01:00
|
|
|
) -> None:
|
2020-01-09 16:54:15 +00:00
|
|
|
for cmd in to_add:
|
|
|
|
commands.append(cmd)
|
|
|
|
listbox.insert(tk.END, cmd)
|
2020-02-26 16:31:28 +00:00
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def get_commands(self) -> Tuple[List[str], List[str], List[str]]:
|
2020-02-26 16:31:28 +00:00
|
|
|
startup = self.startup_commands_listbox.get(0, "end")
|
|
|
|
shutdown = self.shutdown_commands_listbox.get(0, "end")
|
|
|
|
validate = self.validate_commands_listbox.get(0, "end")
|
|
|
|
return startup, validate, shutdown
|
2020-02-26 18:43:01 +00:00
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def find_directory_button(self) -> None:
|
2020-02-26 18:43:01 +00:00
|
|
|
d = filedialog.askdirectory(initialdir="/")
|
|
|
|
self.directory_entry.delete(0, "end")
|
|
|
|
self.directory_entry.insert("end", d)
|
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def add_directory(self) -> None:
|
2021-03-19 23:54:24 +00:00
|
|
|
directory = self.directory_entry.get()
|
|
|
|
directory = Path(directory)
|
|
|
|
if directory.is_dir():
|
|
|
|
if str(directory) not in self.temp_directories:
|
|
|
|
self.dir_list.listbox.insert("end", directory)
|
2021-04-24 06:51:35 +01:00
|
|
|
self.temp_directories.append(str(directory))
|
2020-02-26 18:43:01 +00:00
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def remove_directory(self) -> None:
|
2020-02-26 18:43:01 +00:00
|
|
|
d = self.directory_entry.get()
|
|
|
|
dirs = self.dir_list.listbox.get(0, "end")
|
|
|
|
if d and d in self.temp_directories:
|
|
|
|
self.temp_directories.remove(d)
|
|
|
|
try:
|
|
|
|
i = dirs.index(d)
|
|
|
|
self.dir_list.listbox.delete(i)
|
|
|
|
except ValueError:
|
2021-04-22 05:09:35 +01:00
|
|
|
logger.debug("directory is not in the list")
|
2020-02-26 18:43:01 +00:00
|
|
|
self.directory_entry.delete(0, "end")
|
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def directory_select(self, event) -> None:
|
2020-02-26 18:43:01 +00:00
|
|
|
i = self.dir_list.listbox.curselection()
|
|
|
|
if i:
|
|
|
|
d = self.dir_list.listbox.get(i)
|
|
|
|
self.directory_entry.delete(0, "end")
|
|
|
|
self.directory_entry.insert("end", d)
|
2020-02-27 18:57:22 +00:00
|
|
|
|
2020-06-22 19:04:33 +01:00
|
|
|
def current_service_color(self, color="") -> None:
|
2020-02-27 18:57:22 +00:00
|
|
|
"""
|
|
|
|
change the current service label color
|
|
|
|
"""
|
|
|
|
listbox = self.master.current.listbox
|
|
|
|
services = listbox.get(0, tk.END)
|
|
|
|
listbox.itemconfig(services.index(self.service_name), bg=color)
|