fixed name issue with app config, renamed to guiconfig
This commit is contained in:
parent
fbbf31f4fa
commit
a6cdd63570
7 changed files with 15 additions and 15 deletions
|
@ -26,7 +26,7 @@ class Application(tk.Frame):
|
||||||
self.statusbar = None
|
self.statusbar = None
|
||||||
|
|
||||||
# setup
|
# setup
|
||||||
self.config = appconfig.read()
|
self.guiconfig = appconfig.read()
|
||||||
self.style = ttk.Style()
|
self.style = ttk.Style()
|
||||||
self.setup_theme()
|
self.setup_theme()
|
||||||
self.core = CoreClient(self)
|
self.core = CoreClient(self)
|
||||||
|
@ -36,7 +36,7 @@ class Application(tk.Frame):
|
||||||
|
|
||||||
def setup_theme(self):
|
def setup_theme(self):
|
||||||
themes.load(self.style)
|
themes.load(self.style)
|
||||||
self.style.theme_use(self.config["preferences"]["theme"])
|
self.style.theme_use(self.guiconfig["preferences"]["theme"])
|
||||||
func = partial(themes.update_menu, self.style)
|
func = partial(themes.update_menu, self.style)
|
||||||
self.master.bind_class("Menu", "<<ThemeChanged>>", func)
|
self.master.bind_class("Menu", "<<ThemeChanged>>", func)
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ class Application(tk.Frame):
|
||||||
menu_action.on_quit()
|
menu_action.on_quit()
|
||||||
|
|
||||||
def save_config(self):
|
def save_config(self):
|
||||||
appconfig.save(self.config)
|
appconfig.save(self.guiconfig)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -83,12 +83,12 @@ class CoreClient:
|
||||||
|
|
||||||
def read_config(self):
|
def read_config(self):
|
||||||
# read distributed server
|
# read distributed server
|
||||||
for config in self.app.config.get("servers", []):
|
for config in self.app.guiconfig.get("servers", []):
|
||||||
server = CoreServer(config["name"], config["address"], config["port"])
|
server = CoreServer(config["name"], config["address"], config["port"])
|
||||||
self.servers[server.name] = server
|
self.servers[server.name] = server
|
||||||
|
|
||||||
# read custom nodes
|
# read custom nodes
|
||||||
for config in self.app.config.get("nodes", []):
|
for config in self.app.guiconfig.get("nodes", []):
|
||||||
name = config["name"]
|
name = config["name"]
|
||||||
image_file = config["image"]
|
image_file = config["image"]
|
||||||
services = set(config["services"])
|
services = set(config["services"])
|
||||||
|
@ -96,7 +96,7 @@ class CoreClient:
|
||||||
self.custom_nodes[name] = node_draw
|
self.custom_nodes[name] = node_draw
|
||||||
|
|
||||||
# read observers
|
# read observers
|
||||||
for config in self.app.config.get("observers", []):
|
for config in self.app.guiconfig.get("observers", []):
|
||||||
observer = Observer(config["name"], config["cmd"])
|
observer = Observer(config["name"], config["cmd"])
|
||||||
self.custom_observers[observer.name] = observer
|
self.custom_observers[observer.name] = observer
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ class CoreClient:
|
||||||
"""
|
"""
|
||||||
response = self.client.create_session()
|
response = self.client.create_session()
|
||||||
logging.info("created session: %s", response)
|
logging.info("created session: %s", response)
|
||||||
location_config = self.app.config["location"]
|
location_config = self.app.guiconfig["location"]
|
||||||
self.location = core_pb2.SessionLocation(
|
self.location = core_pb2.SessionLocation(
|
||||||
x=location_config["x"],
|
x=location_config["x"],
|
||||||
y=location_config["y"],
|
y=location_config["y"],
|
||||||
|
|
|
@ -179,7 +179,7 @@ class SizeAndScaleDialog(Dialog):
|
||||||
location.alt = self.alt.get()
|
location.alt = self.alt.get()
|
||||||
location.scale = self.scale.get()
|
location.scale = self.scale.get()
|
||||||
if self.save_default.get():
|
if self.save_default.get():
|
||||||
location_config = self.app.config["location"]
|
location_config = self.app.guiconfig["location"]
|
||||||
location_config["x"] = location.x
|
location_config["x"] = location.x
|
||||||
location_config["y"] = location.y
|
location_config["y"] = location.y
|
||||||
location_config["z"] = location.z
|
location_config["z"] = location.z
|
||||||
|
|
|
@ -180,17 +180,17 @@ class CustomNodesDialog(Dialog):
|
||||||
self.services.update(dialog.current_services)
|
self.services.update(dialog.current_services)
|
||||||
|
|
||||||
def click_save(self):
|
def click_save(self):
|
||||||
self.app.config["nodes"].clear()
|
self.app.guiconfig["nodes"].clear()
|
||||||
for name in sorted(self.app.core.custom_nodes):
|
for name in sorted(self.app.core.custom_nodes):
|
||||||
node_draw = self.app.core.custom_nodes[name]
|
node_draw = self.app.core.custom_nodes[name]
|
||||||
self.app.config["nodes"].append(
|
self.app.guiconfig["nodes"].append(
|
||||||
{
|
{
|
||||||
"name": name,
|
"name": name,
|
||||||
"image": node_draw.image_file,
|
"image": node_draw.image_file,
|
||||||
"services": list(node_draw.services),
|
"services": list(node_draw.services),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
logging.info("saving custom nodes: %s", self.app.config["nodes"])
|
logging.info("saving custom nodes: %s", self.app.guiconfig["nodes"])
|
||||||
self.app.save_config()
|
self.app.save_config()
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ class ObserverDialog(Dialog):
|
||||||
for name in sorted(self.app.core.custom_observers):
|
for name in sorted(self.app.core.custom_observers):
|
||||||
observer = self.app.core.custom_observers[name]
|
observer = self.app.core.custom_observers[name]
|
||||||
observers.append({"name": observer.name, "cmd": observer.cmd})
|
observers.append({"name": observer.name, "cmd": observer.cmd})
|
||||||
self.app.config["observers"] = observers
|
self.app.guiconfig["observers"] = observers
|
||||||
self.app.save_config()
|
self.app.save_config()
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ from coretk.dialogs.dialog import Dialog
|
||||||
class PreferencesDialog(Dialog):
|
class PreferencesDialog(Dialog):
|
||||||
def __init__(self, master, app):
|
def __init__(self, master, app):
|
||||||
super().__init__(master, app, "Preferences", modal=True)
|
super().__init__(master, app, "Preferences", modal=True)
|
||||||
preferences = self.app.config["preferences"]
|
preferences = self.app.guiconfig["preferences"]
|
||||||
self.editor = tk.StringVar(value=preferences["editor"])
|
self.editor = tk.StringVar(value=preferences["editor"])
|
||||||
self.theme = tk.StringVar(value=preferences["theme"])
|
self.theme = tk.StringVar(value=preferences["theme"])
|
||||||
self.terminal = tk.StringVar(value=preferences["terminal"])
|
self.terminal = tk.StringVar(value=preferences["terminal"])
|
||||||
|
@ -76,7 +76,7 @@ class PreferencesDialog(Dialog):
|
||||||
self.app.style.theme_use(theme)
|
self.app.style.theme_use(theme)
|
||||||
|
|
||||||
def click_save(self):
|
def click_save(self):
|
||||||
preferences = self.app.config["preferences"]
|
preferences = self.app.guiconfig["preferences"]
|
||||||
preferences["terminal"] = self.terminal.get()
|
preferences["terminal"] = self.terminal.get()
|
||||||
preferences["editor"] = self.editor.get()
|
preferences["editor"] = self.editor.get()
|
||||||
preferences["gui3d"] = self.gui3d.get()
|
preferences["gui3d"] = self.gui3d.get()
|
||||||
|
|
|
@ -115,7 +115,7 @@ class ServersDialog(Dialog):
|
||||||
servers.append(
|
servers.append(
|
||||||
{"name": server.name, "address": server.address, "port": server.port}
|
{"name": server.name, "address": server.address, "port": server.port}
|
||||||
)
|
)
|
||||||
self.app.config["servers"] = servers
|
self.app.guiconfig["servers"] = servers
|
||||||
self.app.save_config()
|
self.app.save_config()
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue