pygui some cleanup for dialog constructors to avoid passing duplicate parameters in most cases

This commit is contained in:
Blake Harnden 2020-05-04 22:50:59 -07:00
parent 185c6736b3
commit 1d620a0b17
42 changed files with 143 additions and 209 deletions

View file

@ -134,7 +134,7 @@ class Application(ttk.Frame):
self.show_error(title, str(e))
def show_error(self, title: str, message: str) -> None:
self.after(0, lambda: ErrorDialog(self, self, title, message).show())
self.after(0, lambda: ErrorDialog(self, title, message).show())
def on_closing(self):
self.menubar.prompt_save_running_session(True)

View file

@ -467,11 +467,11 @@ class CoreClient:
if len(sessions) == 0:
self.create_new_session()
else:
dialog = SessionsDialog(self.app, self.app, True)
dialog = SessionsDialog(self.app, True)
dialog.show()
except grpc.RpcError as e:
logging.exception("core setup error")
dialog = ErrorDialog(self.app, self.app, "Setup Error", e.details())
dialog = ErrorDialog(self.app, "Setup Error", e.details())
dialog.show()
self.app.close()

View file

@ -35,8 +35,8 @@ THE POSSIBILITY OF SUCH DAMAGE.\
class AboutDialog(Dialog):
def __init__(self, master: "Application", app: "Application"):
super().__init__(master, app, "About CORE")
def __init__(self, app: "Application"):
super().__init__(app, "About CORE")
self.draw()
def draw(self):

View file

@ -15,9 +15,8 @@ if TYPE_CHECKING:
class AlertsDialog(Dialog):
def __init__(self, master: "Application", app: "Application"):
super().__init__(master, app, "Alerts")
self.app = app
def __init__(self, app: "Application"):
super().__init__(app, "Alerts")
self.tree = None
self.codetext = None
self.alarm_map = {}
@ -93,16 +92,10 @@ class AlertsDialog(Dialog):
frame.grid(sticky="ew")
frame.columnconfigure(0, weight=1)
frame.columnconfigure(1, weight=1)
frame.columnconfigure(2, weight=1)
frame.columnconfigure(3, weight=1)
button = ttk.Button(frame, text="Reset", command=self.reset_alerts)
button.grid(row=0, column=0, sticky="ew", padx=PADX)
button = ttk.Button(frame, text="Daemon Log", command=self.daemon_log)
button.grid(row=0, column=1, sticky="ew", padx=PADX)
button = ttk.Button(frame, text="Node Log")
button.grid(row=0, column=2, sticky="ew", padx=PADX)
button = ttk.Button(frame, text="Close", command=self.destroy)
button.grid(row=0, column=3, sticky="ew")
button.grid(row=0, column=1, sticky="ew")
def reset_alerts(self):
self.codetext.text.delete("1.0", tk.END)
@ -110,10 +103,6 @@ class AlertsDialog(Dialog):
self.tree.delete(item)
self.app.statusbar.core_alarms.clear()
def daemon_log(self):
dialog = DaemonLog(self, self.app)
dialog.show()
def click_select(self, event: tk.Event):
current = self.tree.selection()[0]
alarm = self.alarm_map[current]
@ -121,33 +110,3 @@ class AlertsDialog(Dialog):
self.codetext.text.delete("1.0", "end")
self.codetext.text.insert("1.0", alarm.exception_event.text)
self.codetext.text.config(state=tk.DISABLED)
class DaemonLog(Dialog):
def __init__(self, master: tk.Widget, app: "Application"):
super().__init__(master, app, "core-daemon log")
self.columnconfigure(0, weight=1)
self.path = tk.StringVar(value="/var/log/core-daemon.log")
self.draw()
def draw(self):
self.top.columnconfigure(0, weight=1)
self.top.rowconfigure(1, weight=1)
frame = ttk.Frame(self.top)
frame.grid(row=0, column=0, sticky="ew", pady=PADY)
frame.columnconfigure(0, weight=1)
frame.columnconfigure(1, weight=9)
label = ttk.Label(frame, text="File", anchor="w")
label.grid(row=0, column=0, sticky="ew")
entry = ttk.Entry(frame, textvariable=self.path, state="disabled")
entry.grid(row=0, column=1, sticky="ew")
try:
file = open("/var/log/core-daemon.log", "r")
log = file.readlines()
except FileNotFoundError:
log = "Log file not found"
codetext = CodeText(self.top)
codetext.text.insert("1.0", log)
codetext.text.see("end")
codetext.text.config(state=tk.DISABLED)
codetext.grid(row=1, column=0, sticky="nsew")

