grpc: added session options to session wrapped object, updated get_session and start_session to utilize this change, updated pygui to leverage as well
This commit is contained in:
parent
597834a993
commit
7938379e6d
7 changed files with 42 additions and 21 deletions
|
@ -1,11 +1,8 @@
|
|||
import logging
|
||||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
from typing import TYPE_CHECKING, Dict, Optional
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
import grpc
|
||||
|
||||
from core.api.grpc.wrappers import ConfigOption
|
||||
from core.gui.dialogs.dialog import Dialog
|
||||
from core.gui.themes import PADX, PADY
|
||||
from core.gui.widgets import ConfigFrame
|
||||
|
@ -21,24 +18,15 @@ class SessionOptionsDialog(Dialog):
|
|||
super().__init__(app, "Session Options")
|
||||
self.config_frame: Optional[ConfigFrame] = None
|
||||
self.has_error: bool = False
|
||||
self.config: Dict[str, ConfigOption] = self.get_config()
|
||||
self.enabled: bool = not self.app.core.is_runtime()
|
||||
if not self.has_error:
|
||||
self.draw()
|
||||
|
||||
def get_config(self) -> Dict[str, ConfigOption]:
|
||||
try:
|
||||
session_id = self.app.core.session.id
|
||||
return self.app.core.client.get_session_options(session_id)
|
||||
except grpc.RpcError as e:
|
||||
self.app.show_grpc_exception("Get Session Options Error", e)
|
||||
self.has_error = True
|
||||
self.destroy()
|
||||
|
||||
def draw(self) -> None:
|
||||
self.top.columnconfigure(0, weight=1)
|
||||
self.top.rowconfigure(0, weight=1)
|
||||
self.config_frame = ConfigFrame(self.top, self.app, self.config, self.enabled)
|
||||
options = self.app.core.session.options
|
||||
self.config_frame = ConfigFrame(self.top, self.app, options, self.enabled)
|
||||
self.config_frame.draw_config()
|
||||
self.config_frame.grid(sticky=tk.NSEW, pady=PADY)
|
||||
|
||||
|
@ -54,10 +42,6 @@ class SessionOptionsDialog(Dialog):
|
|||
|
||||
def save(self) -> None:
|
||||
config = self.config_frame.parse_config()
|
||||
try:
|
||||
session_id = self.app.core.session.id
|
||||
result = self.app.core.client.set_session_options(session_id, config)
|
||||
logger.info("saved session config: %s", result)
|
||||
except grpc.RpcError as e:
|
||||
self.app.show_grpc_exception("Set Session Options Error", e)
|
||||
for key, value in config.items():
|
||||
self.app.core.session.options[key].value = value
|
||||
self.destroy()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue