pygui: changes to make use of wrapped session object and wrapped nodes to maintain and retrieving configurations information
This commit is contained in:
parent
3bdd6292cd
commit
588afaad13
21 changed files with 284 additions and 455 deletions
|
@ -9,22 +9,21 @@ from core.gui.dialogs.dialog import Dialog
|
|||
from core.gui.dialogs.serviceconfig import ServiceConfigDialog
|
||||
from core.gui.themes import FRAME_PAD, PADX, PADY
|
||||
from core.gui.widgets import CheckboxList, ListboxScroll
|
||||
from core.gui.wrappers import Node
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
from core.gui.graph.node import CanvasNode
|
||||
|
||||
|
||||
class NodeServiceDialog(Dialog):
|
||||
def __init__(self, app: "Application", canvas_node: "CanvasNode") -> None:
|
||||
title = f"{canvas_node.core_node.name} Services"
|
||||
def __init__(self, app: "Application", node: Node) -> None:
|
||||
title = f"{node.name} Services"
|
||||
super().__init__(app, title)
|
||||
self.canvas_node: "CanvasNode" = canvas_node
|
||||
self.node_id: int = canvas_node.core_node.id
|
||||
self.node: Node = node
|
||||
self.groups: Optional[ListboxScroll] = None
|
||||
self.services: Optional[CheckboxList] = None
|
||||
self.current: Optional[ListboxScroll] = None
|
||||
services = set(canvas_node.core_node.services)
|
||||
services = set(node.services)
|
||||
self.current_services: Set[str] = services
|
||||
self.draw()
|
||||
|
||||
|
@ -104,7 +103,7 @@ class NodeServiceDialog(Dialog):
|
|||
self.current.listbox.insert(tk.END, name)
|
||||
if self.is_custom_service(name):
|
||||
self.current.listbox.itemconfig(tk.END, bg="green")
|
||||
self.canvas_node.core_node.services[:] = self.current_services
|
||||
self.node.services = self.current_services.copy()
|
||||
|
||||
def click_configure(self) -> None:
|
||||
current_selection = self.current.listbox.curselection()
|
||||
|
@ -113,8 +112,7 @@ class NodeServiceDialog(Dialog):
|
|||
self,
|
||||
self.app,
|
||||
self.current.listbox.get(current_selection[0]),
|
||||
self.canvas_node,
|
||||
self.node_id,
|
||||
self.node,
|
||||
)
|
||||
|
||||
# if error occurred when creating ServiceConfigDialog, don't show the dialog
|
||||
|
@ -128,8 +126,7 @@ class NodeServiceDialog(Dialog):
|
|||
)
|
||||
|
||||
def click_save(self) -> None:
|
||||
core_node = self.canvas_node.core_node
|
||||
core_node.services[:] = self.current_services
|
||||
self.node.services[:] = self.current_services
|
||||
self.destroy()
|
||||
|
||||
def click_remove(self) -> None:
|
||||
|
@ -144,6 +141,6 @@ class NodeServiceDialog(Dialog):
|
|||
return
|
||||
|
||||
def is_custom_service(self, service: str) -> bool:
|
||||
has_service_config = service in self.canvas_node.service_configs
|
||||
has_file_config = service in self.canvas_node.service_file_configs
|
||||
has_service_config = service in self.node.service_configs
|
||||
has_file_config = service in self.node.service_file_configs
|
||||
return has_service_config or has_file_config
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue