more type hinting, remove some Optional type, and fix a small bug at dialogs.nodeconfig.mac_auto()
This commit is contained in:
parent
6c8a2526d9
commit
c22f1680f7
12 changed files with 59 additions and 52 deletions
|
@ -190,7 +190,7 @@ class ColorPickerDialog(Dialog):
|
|||
green = self.green_entry.get()
|
||||
return "#%02x%02x%02x" % (int(red), int(green), int(blue))
|
||||
|
||||
def current_focus(self, focus):
|
||||
def current_focus(self, focus: str):
|
||||
self.focus = focus
|
||||
|
||||
def update_color(self, arg1=None, arg2=None, arg3=None):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
from typing import TYPE_CHECKING, Union
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from core.api.grpc import core_pb2
|
||||
from core.gui.dialogs.dialog import Dialog
|
||||
|
@ -12,7 +12,7 @@ if TYPE_CHECKING:
|
|||
|
||||
|
||||
class HookDialog(Dialog):
|
||||
def __init__(self, master: Union[tk.Widget, Dialog], app: "Application"):
|
||||
def __init__(self, master: Any, app: "Application"):
|
||||
super().__init__(master, app, "Hook", modal=True)
|
||||
self.name = tk.StringVar()
|
||||
self.codetext = None
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
import grpc
|
||||
|
||||
|
@ -69,7 +69,7 @@ class MobilityPlayer:
|
|||
|
||||
class MobilityPlayerDialog(Dialog):
|
||||
def __init__(
|
||||
self, master: Dialog, app: "Application", canvas_node: "CanvasNode", config
|
||||
self, master: Any, app: "Application", canvas_node: "CanvasNode", config
|
||||
):
|
||||
super().__init__(
|
||||
master, app, f"{canvas_node.core_node.name} Mobility Player", modal=False
|
||||
|
|
|
@ -18,19 +18,27 @@ if TYPE_CHECKING:
|
|||
from core.gui.graph.node import CanvasNode
|
||||
|
||||
|
||||
def mac_auto(is_auto, entry):
|
||||
def mac_auto(is_auto: tk.BooleanVar, entry: ttk.Entry):
|
||||
logging.info("mac auto clicked")
|
||||
if is_auto.get():
|
||||
logging.info("disabling mac")
|
||||
entry.var.set("")
|
||||
entry.delete(0, tk.END)
|
||||
entry.insert(tk.END, "")
|
||||
entry.config(state=tk.DISABLED)
|
||||
else:
|
||||
entry.var.set("00:00:00:00:00:00")
|
||||
entry.delete(0, tk.END)
|
||||
entry.insert(tk.END, "00:00:00:00:00:00")
|
||||
entry.config(state=tk.NORMAL)
|
||||
|
||||
|
||||
class InterfaceData:
|
||||
def __init__(self, is_auto, mac, ip4, ip6):
|
||||
def __init__(
|
||||
self,
|
||||
is_auto: tk.BooleanVar,
|
||||
mac: tk.StringVar,
|
||||
ip4: tk.StringVar,
|
||||
ip6: tk.StringVar,
|
||||
):
|
||||
self.is_auto = is_auto
|
||||
self.mac = mac
|
||||
self.ip4 = ip4
|
||||
|
|
|
@ -3,7 +3,7 @@ core node services
|
|||
"""
|
||||
import tkinter as tk
|
||||
from tkinter import messagebox, ttk
|
||||
from typing import TYPE_CHECKING, Any
|
||||
from typing import TYPE_CHECKING, Any, Set
|
||||
|
||||
from core.gui.dialogs.dialog import Dialog
|
||||
from core.gui.dialogs.serviceconfig import ServiceConfigDialog
|
||||
|
@ -17,7 +17,11 @@ if TYPE_CHECKING:
|
|||
|
||||
class NodeServiceDialog(Dialog):
|
||||
def __init__(
|
||||
self, master: Any, app: "Application", canvas_node: "CanvasNode", services=None
|
||||
self,
|
||||
master: Any,
|
||||
app: "Application",
|
||||
canvas_node: "CanvasNode",
|
||||
services: Set[str] = None,
|
||||
):
|
||||
title = f"{canvas_node.core_node.name} Services"
|
||||
super().__init__(master, app, title, modal=True)
|
||||
|
|
|
@ -3,7 +3,7 @@ shape input dialog
|
|||
"""
|
||||
import tkinter as tk
|
||||
from tkinter import font, ttk
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, List, Union
|
||||
|
||||
from core.gui.dialogs.colorpicker import ColorPickerDialog
|
||||
from core.gui.dialogs.dialog import Dialog
|
||||
|
@ -167,10 +167,9 @@ class ShapeDialog(Dialog):
|
|||
self.add_text()
|
||||
self.destroy()
|
||||
|
||||
def make_font(self):
|
||||
def make_font(self) -> List[Union[int, str]]:
|
||||
"""
|
||||
create font for text or shape label
|
||||
:return: list(font specifications)
|
||||
"""
|
||||
size = int(self.font_size.get())
|
||||
text_font = [self.font.get(), size]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue