Skip to content

Commit b931ba1

Browse files
committed
qtvcp -docs: add details about embedded custom qtvcp panels
1 parent cb940c8 commit b931ba1

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

docs/src/gui/qtvcp-vcp-panels.adoc

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,4 +305,75 @@ start
305305
<1> In this case we load `qtvcp` using *`-Wn`* which waits for the panel to finish loading before continuing to run the next HAL command. +
306306
This is to _ensure that the panel created HAL pins are actually done_ in case they are used in the rest of the file.
307307

308+
== Embedding QtVCP Virtual Control Panels into QtVCP Screens
309+
Qtvcp panels can be embedded into most Qtvcp screens and avoids problems such as focus transferring that can be a problem in non-native embedding.
310+
311+
=== Embedding Commands
312+
A typical screen such as QtDragon will search the INI file under the heading [DISPLAY] for commands to embed a panel.
313+
314+
[source,{ini}]
315+
----
316+
[DISPLAY]
317+
EMBED_TAB_NAME=Embedding demo
318+
EMBED_TAB_COMMAND=qtvcp simple_hal
319+
EMBED_TAB_LOCATION=tabWidget_utilities
320+
----
321+
322+
*'EMBED_TAB_NAME'*:: will typically be the title of the tab.
323+
*'EMBED_TAB_LOCATION'*:: will be specific to the screen and specifies the tabWidget or stackedWidget to embed into.
324+
*'EMBED_TAB_COMMAND'*:: is the command used to invoke loading of the panel. For native embedded panels the first word will always be 'qtvcp', the second will be the panel to load. You cannot currently add any switches to the command line. The panel will follow the debugging mode setting of the main screen.
325+
326+
=== Location of builtin Panels
327+
There are panels available that are included with linuxcnc. To see a list open a terminal and type 'qtvcp' and press return. +
328+
You will get a help printout and a list of builtin screen and panels. +
329+
Pick any of the names from the panel list and add that to the COMMAND entry after 'qtvcp'. +
330+
The builtin panel search path is 'share/qtvcp/panels/PANELNAME'. +
331+
Run-In-Place and installed versions of linuxcnc have these in different locations on the system.
332+
333+
=== Location of Custom Panels
334+
Custom panels can be embedded too -either a modified builtin panel or a new user-built one. +
335+
When loading panels, QtVCP looks in the configuration folders path for 'qtvcp/panels/PANELNAME/PANELNAME.ui'. +
336+
'PANNELNAME' being any valid string with no spaces. If no path is found there, then looks in the builtin file path. +
337+
QtVCP will do the same process for the optional handler file: 'qtvcp/panels/PANELNAME/PANELNAME_handler.py'
338+
339+
=== Handler Programming Tips
340+
In a screen handler file, the reference used for the window is 'self.w'. +
341+
In QtVCP panels, that reference will refers to the panel's window. +
342+
To reference the main window use 'self.w.MAIN'
343+
If your panel is to be able to run independently and embedded, you must trap errors from referencing objects not available.
344+
(ie main screen objects are not available in an independent panel.)
345+
346+
eg. This would use the panels preference file if there is one.
347+
[source,{hal}]
348+
----
349+
try:
350+
belt_en = self.w.PREFS_.getpref('Front_Belt_enabled', 1, int, 'SPINDLE_EXTRAS')
351+
exception:
352+
belt_en = 1
353+
----
354+
355+
This would use the main screen preference file if there is one.
356+
[source,{hal}]
357+
----
358+
try:
359+
belt_en = self.w.MAIN.PREFS_.getpref('Front_Belt_enabled', 1, int, 'SPINDLE_EXTRAS')
360+
exception:
361+
belt_en = 1
362+
----
363+
364+
=== Designer Widget Tips
365+
366+
When using python command option in Action Button widgets of an embedded panel:
367+
368+
*`INSTANCE`*::
369+
refers to the panel window
370+
E.g., `INSTANCE.my_panel_handler_function_call(True)`
371+
372+
*'MAIN_INSTANCE'*::
373+
refers to the main screen window.
374+
E.g., `INSTANCE.my_main_screen_handler_function_call(True)`
375+
376+
If the panel is not embedded, both refer to the panel window. +
377+
378+
308379
// vim: set syntax=asciidoc:

0 commit comments

Comments
 (0)