-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
1,693 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Graphical user interface for the Road Core config editor.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Implementation of all GUI dialog boxes.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Oops, something went wrong.