Skip to content

Commit

Permalink
First version of editor
Browse files Browse the repository at this point in the history
  • Loading branch information
tisnik committed Dec 17, 2024
1 parent 0d492bc commit e0c20a5
Show file tree
Hide file tree
Showing 39 changed files with 1,693 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/config_editor.py
Original file line number Diff line number Diff line change
@@ -1 +1,46 @@
"""Configuration editor for Road Core service."""

import yaml

from gui.main_window import MainWindow

DEFAULT_CONFIGURATION_FILE = "olsconfig.yaml"


class ConfigEditor:
"""Class representing instances of configuration editor."""

def __init__(self):
"""Initialize configuration editor."""
self.configuration = None

def new_configuration(self):
"""Create new configuration to be edited."""
self.configuration = None

def load_configuration(self, filename):
"""Load configuration from YAML file."""
with open(filename) as fin:
self.configuration = yaml.safe_load(fin)
self.filename = filename

def save_configuration_as(self, filename):
"""Store configuration into YAML file."""
with open(filename, "w") as fout:
yaml.dump(self.configuration, fout)

def save_configuration(self):
"""Store configuration into YAML file."""
with open(self.filename, "w") as fout:
yaml.dump(self.configuration, fout)

def check_configuration(self):
"""Check if configuration is correct one."""
pass


config_editor = ConfigEditor()
config_editor.load_configuration(DEFAULT_CONFIGURATION_FILE)

main_window = MainWindow(config_editor)
main_window.show()
1 change: 1 addition & 0 deletions src/gui/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Graphical user interface for the Road Core config editor."""
1 change: 1 addition & 0 deletions src/gui/dialogs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Implementation of all GUI dialog boxes."""
10 changes: 10 additions & 0 deletions src/gui/dialogs/about_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""Implementation of simple 'About' dialog."""

from tkinter import messagebox


def about():
"""Show 'about' dialog."""
messagebox.showinfo(
"Config editor", "Configuration editor for the Road Core service"
)
39 changes: 39 additions & 0 deletions src/gui/dialogs/auth_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""Auth dialog."""

import tkinter


class AuthDialog(tkinter.Toplevel):
"""Dialog for editing authentication configuration."""

def __init__(self, parent, icons):
"""Initialize authentication configuration dialog."""
tkinter.Toplevel.__init__(self, parent)
self.title("Authentication configuration")
self.icons = icons
self.parent = parent

# don't display the dialog in list of opened windows
self.transient(parent)

# close the dialog on 'x' click
self.protocol("WM_DELETE_WINDOW", self.destroy)

# get the focus
self.grab_set()

ok_button = tkinter.Button(
self,
text="OK",
command=self.ok,
compound="left",
image=self.icons.checkbox_icon,
width=200,
)
ok_button.grid(row=2, column=1, sticky="W", padx=10, pady=10)
# get the focus
ok_button.focus_set()

def ok(self) -> None:
"""Handle Ok button press."""
self.destroy()
66 changes: 66 additions & 0 deletions src/gui/dialogs/cache_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
"""Conversation cache dialog."""

import tkinter
import tkinter.ttk as ttk


class ConversationCacheDialog(tkinter.Toplevel):
"""Dialog for editing conversation settings."""

def __init__(self, parent, icons):
"""Initialize dialog for editing conversation settings."""
tkinter.Toplevel.__init__(self, parent)
self.title("Conversation cache")
self.icons = icons
self.parent = parent

# don't display the dialog in list of opened windows
self.transient(parent)

# close the dialog on 'x' click
self.protocol("WM_DELETE_WINDOW", self.destroy)

# get the focus
self.grab_set()

# UI groups
self.group = tkinter.LabelFrame(self, text="Conversation cache", padx=5, pady=8)

label1 = tkinter.Label(self.group, text="Type")

label1.grid(row=1, column=1, sticky="W", padx=5, pady=5)

cache_types = ("In-memory", "PostgreSQL", "Redis")

cache_type = tkinter.StringVar(self.group, cache_types[0], "cache_type")
print(cache_type)

cb1 = ttk.Combobox(
self.group,
values=cache_types,
# textvariable=app_log_levels,
state="readonly",
)
cb1.current(0)
cb1.grid(row=1, column=2, sticky="W", padx=5, pady=5)

ok_button = tkinter.Button(
self,
text="OK",
command=self.ok,
compound="left",
image=self.icons.checkbox_icon,
width=200,
)

