Skip to content

Commit

Permalink
Version 0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Akascape committed Jan 28, 2024
1 parent cb96908 commit f8a2415
Show file tree
Hide file tree
Showing 5 changed files with 287 additions and 158 deletions.
2 changes: 1 addition & 1 deletion tknodesystem/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
License: MIT
"""

__version__ = '0.7'
__version__ = '0.8'

from .node_types import NodeValue, NodeOperation, NodeCompile
from .node_canvas import NodeCanvas
Expand Down
18 changes: 13 additions & 5 deletions tknodesystem/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,29 @@ def destroy(self):
self.canvas.node_list.remove(self)
for i in self.canvas.line_ids:
i.update()


def bind(self, binding, command, add="+"):
for i in self.auxlist:
self.canvas.tag_bind(i, binding, command, add)

def configure(self, **kwargs):
""" configure options """

if "fg_color" in kwargs:
self.canvas.itemconfig(self.ID, fill=kwargs.pop("fg_color"))
self.node_color = kwargs.pop("fg_color")
self.canvas.itemconfig(self.ID, fill=self.node_color)
if "highlightcolor" in kwargs:
self.hover_color = kwargs.pop("highlightcolor")
if "hover" in kwargs:
self.hover = kwargs.pop("hover")
if "text" in kwargs:
self.canvas.itemconfig(self.IDtext, text=kwargs.pop("text"))
self.text = kwargs.pop("text")
self.canvas.itemconfig(self.IDtext, text=self.text)
if "text_color" in kwargs:
self.canvas.itemconfig(self.IDtext, fill=kwargs.pop("text_color"))
self.text_color = kwargs.pop("text_color")
self.canvas.itemconfig(self.IDtext, fill=self.text_color)
if "font" in kwargs:
self.canvas.itemconfig(self.IDtext, font=kwargs.pop("font"))
self.font = kwargs.pop("font")
self.canvas.itemconfig(self.IDtext, font=self.font)
if len(kwargs)>0:
raise ValueError("This option is not configurable:" + list(kwargs.keys())[0])
9 changes: 4 additions & 5 deletions tknodesystem/node_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def value_args(args):
def func_args(args):
default_args = {'width': 100, 'height': 80, 'inputs': 2, 'border_color': '#37373D', 'text': None, 'socket_radius': 8,
'corner_radius': 25, 'border_width': 0, 'fg_color': '#37373D', 'text_color': 'white', 'font': ('', 10),
'highlightcolor': '#52d66c', 'hover': True, 'socket_color': 'green', 'socket_hover_color': 'grey50',
'highlightcolor': '#52d66c', 'hover': True, 'socket_color': 'green', 'socket_hover_color': 'grey50', 'pass_node_id': False,
'x': None, 'y': None, 'multiside': False, 'output_socket_color': 'green', 'click_command': None, 'fixed': False,
'socket_hover': True, 'num': None, 'none_inputs': False, 'justify': 'center', 'hover_text': None}
'socket_hover': True, 'num': None, 'none_inputs': False, 'justify': 'center', 'hover_text': None, 'multiple_connection': False}

args.pop("canvas")
args.pop("self")
Expand All @@ -47,8 +47,8 @@ def func_args(args):
return new_args

def compile_args(args):
default_args = {'width': 100, 'height': 50, 'border_color': '#37373D', 'text': 'Compile', 'socket_radius': 8, 'justify': 'center',
'corner_radius': 25, 'x': None, 'y': None, 'border_width': 0, 'fg_color': '#37373D', 'text_color': 'white',
default_args = {'width': 100, 'height': 50, 'border_color': '#37373D', 'text': 'Compile', 'socket_radius': 8, 'justify': 'center', 'pass_node_id': False,
'corner_radius': 25, 'x': None, 'y': None, 'border_width': 0, 'fg_color': '#37373D', 'text_color': 'white', 'multiple_connection': False,
'font': ('', 10), 'highlightcolor': '#52d66c', 'hover': True, 'socket_hover': True, 'socket_color': 'green', 'fixed': False,
'socket_hover_color': 'grey50', 'show_value': True, 'command': None, 'click_command': None, 'side': 'left', 'num': None}

Expand All @@ -60,7 +60,6 @@ def compile_args(args):
args.pop("y")
args.pop("click_command")
args.pop("num")

new_args = {}

for i in args.keys():
Expand Down
86 changes: 33 additions & 53 deletions tknodesystem/node_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ def __init__(self, master, bg="grey10", width=500, height=500, wire_color="white
if sys.platform.startswith("darwin"):
self.tag_bind(self.grid_bg, '<ButtonPress-3>', lambda e: self.getpos(e, 1))
self.tag_bind(self.grid_bg, '<ButtonRelease-3>', lambda e: self.getpos(e, 0))
self.tag_bind(self.grid_bg, "<B3-Motion>", self.move_grid)
else:
self.tag_bind(self.grid_bg, '<ButtonPress-2>', lambda e: self.getpos(e, 1))
self.tag_bind(self.grid_bg, '<ButtonRelease-2>', lambda e: self.getpos(e, 0))
self.tag_bind(self.grid_bg, "<B2-Motion>", self.move_grid)
self.tag_bind(self.grid_bg, "<B2-Motion>", self.move_grid)

if zoom:
self.bind("<MouseWheel>", self.do_zoom)
Expand Down Expand Up @@ -73,11 +74,11 @@ def getpos(self, event, cursor):
""" get the mouse position and change cursor style """

self.xy_set = (event.x, event.y)

if cursor:
self.config(cursor="fleur")
self.config(cursor="fleur", width=self.winfo_reqwidth(), height=self.winfo_reqheight())
else:
self.config(cursor="arrow")
self.config(cursor="arrow", width=self.winfo_reqwidth(), height=self.winfo_reqheight())

def move_grid(self, event):
""" move the contents of the canvas except the grid image """
Expand Down Expand Up @@ -143,6 +144,9 @@ def clear(self):
self.compile_num = 0
self.socket_num = 0
self.line_list = set()
self.obj_list = set()
self.line_ids = set()
self.node_list = set()

def configure(self, **kwargs):
""" configure options """
Expand Down Expand Up @@ -221,58 +225,34 @@ def load(self, filename):
func_nodes.append(obj)
elif obj_type.split()[0]=="NodeCompile":
comp_nodes.append(obj)

self.obj_list.add(obj)

for i in value_nodes:
i.connect_output(None)
for j in func_nodes:
try:
if [self.outputcell.output_.socket_num, j.input_1.socket_num] in line_list:
self.clickcount = 1
j.connect_input(j.line1, 'input1')
if [self.outputcell.output_.socket_num, j.input_2.socket_num] in line_list:
self.clickcount = 1
j.connect_input(j.line2, 'input2')
if [self.outputcell.output_.socket_num, j.input_3.socket_num] in line_list:
self.clickcount = 1
j.connect_input(j.line3, 'input3')
if [self.outputcell.output_.socket_num, j.input_4.socket_num] in line_list:
self.clickcount = 1
j.connect_input(j.line4, 'input4')
if [self.outputcell.output_.socket_num, j.input_5.socket_num] in line_list:
self.clickcount = 1
j.connect_input(j.line5, 'input5')
except AttributeError: None
for j in comp_nodes:
if [self.outputcell.output_.socket_num, j.input_1.socket_num] in line_list:
self.clickcount = 1
j.connect_input(None)

for i in func_nodes:
i.connect_output(None)
for j in func_nodes:
try:

for nodes in [value_nodes, func_nodes, comp_nodes]:
for i in nodes:
i.connect_output(None)
for j in func_nodes:
try:
if [self.outputcell.output_.socket_num, j.input_1.socket_num] in line_list:
self.clickcount = 1
j.connect_input(j.line1, 'input1')
if [self.outputcell.output_.socket_num, j.input_2.socket_num] in line_list:
self.clickcount = 1
j.connect_input(j.line2, 'input2')
if [self.outputcell.output_.socket_num, j.input_3.socket_num] in line_list:
self.clickcount = 1
j.connect_input(j.line3, 'input3')
if [self.outputcell.output_.socket_num, j.input_4.socket_num] in line_list:
self.clickcount = 1
j.connect_input(j.line4, 'input4')
if [self.outputcell.output_.socket_num, j.input_5.socket_num] in line_list:
self.clickcount = 1
j.connect_input(j.line5, 'input5')
except AttributeError: None
for j in comp_nodes:
if [self.outputcell.output_.socket_num, j.input_1.socket_num] in line_list:
self.clickcount = 1
j.connect_input(j.line1, 'input1')
if [self.outputcell.output_.socket_num, j.input_2.socket_num] in line_list:
self.clickcount = 1
j.connect_input(j.line2, 'input2')
if [self.outputcell.output_.socket_num, j.input_3.socket_num] in line_list:
self.clickcount = 1
j.connect_input(j.line3, 'input3')
if [self.outputcell.output_.socket_num, j.input_4.socket_num] in line_list:
self.clickcount = 1
j.connect_input(j.line4, 'input4')
if [self.outputcell.output_.socket_num, j.input_5.socket_num] in line_list:
self.clickcount = 1
j.connect_input(j.line5, 'input5')
except AttributeError: None
for j in comp_nodes:
if [self.outputcell.output_.socket_num, j.input_1.socket_num] in line_list:
self.clickcount = 1
j.connect_input(None)
j.connect_input(None)


self.connect_wire = True

0 comments on commit f8a2415

Please sign in to comment.