diff --git a/daemon/core/gui/dialogs/throughput.py b/daemon/core/gui/dialogs/throughput.py new file mode 100644 index 00000000..178c10d1 --- /dev/null +++ b/daemon/core/gui/dialogs/throughput.py @@ -0,0 +1,97 @@ +""" +throughput dialog +""" +import logging +import tkinter as tk +from tkinter import ttk + +from core.gui.dialogs.dialog import Dialog + + +class ThroughputDialog(Dialog): + def __init__(self, master, app): + super().__init__(master, app, "throughput config", modal=False) + self.app = app + self.show_throughput = tk.IntVar(value=1) + self.exponential_weight = tk.IntVar(value=1) + self.transmission = tk.IntVar(value=1) + self.reception = tk.IntVar(value=1) + self.threshold = tk.DoubleVar(value=250.0) + self.width = tk.IntVar(value=10) + self.top.columnconfigure(0, weight=1) + self.draw() + + def draw(self): + button = ttk.Checkbutton( + self.top, + variable=self.show_throughput, + text="Show throughput level on every link", + ) + button.grid(row=0, column=0, sticky="nsew") + button = ttk.Checkbutton( + self.top, + variable=self.exponential_weight, + text="Use exponential weighted moving average", + ) + button.grid(row=1, column=0, sticky="nsew") + button = ttk.Checkbutton( + self.top, variable=self.transmission, text="Include transmissions" + ) + button.grid(row=2, column=0, sticky="nsew") + button = ttk.Checkbutton( + self.top, variable=self.reception, text="Include receptions" + ) + button.grid(row=3, column=0, sticky="nsew") + + label_frame = ttk.LabelFrame(self.top, text="Link highlight") + label_frame.columnconfigure(0, weight=1) + label_frame.grid(row=4, column=0, sticky="nsew") + label = ttk.Label(label_frame, text="Highlight link if throughput exceeds this") + label.grid(row=0, column=0, sticky="nsew") + + frame = ttk.Frame(label_frame) + frame.columnconfigure(0, weight=2) + frame.columnconfigure(1, weight=1) + frame.columnconfigure(2, weight=1) + frame.grid(row=1, column=0, sticky="nsew") + label = ttk.Label(frame, text="Threshold (0 for disabled)") + label.grid(row=0, column=0, sticky="nsew") + entry = ttk.Entry(frame, textvariable=self.threshold) + entry.grid(row=0, column=1, sticky="nsew") + label = ttk.Label(frame, text="kbps") + label.grid(row=0, column=2, sticky="nsew") + + scale = ttk.Scale( + label_frame, + from_=0, + to=1000, + value=0, + orient=tk.HORIZONTAL, + variable=self.threshold, + ) + scale.grid(row=2, column=0, sticky="nsew") + + frame = ttk.Frame(label_frame) + frame.columnconfigure(0, weight=1) + frame.columnconfigure(1, weight=1) + frame.grid(row=3, column=0, sticky="nsew") + label = ttk.Label(frame, text="Highlight link width: ") + label.grid(row=0, column=0, sticky="nsew") + entry = ttk.Entry(frame, textvariable=self.width) + entry.grid(row=0, column=1, sticky="nsew") + + frame = ttk.Frame(label_frame) + frame.columnconfigure(0, weight=1) + frame.columnconfigure(1, weight=1) + frame.grid(row=4, column=0, sticky="nsew") + label = ttk.Label(frame, text="Color: ") + label.grid(row=0, column=0, sticky="nsew") + button = ttk.Button(frame, text="not implemented") + button.grid(row=0, column=1, sticky="nsew") + + button = ttk.Button(self.top, text="OK", command=self.ok) + button.grid(row=5, column=0, sticky="nsew") + + def ok(self): + logging.debug("click ok") + self.destroy() diff --git a/daemon/core/gui/menuaction.py b/daemon/core/gui/menuaction.py index 8d45c33a..7a635ba6 100644 --- a/daemon/core/gui/menuaction.py +++ b/daemon/core/gui/menuaction.py @@ -20,6 +20,7 @@ from core.gui.dialogs.preferences import PreferencesDialog from core.gui.dialogs.servers import ServersDialog from core.gui.dialogs.sessionoptions import SessionOptionsDialog from core.gui.dialogs.sessions import SessionsDialog +from core.gui.dialogs.throughput import ThroughputDialog class MenuAction: @@ -164,3 +165,8 @@ class MenuAction: def paste(self, event=None): logging.debug("paste") self.app.canvas.paste() + + def config_throughput(self): + logging.debug("not implemented") + dialog = ThroughputDialog(self.app, self.app) + dialog.show() diff --git a/daemon/core/gui/menubar.py b/daemon/core/gui/menubar.py index d797097f..f8020866 100644 --- a/daemon/core/gui/menubar.py +++ b/daemon/core/gui/menubar.py @@ -435,7 +435,9 @@ class Menubar(tk.Menu): menu.add_checkbutton(label="Throughput", command=self.menuaction.throughput) menu.add_separator() menu.add_command(label="Configure Adjacency...", state=tk.DISABLED) - menu.add_command(label="Configure Throughput...", state=tk.DISABLED) + menu.add_command( + label="Configure Throughput...", command=self.menuaction.config_throughput + ) self.add_cascade(label="Widgets", menu=menu) def draw_session_menu(self):