In this article I'll show you how to customize CircuitDraw with small code modifications
CircuitDraw is open-source software and I want people to be able to modify and customize the program to their tastes. Today I'll give you a few tips to get you started.
I recommend you make a copy of the main file and modify the copy. This way you have the original program backed up if things go gloriously wrong.
Scale and board-positioning
Something you may wish to change is the size and position of the primary boards. Let's say you wish to have just a Raspberry Pi, a breadboard and one power supply in your diagrams, and you want them to be larger. I'll run you through the methods to do that.
First, make a copy of the main file and rename the copy pi_breadboard.py or something similar. You can make a different file for each board configuration you want.
In your new file, the first thing you need to do is disable the auto-resolution function. This function sets the draw-size for objects according to the size of your computer's display. While this is enabled it will overide your modifications.
The auto resolution function is named set_magnification() and it is called on line 358.
Comment out the call with a hash tag like the image below.
Next we'll change the default magnification variable. This variable is named m and you will find it on line 30.
Change m from 3 to 5.
This will change the magnification for all components on the screen. If you run the program now some of the boards will be off the screen, so we need to change the starting positions of our required boards to the left.
For a breadboard you'll need to scroll down to line 474 and modify the Breadboard class constructor.
The first number inside the brackets (currently set to 170) sets the horizontal position of the top-left corner of the breadboard. Change this value to 120.
If you save and run the program now and load a breadboard it should be much larger.
If you need to move the Pi, the class constructor for this is on line 456.
By default it is already far-left where we want it, but it is positioned too low to work at this magnification. This time we need to change the verticle starting point. That is the second number in the brackets, which is 90 by default.
Change this value to 30.
We now have the Raspberry Pi and breadboard filling the entire window.
We now need to change the position of the power supply and heading. Scroll down to line 510.
Change the second number in the psu1 Power constructor from 8 to 4.
Finally, to move the heading right go to line 426.
Change the first number in the brackets from 450 to 750.
Save and run the program. Load a Pi, a breadboard and a power supply and see how it looks.
This is just one configuration example, you can create many other configurations in the same way.
Change main header
If you would like to change the heading to your own, it's easy. Go to line 427.
Replace "Estimcad CircuitDraw" with your heading of choice.
That is just a couple of examples of code modifications possible on CircuitDraw. With a bit of trial-and-error you should be making your own improvements to the program in no time.
I'll also detail the major changes coming in version 0.3, which should arrive in March.