Skip to content

Introduction

Akash Bora edited this page May 23, 2023 · 35 revisions

What is TkNodeSystem?

TkNodeSystem is a nodal-interface, basically a DAG where each node performs an operation on it's input connections, and outputs something (which you can connect to another node).

It can be used to implement flow-based operations in your application. It can be used with tkinter or customtkinter easily as it is created with tkinter canvas.

Note that the node components are not separate widgets like customtkinter. The whole canvas is one parent widget and other components are drawn inside that canvas.

Internal components of TkNodeSystem are:

  • node canvas: containing the grid image and other bindings
  • node frame: containing round rectangle and text
  • node sockets: containing circle which acts as connector, attached to the node frame
  • node wires: the lines are created when output is connected to some input
  • node menu: a separate widget for searching and spawning new nodes

Final components of TkNodeSystem:

  • NodeCanvas
  • NodeValue
  • NodeOperation
  • NodeCompile
  • NodeMenu

The flow is always from output_socket-->input_socket(s)

Importing

This is the preferred way of importing the package:

from tknodesystem import *

or

from tknodesystem import NodeCanvas, NodeValue, NodeOperation, NodeCompile, NodeMenu

Important Note

This node system is not like the Blender node system (where the nodes have various widgets like sliders and options), but it is similar to the node system of Davinci Resolve (fusion), Natron or Nuke. So, basically you have to place controls on a separate frame in your application. An advanced example is also provided here.

If we place any tk widgets in the canvas then they are always drawn on top of other canvas objects and the UI looks displaced. The issue was also asked on StackOverflow, but there is no valid solution to it.

Clone this wiki locally