View file

@ -15,11 +15,11 @@ PIXEL_SCALE = 100
class SizeAndScaleDialog(Dialog):
def __init__(self, master: "Application", app: "Application"):
def __init__(self, app: "Application"):
"""
create an instance for size and scale object
"""
super().__init__(master, app, "Canvas Size and Scale")
super().__init__(app, "Canvas Size and Scale")
self.canvas = self.app.canvas
self.validation = app.validation
self.section_font = font.Font(weight="bold")

View file

@ -17,11 +17,11 @@ if TYPE_CHECKING:
class CanvasWallpaperDialog(Dialog):
def __init__(self, master: "Application", app: "Application"):
def __init__(self, app: "Application"):
"""
create an instance of CanvasWallpaper object
"""
super().__init__(master, app, "Canvas Background")
super().__init__(app, "Canvas Background")
self.canvas = self.app.canvas
self.scale_option = tk.IntVar(value=self.canvas.scale_option.get())
self.adjust_to_dim = tk.BooleanVar(value=self.canvas.adjust_to_dim.get())

View file

@ -3,7 +3,7 @@ custom color picker
"""
import tkinter as tk
from tkinter import ttk
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING
from core.gui.dialogs.dialog import Dialog
@ -12,8 +12,10 @@ if TYPE_CHECKING:
class ColorPickerDialog(Dialog):
def __init__(self, master: Any, app: "Application", initcolor: str = "#000000"):
super().__init__(master, app, "color picker")
def __init__(
self, master: tk.BaseWidget, app: "Application", initcolor: str = "#000000"
):
super().__init__(app, "color picker", master=master)
self.red_entry = None
self.blue_entry = None
self.green_entry = None

View file

@ -4,7 +4,7 @@ Service configuration dialog
import logging
import tkinter as tk
from tkinter import ttk
from typing import TYPE_CHECKING, Any, List
from typing import TYPE_CHECKING, List
import grpc
@ -21,16 +21,14 @@ if TYPE_CHECKING:
class ConfigServiceConfigDialog(Dialog):
def __init__(
self,
master: Any,
master: tk.BaseWidget,
app: "Application",
service_name: str,
canvas_node: "CanvasNode",
node_id: int,
):
title = f"{service_name} Config Service"
super().__init__(master, app, title)
self.master = master
self.app = app
super().__init__(app, title, master=master)
self.core = app.core
self.canvas_node = canvas_node
self.node_id = node_id

View file

@ -4,7 +4,7 @@ copy service config dialog
import tkinter as tk
from tkinter import ttk
from typing import TYPE_CHECKING, Any, Tuple
from typing import TYPE_CHECKING, Tuple
from core.gui.dialogs.dialog import Dialog
from core.gui.themes import FRAME_PAD, PADX
@ -15,10 +15,9 @@ if TYPE_CHECKING:
class CopyServiceConfigDialog(Dialog):
def __init__(self, master: Any, app: "Application", node_id: int):
super().__init__(master, app, f"Copy services to node {node_id}")
def __init__(self, master: tk.BaseWidget, app: "Application", node_id: int):
super().__init__(app, f"Copy services to node {node_id}", master=master)
self.parent = master
self.app = app
self.node_id = node_id
self.service_configs = app.core.service_configs
self.file_configs = app.core.file_configs
@ -171,13 +170,13 @@ class CopyServiceConfigDialog(Dialog):
class ViewConfigDialog(Dialog):
def __init__(
self,
master: Any,
master: tk.BaseWidget,
app: "Application",
node_id: int,
data: str,
filename: str = None,
):
super().__init__(master, app, f"n{node_id} config data")
super().__init__(app, f"n{node_id} config data", master=master)
self.data = data
self.service_data = None
self.filepath = tk.StringVar(value=f"/tmp/services.tmp-n{node_id}-{filename}")

View file

@ -2,7 +2,7 @@ import logging
import tkinter as tk
from pathlib import Path
from tkinter import ttk
from typing import TYPE_CHECKING, Any, Set
from typing import TYPE_CHECKING, Set
from core.gui import nodeutils
from core.gui.appconfig import ICONS_PATH
@ -17,8 +17,10 @@ if TYPE_CHECKING:
class ServicesSelectDialog(Dialog):
def __init__(self, master: Any, app: "Application", current_services: Set[str]):
super().__init__(master, app, "Node Services")
def __init__(
self, master: tk.BaseWidget, app: "Application", current_services: Set[str]
):
super().__init__(app, "Node Services", master=master)
self.groups = None
self.services = None
self.current = None
@ -100,8 +102,8 @@ class ServicesSelectDialog(Dialog):
class CustomNodesDialog(Dialog):
def __init__(self, master: "Application", app: "Application"):
super().__init__(master, app, "Custom Nodes")
def __init__(self, app: "Application"):
super().__init__(app, "Custom Nodes")
self.edit_button = None
self.delete_button = None
self.nodes_list = None

View file

@ -11,8 +11,14 @@ if TYPE_CHECKING:
class Dialog(tk.Toplevel):
def __init__(
self, master: tk.Widget, app: "Application", title: str, modal: bool = True
self,
app: "Application",
title: str,
modal: bool = True,
master: tk.BaseWidget = None,
):
if master is None:
master = app
super().__init__(master)
self.withdraw()
self.app = app

View file

@ -4,7 +4,7 @@ emane configuration
import tkinter as tk
import webbrowser
from tkinter import ttk
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING
import grpc
@ -19,8 +19,8 @@ if TYPE_CHECKING:
class GlobalEmaneDialog(Dialog):
def __init__(self, master: Any, app: "Application"):
super().__init__(master, app, "EMANE Configuration")
def __init__(self, master: tk.BaseWidget, app: "Application"):
super().__init__(app, "EMANE Configuration", master=master)
self.config_frame = None
self.draw()
@ -52,14 +52,14 @@ class GlobalEmaneDialog(Dialog):
class EmaneModelDialog(Dialog):
def __init__(
self,
master: Any,
master: tk.BaseWidget,
app: "Application",
canvas_node: "CanvasNode",
model: str,
interface: int = None,
):
super().__init__(
master, app, f"{canvas_node.core_node.name} {model} Configuration"
app, f"{canvas_node.core_node.name} {model} Configuration", master=master
)
self.canvas_node = canvas_node
self.node = canvas_node.core_node
@ -109,13 +109,8 @@ class EmaneModelDialog(Dialog):
class EmaneConfigDialog(Dialog):
def __init__(
self, master: "Application", app: "Application", canvas_node: "CanvasNode"
):
super().__init__(
master, app, f"{canvas_node.core_node.name} EMANE Configuration"
)
self.app = app
def __init__(self, app: "Application", canvas_node: "CanvasNode"):
super().__init__(app, f"{canvas_node.core_node.name} EMANE Configuration")
self.canvas_node = canvas_node
self.node = canvas_node.core_node
self.radiovar = tk.IntVar()

View file

@ -11,8 +11,8 @@ if TYPE_CHECKING:
class ErrorDialog(Dialog):
def __init__(self, master, app: "Application", title: str, details: str) -> None:
super().__init__(master, app, "CORE Exception")
def __init__(self, app: "Application", title: str, details: str) -> None:
super().__init__(app, "CORE Exception")
self.title = title
self.details = details
self.error_message = None

View file

@ -1,16 +1,19 @@
import logging
import tkinter as tk
from tkinter import filedialog, ttk
from typing import TYPE_CHECKING
from core.gui.appconfig import SCRIPT_PATH
from core.gui.dialogs.dialog import Dialog
from core.gui.themes import FRAME_PAD, PADX
if TYPE_CHECKING:
from core.gui.app import Application
class ExecutePythonDialog(Dialog):
def __init__(self, master, app):
super().__init__(master, app, "Execute Python Script")
self.app = app
def __init__(self, app: "Application"):
super().__init__(app, "Execute Python Script")
self.with_options = tk.IntVar(value=0)
self.options = tk.StringVar(value="")
self.option_entry = None

View file

@ -1,14 +1,18 @@
import logging
import tkinter as tk
from tkinter import ttk
from typing import TYPE_CHECKING
from core.gui.dialogs.dialog import Dialog
from core.gui.themes import FRAME_PAD, PADX, PADY
if TYPE_CHECKING:
from core.gui.app import Application
class FindDialog(Dialog):
def __init__(self, master, app) -> None:
super().__init__(master, app, "Find", modal=False)
def __init__(self, app: "Application") -> None:
super().__init__(app, "Find", modal=False)
self.find_text = tk.StringVar(value="")
self.tree = None
self.draw()
@ -90,7 +94,8 @@ class FindDialog(Dialog):
if not node_name or node_name == name:
pos_x = round(node.core_node.position.x, 1)
pos_y = round(node.core_node.position.y, 1)
# TODO I am not sure what to insert for Detail column, leaving in blank for now
# TODO: I am not sure what to insert for Detail column
# leaving it blank for now
self.tree.insert(
"",
tk.END,

View file

@ -1,6 +1,6 @@
import tkinter as tk
from tkinter import ttk
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING
from core.api.grpc import core_pb2
from core.gui.dialogs.dialog import Dialog
@ -12,8 +12,8 @@ if TYPE_CHECKING:
class HookDialog(Dialog):
def __init__(self, master: Any, app: "Application"):
super().__init__(master, app, "Hook")
def __init__(self, master: tk.BaseWidget, app: "Application"):
super().__init__(app, "Hook", master=master)
self.name = tk.StringVar()
self.codetext = None
self.hook = core_pb2.Hook()
@ -88,8 +88,8 @@ class HookDialog(Dialog):
class HooksDialog(Dialog):
def __init__(self, master: "Application", app: "Application"):
super().__init__(master, app, "Hooks")
def __init__(self, app: "Application"):
super().__init__(app, "Hooks")
self.listbox = None
self.edit_button = None
self.delete_button = None

View file

@ -14,8 +14,8 @@ if TYPE_CHECKING:
class IpConfigDialog(Dialog):
def __init__(self, master: "Application", app: "Application") -> None:
super().__init__(master, app, "IP Configuration")
def __init__(self, app: "Application") -> None:
super().__init__(app, "IP Configuration")
ip_config = self.app.guiconfig.setdefault("ips")
self.ip4 = ip_config.setdefault("ip4", appconfig.DEFAULT_IP4)
self.ip6 = ip_config.setdefault("ip6", appconfig.DEFAULT_IP6)

View file

@ -12,7 +12,7 @@ from core.gui.themes import PADX, PADY
if TYPE_CHECKING:
from core.gui.app import Application
from core.gui.graph.graph import CanvasGraph, CanvasEdge
from core.gui.graph.graph import CanvasEdge
def get_int(var: tk.StringVar) -> Union[int, None]:
@ -32,9 +32,8 @@ def get_float(var: tk.StringVar) -> Union[float, None]:
class LinkConfigurationDialog(Dialog):
def __init__(self, master: "CanvasGraph", app: "Application", edge: "CanvasEdge"):
super().__init__(master, app, "Link Configuration")
self.app = app
def __init__(self, app: "Application", edge: "CanvasEdge"):
super().__init__(app, "Link Configuration")
self.edge = edge
self.is_symmetric = edge.link.options.unidirectional is False
if self.is_symmetric:

View file

@ -13,8 +13,8 @@ if TYPE_CHECKING:
class MacConfigDialog(Dialog):
def __init__(self, master: "Application", app: "Application") -> None:
super().__init__(master, app, "MAC Configuration")
def __init__(self, app: "Application") -> None:
super().__init__(app, "MAC Configuration")
mac = self.app.guiconfig.get("mac", appconfig.DEFAULT_MAC)
self.mac_var = tk.StringVar(value=mac)
self.draw()

View file

@ -17,11 +17,8 @@ MARKER_THICKNESS = [3, 5, 8, 10]
class MarkerDialog(Dialog):
def __init__(
self, master: "Application", app: "Application", initcolor: str = "#000000"
):
super().__init__(master, app, "Marker Tool", modal=False)
self.app = app
def __init__(self, app: "Application", initcolor: str = "#000000"):
super().__init__(app, "Marker Tool", modal=False)
self.color = initcolor
self.radius = MARKER_THICKNESS[0]
self.marker_thickness = tk.IntVar(value=MARKER_THICKNESS[0])

View file

@ -16,12 +16,8 @@ if TYPE_CHECKING:
class MobilityConfigDialog(Dialog):
def __init__(
self, master: "Application", app: "Application", canvas_node: "CanvasNode"
):
super().__init__(
master, app, f"{canvas_node.core_node.name} Mobility Configuration"
)
def __init__(self, app: "Application", canvas_node: "CanvasNode"):
super().__init__(app, f"{canvas_node.core_node.name} Mobility Configuration")
self.canvas_node = canvas_node
self.node = canvas_node.core_node
self.config_frame = None

View file

@ -1,6 +1,6 @@
import tkinter as tk
from tkinter import ttk
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING
import grpc
@ -17,14 +17,7 @@ ICON_SIZE = 16
class MobilityPlayer:
def __init__(
self,
master: "Application",
app: "Application",
canvas_node: "CanvasNode",
config,
):
self.master = master
def __init__(self, app: "Application", canvas_node: "CanvasNode", config):
self.app = app
self.canvas_node = canvas_node
self.config = config
@ -34,9 +27,7 @@ class MobilityPlayer:
def show(self):
if self.dialog:
self.dialog.destroy()
self.dialog = MobilityPlayerDialog(
self.master, self.app, self.canvas_node, self.config
)
self.dialog = MobilityPlayerDialog(self.app, self.canvas_node, self.config)
self.dialog.protocol("WM_DELETE_WINDOW", self.close)
if self.state == MobilityAction.START:
self.set_play()
@ -68,11 +59,9 @@ class MobilityPlayer:
class MobilityPlayerDialog(Dialog):
def __init__(
self, master: Any, app: "Application", canvas_node: "CanvasNode", config
):
def __init__(self, app: "Application", canvas_node: "CanvasNode", config):
super().__init__(
master, app, f"{canvas_node.core_node.name} Mobility Player", modal=False
app, f"{canvas_node.core_node.name} Mobility Player", modal=False
)
self.resizable(False, False)
self.geometry("")

View file

@ -94,13 +94,11 @@ class InterfaceData:
class NodeConfigDialog(Dialog):
def __init__(
self, master: "Application", app: "Application", canvas_node: "CanvasNode"
):
def __init__(self, app: "Application", canvas_node: "CanvasNode"):
"""
create an instance of node configuration
"""
super().__init__(master, app, f"{canvas_node.core_node.name} Configuration")
super().__init__(app, f"{canvas_node.core_node.name} Configuration")
self.canvas_node = canvas_node
self.node = canvas_node.core_node
self.image = canvas_node.image

View file

@ -18,15 +18,10 @@ if TYPE_CHECKING:
class NodeConfigServiceDialog(Dialog):
def __init__(
self,
master: tk.Widget,
app: "Application",
canvas_node: "CanvasNode",
services: Set[str] = None,
self, app: "Application", canvas_node: "CanvasNode", services: Set[str] = None
):
title = f"{canvas_node.core_node.name} Config Services"
super().__init__(master, app, title)
self.app = app
super().__init__(app, title)
self.canvas_node = canvas_node
self.node_id = canvas_node.core_node.id
self.groups = None

View file

@ -16,12 +16,9 @@ if TYPE_CHECKING:
class NodeServiceDialog(Dialog):
def __init__(
self, master: tk.Widget, app: "Application", canvas_node: "CanvasNode"
):
def __init__(self, app: "Application", canvas_node: "CanvasNode"):
title = f"{canvas_node.core_node.name} Services"
super().__init__(master, app, title)
self.app = app
super().__init__(app, title)
self.canvas_node = canvas_node
self.node_id = canvas_node.core_node.id
self.groups = None

View file

@ -12,8 +12,8 @@ if TYPE_CHECKING:
class ObserverDialog(Dialog):
def __init__(self, master: "Application", app: "Application"):
super().__init__(master, app, "Observer Widgets")
def __init__(self, app: "Application"):
super().__init__(app, "Observer Widgets")
self.observers = None
self.save_button = None
self.delete_button = None

View file

@ -16,8 +16,8 @@ SCALE_INTERVAL = 0.01
class PreferencesDialog(Dialog):
def __init__(self, master: "Application", app: "Application"):
super().__init__(master, app, "Preferences")
def __init__(self, app: "Application"):
super().__init__(app, "Preferences")
self.gui_scale = tk.DoubleVar(value=self.app.app_scale)
preferences = self.app.guiconfig["preferences"]
self.editor = tk.StringVar(value=preferences["editor"])

View file

@ -1,17 +1,20 @@
import tkinter as tk
from tkinter import ttk
from typing import TYPE_CHECKING
from core.gui.dialogs.dialog import Dialog
from core.gui.nodeutils import NodeUtils
from core.gui.themes import FRAME_PAD, PADX, PADY
from core.gui.widgets import CodeText, ListboxScroll
if TYPE_CHECKING:
from core.gui.app import Application
class RunToolDialog(Dialog):
def __init__(self, master, app) -> None:
super().__init__(master, app, "Run Tool")
def __init__(self, app: "Application") -> None:
super().__init__(app, "Run Tool")
self.cmd = tk.StringVar(value="ps ax")
self.app = app
self.result = None
self.node_list = None
self.executable_nodes = {}

View file

@ -16,8 +16,8 @@ DEFAULT_PORT = 50051
class ServersDialog(Dialog):
def __init__(self, master: "Application", app: "Application"):
super().__init__(master, app, "CORE Servers")
def __init__(self, app: "Application"):
super().__init__(app, "CORE Servers")
self.name = tk.StringVar(value=DEFAULT_NAME)
self.address = tk.StringVar(value=DEFAULT_ADDRESS)
self.port = tk.IntVar(value=DEFAULT_PORT)

View file

@ -2,7 +2,7 @@ import logging
import os
import tkinter as tk
from tkinter import filedialog, ttk
from typing import TYPE_CHECKING, Any, List
from typing import TYPE_CHECKING, List
import grpc
@ -21,16 +21,14 @@ if TYPE_CHECKING:
class ServiceConfigDialog(Dialog):
def __init__(
self,
master: Any,
master: tk.BaseWidget,
app: "Application",
service_name: str,
canvas_node: "CanvasNode",
node_id: int,
):
title = f"{service_name} Service"
super().__init__(master, app, title)
self.master = master
self.app = app
super().__init__(app, title, master=master)
self.core = app.core
self.canvas_node = canvas_node
self.node_id = node_id

View file

@ -13,8 +13,8 @@ if TYPE_CHECKING:
class SessionOptionsDialog(Dialog):
def __init__(self, master: "Application", app: "Application"):
super().__init__(master, app, "Session Options")
def __init__(self, app: "Application"):
super().__init__(app, "Session Options")
self.config_frame = None
self.has_error = False
self.config = self.get_config()

View file

@ -16,10 +16,8 @@ if TYPE_CHECKING:
class SessionsDialog(Dialog):
def __init__(
self, master: "Application", app: "Application", is_start_app: bool = False
) -> None:
super().__init__(master, app, "Sessions")
def __init__(self, app: "Application", is_start_app: bool = False) -> None:
super().__init__(app, "Sessions")
self.is_start_app = is_start_app
self.selected_session = None
self.selected_id = None

View file

@ -20,12 +20,12 @@ BORDER_WIDTH = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
class ShapeDialog(Dialog):
def __init__(self, master: "Application", app: "Application", shape: "Shape"):
def __init__(self, app: "Application", shape: "Shape"):
if is_draw_shape(shape.shape_type):
title = "Add Shape"
else:
title = "Add Text"
super().__init__(master, app, title)
super().__init__(app, title)
self.canvas = app.canvas
self.fill = None
self.border = None

View file

@ -14,9 +14,8 @@ if TYPE_CHECKING:
class ThroughputDialog(Dialog):
def __init__(self, master: "Application", app: "Application"):
super().__init__(master, app, "Throughput Config")
self.app = app
def __init__(self, app: "Application"):
super().__init__(app, "Throughput Config")
self.canvas = app.canvas
self.show_throughput = tk.IntVar(value=1)
self.exponential_weight = tk.IntVar(value=1)

View file

@ -16,12 +16,8 @@ RANGE_WIDTH = 3
class WlanConfigDialog(Dialog):
def __init__(
self, master: "Application", app: "Application", canvas_node: "CanvasNode"
):
super().__init__(
master, app, f"{canvas_node.core_node.name} WLAN Configuration"
)
def __init__(self, app: "Application", canvas_node: "CanvasNode"):
super().__init__(app, f"{canvas_node.core_node.name} WLAN Configuration")
self.canvas_node = canvas_node
self.node = canvas_node.core_node
self.config_frame = None

View file

@ -389,5 +389,5 @@ class CanvasEdge(Edge):
self.canvas.delete_edge(self)
def click_configure(self) -> None:
dialog = LinkConfigurationDialog(self.canvas, self.canvas.app, self)
dialog = LinkConfigurationDialog(self.canvas.app, self)
dialog.show()

View file

@ -720,7 +720,7 @@ class CanvasGraph(tk.Canvas):
selected = self.get_selected(event)
if selected is not None and selected in self.shapes:
shape = self.shapes[selected]
dialog = ShapeDialog(self.app, self.app, shape)
dialog = ShapeDialog(self.app, shape)
dialog.show()
def add_node(self, x: float, y: float) -> CanvasNode:

View file

@ -265,16 +265,16 @@ class CanvasNode:
self.canvas.copy()
def show_config(self):
dialog = NodeConfigDialog(self.app, self.app, self)
dialog = NodeConfigDialog(self.app, self)
dialog.show()
def show_wlan_config(self):
dialog = WlanConfigDialog(self.app, self.app, self)
dialog = WlanConfigDialog(self.app, self)
if not dialog.has_error:
dialog.show()
def show_mobility_config(self):
dialog = MobilityConfigDialog(self.app, self.app, self)
dialog = MobilityConfigDialog(self.app, self)
if not dialog.has_error:
dialog.show()
@ -283,15 +283,15 @@ class CanvasNode:
mobility_player.show()
def show_emane_config(self):
dialog = EmaneConfigDialog(self.app, self.app, self)
dialog = EmaneConfigDialog(self.app, self)
dialog.show()
def show_services(self):
dialog = NodeServiceDialog(self.app, self.app, self)
dialog = NodeServiceDialog(self.app, self)
dialog.show()
def show_config_services(self):
dialog = NodeConfigServiceDialog(self.app, self.app, self)
dialog = NodeConfigServiceDialog(self.app, self)
dialog.show()
def has_emane_link(self, interface_id: int) -> core_pb2.Node:

View file

@ -148,7 +148,7 @@ class Shape:
def shape_complete(self, x: float, y: float):
for component in tags.ABOVE_SHAPE:
self.canvas.tag_raise(component)
s = ShapeDialog(self.app, self.app, self)
s = ShapeDialog(self.app, self)
s.show()
def disappear(self):

View file

@ -345,8 +345,8 @@ class Menubar(tk.Menu):
task = ProgressTask(self.app, "Open XML", self.core.open_xml, args=(filename,))
task.start()
def execute_python(self):
dialog = ExecutePythonDialog(self.app, self.app)
def execute_python(self) -> None:
dialog = ExecutePythonDialog(self.app)
dialog.show()
def add_recent_file_to_gui_config(self, file_path) -> None:
@ -399,19 +399,19 @@ class Menubar(tk.Menu):
self.core.xml_file = None
def click_find(self, _event: tk.Event = None) -> None:
dialog = FindDialog(self.app, self.app)
dialog = FindDialog(self.app)
dialog.show()
def click_preferences(self) -> None:
dialog = PreferencesDialog(self.app, self.app)
dialog = PreferencesDialog(self.app)
dialog.show()
def click_canvas_size_and_scale(self) -> None:
dialog = SizeAndScaleDialog(self.app, self.app)
dialog = SizeAndScaleDialog(self.app)
dialog.show()
def click_canvas_wallpaper(self) -> None:
dialog = CanvasWallpaperDialog(self.app, self.app)
dialog = CanvasWallpaperDialog(self.app)
dialog.show()
def click_core_github(self) -> None:
@ -421,7 +421,7 @@ class Menubar(tk.Menu):
webbrowser.open_new("http://coreemu.github.io/core/")
def click_about(self) -> None:
dialog = AboutDialog(self.app, self.app)
dialog = AboutDialog(self.app)
dialog.show()
def click_throughput(self) -> None:
@ -431,7 +431,7 @@ class Menubar(tk.Menu):
self.core.cancel_throughputs()
def click_config_throughput(self) -> None:
dialog = ThroughputDialog(self.app, self.app)
dialog = ThroughputDialog(self.app)
dialog.show()
def click_copy(self, _event: tk.Event = None) -> None:
@ -449,27 +449,27 @@ class Menubar(tk.Menu):
def click_session_options(self) -> None:
logging.debug("Click options")
dialog = SessionOptionsDialog(self.app, self.app)
dialog = SessionOptionsDialog(self.app)
if not dialog.has_error:
dialog.show()
def click_sessions(self) -> None:
logging.debug("Click change sessions")
dialog = SessionsDialog(self.app, self.app)
dialog = SessionsDialog(self.app)
dialog.show()
def click_hooks(self) -> None:
logging.debug("Click hooks")
dialog = HooksDialog(self.app, self.app)
dialog = HooksDialog(self.app)
dialog.show()
def click_servers(self) -> None:
logging.debug("Click emulation servers")
dialog = ServersDialog(self.app, self.app)
dialog = ServersDialog(self.app)
dialog.show()
def click_edit_observer_widgets(self) -> None:
dialog = ObserverDialog(self.app, self.app)
dialog = ObserverDialog(self.app)
dialog.show()
def click_autogrid(self) -> None:
@ -492,13 +492,13 @@ class Menubar(tk.Menu):
edge.draw_labels()
def click_mac_config(self) -> None:
dialog = MacConfigDialog(self.app, self.app)
dialog = MacConfigDialog(self.app)
dialog.show()
def click_ip_config(self) -> None:
dialog = IpConfigDialog(self.app, self.app)
dialog = IpConfigDialog(self.app)
dialog.show()
def click_custom_nodes(self) -> None:
dialog = CustomNodesDialog(self.app, self.app)
dialog = CustomNodesDialog(self.app)
dialog.show()

View file

@ -65,7 +65,7 @@ class StatusBar(ttk.Frame):
self.alerts_button.grid(row=0, column=3, sticky="ew")
def click_alerts(self):
dialog = AlertsDialog(self.app, self.app)
dialog = AlertsDialog(self.app)
dialog.show()
def set_status(self, message: str):

View file

@ -459,12 +459,12 @@ class Toolbar(ttk.Frame):
if is_marker(shape_type):
if self.marker_tool:
self.marker_tool.destroy()
self.marker_tool = MarkerDialog(self.app, self.app)
self.marker_tool = MarkerDialog(self.app)
self.marker_tool.show()
def click_run_button(self):
logging.debug("Click on RUN button")
dialog = RunToolDialog(self.app, self.app)
dialog = RunToolDialog(self.app)
dialog.show()
def click_marker_button(self):
@ -474,7 +474,7 @@ class Toolbar(ttk.Frame):
self.app.canvas.annotation_type = ShapeType.MARKER
if self.marker_tool:
self.marker_tool.destroy()
self.marker_tool = MarkerDialog(self.app, self.app)
self.marker_tool = MarkerDialog(self.app)
self.marker_tool.show()
def scale_button(self, button, image_enum):