Your first PanelWorks panel in five minutes
You've heard PanelWorks brings back the Visual Basic way of building programs, in Python. Here's the quickest way to see it for yourself: no hardware, no accounts, about five minutes. These steps are for Windows; Mac and Linux are the same with pw/bin/python in place of pw\Scripts\python.
1. Install Python
Get Python 3.10 or newer from python.org. In the installer, tick Add python.exe to PATH, then Install Now.
2. Install PanelWorks
Open a Command Prompt and type these one at a time:
mkdir C:\dev
cd C:\dev
python -m venv pw
pw\Scripts\python -m pip install panelworks
That makes a private copy of Python in a folder called pw and installs PanelWorks into it, so nothing else on your PC is touched.
3. Run a ready-made panel
pw\Scripts\python -m panelworks --example pumppanel --mcp none
A cistern pump panel opens. Click Start and watch the tank level move. Close the window when you're done. (The first run copies the example into a PanelWorks folder in your Documents, so you can change it without breaking the original.)
To see how it's built, open the same panel in the designer:
pw\Scripts\python -m panelworks --example pumppanel --design
There's the form, the toolbox and the properties, just like VB. Double-click a button to see the code behind it.
4. Make your own
A panel is two files: a form and its code. In C:\dev, save this as Hello.json:
{
"name": "Hello",
"caption": "My First Panel",
"width": 360,
"height": 160,
"code": "Hello.py",
"objects": {
"lblHello": {"type": "Label", "Caption": "Type your name and press Greet", "Left": 20, "Top": 20, "Width": 320, "Height": 24},
"txtName": {"type": "TextBox", "Text": "", "Left": 20, "Top": 60, "Width": 200, "Height": 26},
"cmdGreet": {"type": "CommandButton", "Caption": "Greet", "Left": 235, "Top": 58, "Width": 90, "Height": 30}
}
}
And this as Hello.py:
def cmdGreet_Click(f):
f.lblHello.Caption = "Hello, " + f.txtName.Text + "!"
Run it:
pw\Scripts\python -m panelworks Hello.json --mcp none
Type your name, click Greet, and the label says hello. cmdGreet_Click runs when cmdGreet is clicked, and f is the form, so f.lblHello.Caption is the label's Caption. If you've written VB, you already know how this works.
Where next
pw\Scripts\python -m panelworks --examplelists all the bundled examples. Several (weather, solar, UPS, Modbus meter) come with a pretend device, so they run with no hardware.pw\Scripts\python -m panelworks.designeropens the designer, so you can draw panels instead of typing them.- PanelWorks is free and open source: github.com/KK4HFJ/panelworks.
- For the whole story, from your first panel to Arduino, ESP32, MQTT, Modbus and SNMP, there's my book, Draw It, Wire It, Run It, the official guide to building control panels in Python with PanelWorks: paperback or Kindle (affiliate links). The book's page has the free code and errata.
As an Amazon Associate I earn from qualifying purchases.
73, Steve, KK4HFJ
Reply to this post
A question, a correction, or your own results? Send it here. Replies come to me by email and aren't published. Your address is only used to answer you.