replace logging.info with logging.debug for unimportant loggings, change the functions inside type checking class into classmethods
This commit is contained in:
parent
6c89ba1abb
commit
5dd379a2ee
4 changed files with 35 additions and 14 deletions
|
@ -1,7 +1,6 @@
|
||||||
"""
|
"""
|
||||||
custom color picker
|
custom color picker
|
||||||
"""
|
"""
|
||||||
import logging
|
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from tkinter import ttk
|
from tkinter import ttk
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import TYPE_CHECKING, Any
|
||||||
|
@ -175,7 +174,6 @@ class ColorPickerDialog(Dialog):
|
||||||
self.hex.trace_add("write", self.update_color)
|
self.hex.trace_add("write", self.update_color)
|
||||||
|
|
||||||
def button_ok(self):
|
def button_ok(self):
|
||||||
logging.debug("not implemented")
|
|
||||||
self.color = self.hex.get()
|
self.color = self.hex.get()
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
|
|
|
@ -218,6 +218,12 @@ class CustomNodesDialog(Dialog):
|
||||||
if name not in self.app.core.custom_nodes:
|
if name not in self.app.core.custom_nodes:
|
||||||
image_file = Path(self.image_file).stem
|
image_file = Path(self.image_file).stem
|
||||||
node_draw = NodeDraw.from_custom(name, image_file, set(self.services))
|
node_draw = NodeDraw.from_custom(name, image_file, set(self.services))
|
||||||
|
logging.info(
|
||||||
|
"Created new custom node (%s), image file (%s), services: (%s)",
|
||||||
|
name,
|
||||||
|
image_file,
|
||||||
|
self.services,
|
||||||
|
)
|
||||||
self.app.core.custom_nodes[name] = node_draw
|
self.app.core.custom_nodes[name] = node_draw
|
||||||
self.nodes_list.listbox.insert(tk.END, name)
|
self.nodes_list.listbox.insert(tk.END, name)
|
||||||
self.reset_values()
|
self.reset_values()
|
||||||
|
@ -232,6 +238,12 @@ class CustomNodesDialog(Dialog):
|
||||||
node_draw.image_file = Path(self.image_file).stem
|
node_draw.image_file = Path(self.image_file).stem
|
||||||
node_draw.image = self.image
|
node_draw.image = self.image
|
||||||
node_draw.services = self.services
|
node_draw.services = self.services
|
||||||
|
logging.debug(
|
||||||
|
"Edit custom node (%s), image: (%s), services (%s)",
|
||||||
|
name,
|
||||||
|
self.image_file,
|
||||||
|
self.services,
|
||||||
|
)
|
||||||
self.app.core.custom_nodes[name] = node_draw
|
self.app.core.custom_nodes[name] = node_draw
|
||||||
self.nodes_list.listbox.delete(self.selected_index)
|
self.nodes_list.listbox.delete(self.selected_index)
|
||||||
self.nodes_list.listbox.insert(self.selected_index, name)
|
self.nodes_list.listbox.insert(self.selected_index, name)
|
||||||
|
@ -241,6 +253,7 @@ class CustomNodesDialog(Dialog):
|
||||||
if self.selected and self.selected in self.app.core.custom_nodes:
|
if self.selected and self.selected in self.app.core.custom_nodes:
|
||||||
self.nodes_list.listbox.delete(self.selected_index)
|
self.nodes_list.listbox.delete(self.selected_index)
|
||||||
del self.app.core.custom_nodes[self.selected]
|
del self.app.core.custom_nodes[self.selected]
|
||||||
|
logging.debug("Delete custom node (%s)", self.selected)
|
||||||
self.reset_values()
|
self.reset_values()
|
||||||
self.nodes_list.listbox.selection_clear(0, tk.END)
|
self.nodes_list.listbox.selection_clear(0, tk.END)
|
||||||
self.nodes_list.listbox.event_generate("<<ListboxSelect>>")
|
self.nodes_list.listbox.event_generate("<<ListboxSelect>>")
|
||||||
|
|
|
@ -105,7 +105,7 @@ class Toolbar(ttk.Frame):
|
||||||
self.create_annotation_button()
|
self.create_annotation_button()
|
||||||
|
|
||||||
def design_select(self, button: ttk.Button):
|
def design_select(self, button: ttk.Button):
|
||||||
logging.info("selecting design button: %s", button)
|
logging.debug("selecting design button: %s", button)
|
||||||
self.select_button.state(["!pressed"])
|
self.select_button.state(["!pressed"])
|
||||||
self.link_button.state(["!pressed"])
|
self.link_button.state(["!pressed"])
|
||||||
self.node_button.state(["!pressed"])
|
self.node_button.state(["!pressed"])
|
||||||
|
@ -114,7 +114,7 @@ class Toolbar(ttk.Frame):
|
||||||
button.state(["pressed"])
|
button.state(["pressed"])
|
||||||
|
|
||||||
def runtime_select(self, button: ttk.Button):
|
def runtime_select(self, button: ttk.Button):
|
||||||
logging.info("selecting runtime button: %s", button)
|
logging.debug("selecting runtime button: %s", button)
|
||||||
self.runtime_select_button.state(["!pressed"])
|
self.runtime_select_button.state(["!pressed"])
|
||||||
self.stop_button.state(["!pressed"])
|
self.stop_button.state(["!pressed"])
|
||||||
self.plot_button.state(["!pressed"])
|
self.plot_button.state(["!pressed"])
|
||||||
|
|
|
@ -31,7 +31,8 @@ class InputValidation:
|
||||||
self.rgb = self.master.register(self.check_rbg)
|
self.rgb = self.master.register(self.check_rbg)
|
||||||
self.hex = self.master.register(self.check_hex)
|
self.hex = self.master.register(self.check_hex)
|
||||||
|
|
||||||
def ip_focus_out(self, event: tk.Event):
|
@classmethod
|
||||||
|
def ip_focus_out(cls, event: tk.Event):
|
||||||
value = event.widget.get()
|
value = event.widget.get()
|
||||||
try:
|
try:
|
||||||
IPNetwork(value)
|
IPNetwork(value)
|
||||||
|
@ -39,12 +40,14 @@ class InputValidation:
|
||||||
event.widget.delete(0, tk.END)
|
event.widget.delete(0, tk.END)
|
||||||
event.widget.insert(tk.END, "invalid")
|
event.widget.insert(tk.END, "invalid")
|
||||||
|
|
||||||
def focus_out(self, event: tk.Event, default: str):
|
@classmethod
|
||||||
|
def focus_out(cls, event: tk.Event, default: str):
|
||||||
value = event.widget.get()
|
value = event.widget.get()
|
||||||
if value == "":
|
if value == "":
|
||||||
event.widget.insert(tk.END, default)
|
event.widget.insert(tk.END, default)
|
||||||
|
|
||||||
def check_positive_int(self, s: str) -> bool:
|
@classmethod
|
||||||
|
def check_positive_int(cls, s: str) -> bool:
|
||||||
if len(s) == 0:
|
if len(s) == 0:
|
||||||
return True
|
return True
|
||||||
try:
|
try:
|
||||||
|
@ -55,7 +58,8 @@ class InputValidation:
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def check_positive_float(self, s: str) -> bool:
|
@classmethod
|
||||||
|
def check_positive_float(cls, s: str) -> bool:
|
||||||
if len(s) == 0:
|
if len(s) == 0:
|
||||||
return True
|
return True
|
||||||
try:
|
try:
|
||||||
|
@ -66,7 +70,8 @@ class InputValidation:
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def check_node_name(self, s: str) -> bool:
|
@classmethod
|
||||||
|
def check_node_name(cls, s: str) -> bool:
|
||||||
if len(s) < 0:
|
if len(s) < 0:
|
||||||
return False
|
return False
|
||||||
if len(s) == 0:
|
if len(s) == 0:
|
||||||
|
@ -76,7 +81,8 @@ class InputValidation:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def check_canvas_int(self, s: str) -> bool:
|
@classmethod
|
||||||
|
def check_canvas_int(cls, s: str) -> bool:
|
||||||
if len(s) == 0:
|
if len(s) == 0:
|
||||||
return True
|
return True
|
||||||
try:
|
try:
|
||||||
|
@ -87,7 +93,8 @@ class InputValidation:
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def check_canvas_float(self, s: str) -> bool:
|
@classmethod
|
||||||
|
def check_canvas_float(cls, s: str) -> bool:
|
||||||
if not s:
|
if not s:
|
||||||
return True
|
return True
|
||||||
try:
|
try:
|
||||||
|
@ -98,7 +105,8 @@ class InputValidation:
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def check_ip4(self, s: str) -> bool:
|
@classmethod
|
||||||
|
def check_ip4(cls, s: str) -> bool:
|
||||||
if not s:
|
if not s:
|
||||||
return True
|
return True
|
||||||
pat = re.compile("^([0-9]+[.])*[0-9]*$")
|
pat = re.compile("^([0-9]+[.])*[0-9]*$")
|
||||||
|
@ -117,7 +125,8 @@ class InputValidation:
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def check_rbg(self, s: str) -> bool:
|
@classmethod
|
||||||
|
def check_rbg(cls, s: str) -> bool:
|
||||||
if not s:
|
if not s:
|
||||||
return True
|
return True
|
||||||
if s.startswith("0") and len(s) >= 2:
|
if s.startswith("0") and len(s) >= 2:
|
||||||
|
@ -131,7 +140,8 @@ class InputValidation:
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def check_hex(self, s: str) -> bool:
|
@classmethod
|
||||||
|
def check_hex(cls, s: str) -> bool:
|
||||||
if not s:
|
if not s:
|
||||||
return True
|
return True
|
||||||
pat = re.compile("^([#]([0-9]|[a-f])+)$|^[#]$")
|
pat = re.compile("^([#]([0-9]|[a-f])+)$|^[#]$")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue