Draft: Reimplement halshow in Python#4231
Open
petterreinholdtsen wants to merge 3 commits into
Open
Conversation
Replace the Tcl/Tk halshow (tcl/bin/halshow.tcl) with a Python/Qt
implementation using qtpy for cross-backend compatibility. The new
edition provides identical functionality plus additional features:
Core architecture:
- Direct shared memory access via _hal C extension, eliminating
subprocess overhead. Creates a minimal component "_halshow_{pid}"
that is cleanly removed on exit (ready() -> exit()) to prevent
zombie accumulation.
- Added get_info_components(), get_info_functions(),
get_info_threads() to halmodule.cc for SHM-based listing of
components/functions/threads without halcmd subprocess calls.
- Robust cleanup: atexit handler + signal handlers (SIGINT/SIGTERM/SIGHUP)
ensure component is removed from SHM on any exit path. Fixed a bug where
the old Tcl edition leaked components when exiting via SIGPIPE or
"linuxcnc -l" (which raises SystemExit).
Watch tab:
- Value|Name|Buttons layout matching Tcl halshow order
- Full pin names shown in watch rows (not truncated)
- [Tgl]/[Set]/[Clr] buttons for writable bit signals, plain value for read-only
- Buttons dynamically disabled when signal gains writers at runtime
- Halcmd fallback for writer detection on old _hal.so lacking WRITERS field
Show tab:
- Signal detail matches halcmd "show sig" monospace table format exactly
- Value right-aligned in 5-char field, matching Tcl edition
- Tree view uses monospace font with no word wrap
Main window layout:
- Tree view and tabs side-by-side in a splitter
- Command entry and status bar span full width below the splitter (Tcl match)
- All user-facing GUI text translatable via PO files / gettext (_() wrappers)
This patch was created with help from OpenCode using local llama.cpp
server with Qwen 3.6.
…zation Add a new GRAPH tab (between WATCH and SETTINGS) that renders HAL topology as a bipartite graph (component → signal → component), laid out by Graphviz dot. Graph data model: - GraphDataBuilder collects pins/signals from SHM into structured component/signal dicts, with O(1) pin-to-component index for fast edge resolution - Three-tier fallback for resolving signal connections: pure-SHM pin SIGNAL field, _hal.get_signal_connections(), or halcmd show sig via background QThread - Owner detection falls back to heuristics when old _hal.so lacks OWNER field Layout engine (GraphLayout.compute): - Builds directed AGraph with component boxes and diamond-shaped signal nodes - Runs dot for crossing-minimized placement; extracts edge splines for rendering - Coordinates scaled from points (72 dpi) to device pixels (96 dpi) Rendering (QGraphicsView scene): - ComponentItem: rounded rectangles with blue header, green IN pins (left column), red OUT pins (right column), and connection markers on edges - SignalNodeItem: orange diamonds sized to fit signal names - Edges route from writer pin → signal diamond perimeter → reader pin marker, each segment with arrowhead; uses dot splines when available, cubic bezier fallback - Multi-edge spreading between same component pair Interaction: - Pan via middle/left mouse drag; zoom via scroll wheel or +/- buttons - Right-click context menus on components (add pins to watch) and edges (watch signal) - "Hide unused pins" toggle filters component boxes to only connected pins - Lazy layout computation deferred until first tab activation CLI --dotty flag: - Print HAL topology as DOT source to stdout then exit, with layout parameters matching the GRAPH tab for debugging purposes This patch was created with help from OpenCode using local llama.cpp server with Qwen 3.6.
Contributor
|
You might want to enable the executable bit in git for halshow.py |
Collaborator
Author
|
[Luca Toniolo]
You might want to enable the executable bit in git for halshow.py
Yes, and integrate it into the build system and install rules.
I did quick testing, not looked at the graph yet, should pygraphviz
become a dependency?
Yes, it is a dependency for the graph drawing.
The grouped view of pins and parameters is the new default, but seems
not working in the port?
What is this? I do not believe I have used or seen this myself.
Something from after 2.9?
…--
Happy hacking
Petter Reinholdtsen
|
Contributor
Yes, just made it in 2.10 a few weeks back, see #4147 |
In PyQt6 and PySide6, WindowStaysOnTop moved from Qt to Qt.WindowType. Add a compatibility shim that resolves the flag for both backend families. Fixes crash when applying settings (alwaysOnTop toggle) in halshow.py. This patch was created with help from OpenCode using local llama.cpp server with Qwen 3.6.
Collaborator
Author
|
[Luca Toniolo]
Yes, just made it in 2.10 a few weeks back, see #4147
Right. Then I understand. It had an option in the settings tab, set to
true by default. There was a bug in the settings tab, now fixed, making
it impossible to flip the switch. Added the option as I was surprised
the tree did not look the way I was used to, but could drop it if the
new wanted default is the combined pin/parameter tree.
…--
Happy hacking
Petter Reinholdtsen
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace the tcl/tk implementation of halshow with a Python/Qt implementation, and add new graph support using graphviz to show the interconnection in HAL between pins and signals.