# UI groups placement
self.group.grid(row=1, column=1, sticky="NSWE", padx=5, pady=5)

ok_button.grid(row=2, column=1, sticky="W", padx=10, pady=10)

# get the focus
ok_button.focus_set()

def ok(self) -> None:
"""Handle Ok button press."""
self.destroy()
39 changes: 39 additions & 0 deletions src/gui/dialogs/check_configuration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""Check configuration dialog."""

import tkinter


class CheckConfigurationDialog(tkinter.Toplevel):
"""Dialog for checking the configuration."""

def __init__(self, parent, icons):
"""Initialize dialog for checking the configuration."""
tkinter.Toplevel.__init__(self, parent)
self.title("Check configuration")
self.icons = icons
self.parent = parent

# don't display the dialog in list of opened windows
self.transient(parent)

# close the dialog on 'x' click
self.protocol("WM_DELETE_WINDOW", self.destroy)

# get the focus
self.grab_set()

ok_button = tkinter.Button(
self,
text="OK",
command=self.ok,
compound="left",
image=self.icons.checkbox_icon,
width=200,
)
ok_button.grid(row=2, column=1, sticky="W", padx=10, pady=10)
# get the focus
ok_button.focus_set()

def ok(self) -> None:
"""Handle Ok button press."""
self.destroy()
39 changes: 39 additions & 0 deletions src/gui/dialogs/data_collection_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""Data collection dialog."""

import tkinter


class DataCollectionDialog(tkinter.Toplevel):
"""Data collection dialog."""

def __init__(self, parent, icons):
"""Initialize data collection dialog."""
tkinter.Toplevel.__init__(self, parent)
self.title("Data collection settings")
self.icons = icons
self.parent = parent

# don't display the dialog in list of opened windows
self.transient(parent)

# close the dialog on 'x' click
self.protocol("WM_DELETE_WINDOW", self.destroy)

# get the focus
self.grab_set()

ok_button = tkinter.Button(
self,
text="OK",
command=self.ok,
compound="left",
image=self.icons.checkbox_icon,
width=200,
)
ok_button.grid(row=2, column=1, sticky="W", padx=10, pady=10)
# get the focus
ok_button.focus_set()

def ok(self) -> None:
"""Handle Ok button press."""
self.destroy()
39 changes: 39 additions & 0 deletions src/gui/dialogs/default_model_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""Default model selection dialog."""

import tkinter


class DefaultModelSelection(tkinter.Toplevel):
"""Default model selection dialog."""

def __init__(self, parent, icons):
"""Initialize default model selection dialog."""
tkinter.Toplevel.__init__(self, parent)
self.title("Default model selection")
self.icons = icons
self.parent = parent

# don't display the dialog in list of opened windows
self.transient(parent)

# close the dialog on 'x' click
self.protocol("WM_DELETE_WINDOW", self.destroy)

# get the focus
self.grab_set()

ok_button = tkinter.Button(
self,
text="OK",
command=self.ok,
compound="left",
image=self.icons.checkbox_icon,
width=200,
)
ok_button.grid(row=2, column=1, sticky="W", padx=10, pady=10)
# get the focus
ok_button.focus_set()

def ok(self) -> None:
"""Handle Ok button press."""
self.destroy()
39 changes: 39 additions & 0 deletions src/gui/dialogs/default_provider_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""Default provider selection dialog."""

import tkinter


class DefaultProviderSelection(tkinter.Toplevel):
"""Default provider selection dialog."""

def __init__(self, parent, icons):
"""Initialize default provider selection dialog."""
tkinter.Toplevel.__init__(self, parent)
self.title("Default provider selection")
self.icons = icons
self.parent = parent

# don't display the dialog in list of opened windows
self.transient(parent)

# close the dialog on 'x' click
self.protocol("WM_DELETE_WINDOW", self.destroy)

# get the focus
self.grab_set()

ok_button = tkinter.Button(
self,
text="OK",
command=self.ok,
compound="left",
image=self.icons.checkbox_icon,
width=200,
)
ok_button.grid(row=2, column=1, sticky="W", padx=10, pady=10)
# get the focus
ok_button.focus_set()

def ok(self) -> None:
"""Handle Ok button press."""
self.destroy()
Loading

0 comments on commit e0c20a5

Please sign in to comment.