CADvas: Python CAD on Tk canvas


After 15 years have passed without any development, I decided to 'dust off' this project, update it to run on Python 3, and upload it to GitHub. Here it is (again). Enjoy!


This started out as an experiment to see how easy it would be to write a 2D CAD application in Python. Why Python? Because it's a blast to program stuff in Python. But there are already some other 2D CAD applications written in Python. For example:

So why write yet another 2D CAD application in Python? Well, here's why:

When I discovered PythonCAD in 2003 I was thrilled. I fancied myself a budding Python programmer, and I use CAD at work. What a perfect project for me. I figured I would pore over the code, learn how it works, and then be able to contribute to the project. Unfortunately, I wasn't able to figure out how it works. I'm sure this can be explained by the fact that I was an inexperienced coder, but nevertheless, I was still completely stuck and unable to understand it, let alone contribute. Studying the code, I learned that PythonCAD used the Gnome drawing area widget, and that a lot of code deals with managing events and signals to the drawing entities on the drawing area. As I studied the gnome-python interface, I discovered the Gnome Canvas which has "built-in" event and signal management for drawing items. I wondered if, by using the canvas instead of the drawing area, the job of writing the CAD application might become much easier. It wasn't clear whether the Gnome Canvas would be adequate for this task. Thus, the experiment.

So, I set out writing gcadvas, a python program using the gnome canvas, and which aspired to become a 2D CAD application. However, I encountered several difficulties requiring workarounds, and some that I had no solution for. After about a month working on this, I came across the source code for the gnome canvas and right at the top of the header file it said "the gnome canvas is based on the excellent Tk canvas". I thought: "Gosh, I didn't know that". So I decided to have a look at the Tk canvas to see if it would be better suited for my 2D CAD application. But before I dove in, I did a Google search to see if anyone else had already been down this road before me. Sure enough, somebody had. ThanCAD was a 2D CAD application written in Python and using Tkinter. Again, I downloaded the code and studied it, but again, I got nowhere. I just couldn't figure out how it works. So I thought: "How hard can this be?" and I started writing TkCADvas. What I discovered was that the Tk canvas has a very rich and well documented set of methods, making my job far easier than it was using the Gnome Canvas. I didn't encounter the problems I had using the Gnome Canvas. And the Tk canvas comes included with Python, so my application doesn't depend on any additional libraries. (Actually, that's not quite true: I am using John Grayson's AppShell megawidget which provides tooltips, so you need to have Python megawidgets, but I could have written this to require nothing else beyond a stock Python installation.) Another advantage that fell in my lap is that this program will run on any platform that Python runs on. It is not limited to Linux. After 2 weeks in my spare time, I had what looks like a 2D CAD application (albeit with some missing parts).


At work, my favorite CAD was SolidDesigner (3D) and me10 (2D), originally developed by HP, then spun off as CoCreate (and later purchased by PTC). I have borrowed rather heavily from my experience with ME10 and have tried to create a similar look and feel in CADvas.

  • There are no layers.
  • There are two types of lines: Construction lines and Geometry lines. The idea is that construction lines are used to first create a 'layout' and then geometry lines are added, after which the construction lines could be erased. I imagine that this derived from standard drafting practice at the time, which CAD supplanted.
  • Here are some shortcuts I have implemented:


    Download & Installation:

    Clone the GitHub repository onto your computer.

    There is no installation. Just run the file "".

    Other stuff needed:

    You will need Python (obviously) and Python megawidgets.

    Author and Maintainer:

    Doug Blanding