Skip to main content

A library to display and manipulate graphs on a tkinter canvas.

Project description

tkCanvasGraph is a Python library that implements a tkinter canvas on which users can display and manipulate graphs.

The documentation is available on

A small example of its usage:

import tkinter
from tkCanvasGraph import CanvasFrame, Vertex, Edge
root = tkinter.Tk()
frame = CanvasFrame(root)
frame.pack(fill="both", expand=True)
v1 = Vertex(frame.canvas, label="vertex1")
v2 = Vertex(frame.canvas, label="vertex2")
edge = Edge(frame.canvas, v1, v2, label="edge")

It creates a new tkinter window, fills it with a CanvasFrame (a tkinter frame containing a tkCanvasGraph frame.canvas, but also buttons to apply layouts, and scrollbars), then add two vertices and one edge.

Another example is the tkCanvasGraph/ file:

python -m tkCanvasGraph

It opens a similar window with additional functionalities:

  • new vertices can be created with CTRL + left click,
  • new edges by maintaining CTRL and dragging and dropping the mouse from one vertex to another,
  • elements can be deleted with CTRL + right click,
  • labels can be modified by right-clicking on any element,
  • “j” key will create a new vertex in a random position,
  • “k” key will create a new edge between two vertices without an edge,
  • “o” key will apply one step of the force based layout.

Look at the code to get more insight on how to use the library.

Project details

Release history Release notifications | RSS feed

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for tkCanvasGraph, version 1.0
Filename, size File type Python version Upload date Hashes
Filename, size tkCanvasGraph-1.0.tar.gz (19.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page