Setting initval of a spinbox in hal
- BigJohnT
-
- Offline
- Administrator
-
- Posts: 7000
- Thank you received: 1175
John
Please Log in or Create an account to join the conversation.
- ArcEye
- Offline
- Junior Member
-
- Posts: 24
- Thank you received: 758
If you think that is worth doing, the better way might be to have a field in the .xml file, called for instance writeable .
When <writeable>1</writeable> say, is found inside a widget block, the extra pin could be created giving direct access to the value output or the state of the widget etc.
If not, everything works as previously with no extra pins cluttering pyvcp.
Certainly achievable, just a question of whether it is likely to be adopted and whether it is macro managing an aspect of a larger problem, which is better addressed through gladeVCP?
I only use pyVCP for simple controls and that is probably what it is best for.
Others would use gladeVCP and I would use a Qt panel and component for something more complicated.
regards
Please Log in or Create an account to join the conversation.
- mariusl
-
Topic Author
- Offline
- Platinum Member
-
Remember that that a great many of us are not well versed in using Gladevcp. The easiest way as pyvcp. This work you have done can make the use of pyvcp even more powerful with little effort.
Please include it in the next release. We will take it anyway you give it.
Regards
Marius
www.bluearccnc.com
Please Log in or Create an account to join the conversation.
- BigJohnT
-
- Offline
- Administrator
-
- Posts: 7000
- Thank you received: 1175
JT
If you think that is worth doing, the better way might be to have a field in the .xml file, called for instance writeable .
When <writeable>1</writeable> say, is found inside a widget block, the extra pin could be created giving direct access to the value output or the state of the widget etc.
If not, everything works as previously with no extra pins cluttering pyvcp.
Certainly achievable, just a question of whether it is likely to be adopted and whether it is macro managing an aspect of a larger problem, which is better addressed through gladeVCP?
I only use pyVCP for simple controls and that is probably what it is best for.
Others would use gladeVCP and I would use a Qt panel and component for something more complicated.
regards
I'm not following the writable pin idea...
Lets take something that makes sense to me a preset for a check box. If you could have in the XML a <preset>1</preset> to indicate the state of the check box should be on when created that is what I was talking about. If you leave it out the the default state of off is how it is created.
John
Please Log in or Create an account to join the conversation.
- ArcEye
- Offline
- Junior Member
-
- Posts: 24
- Thank you received: 758
For some widgets it might make more sense to have the setting at time of creation, like your checkbox.
For others you might want to set them to initial values after startup or even dynamically during use.
Even for the checkbox, you might want to specifically check or un-check it when another button is pressed and the associated signal goes true or false
I am de-constructing vcpparse.py, pyvcp.py and pyvcp_widgets.py presently, to get to the exact mechanism for accessing the .xml values
The python notion of pointers is not the same as C, which requires some experimentation to arrive at the correct indexing method
The main idea, as you say, is to have optional fields, which if completed do something, but otherwise everything functions as previously.
It is an interesting exercise (to me at least

regards
Please Log in or Create an account to join the conversation.
- ArcEye
- Offline
- Junior Member
-
- Posts: 24
- Thank you received: 758
I have good news for you already
Lets take something that makes sense to me a preset for a check box. If you could have in the XML a <preset>1</preset> to indicate the state of the check box should be on when created...
I am working my way through the widgets, adding initval settings or settings to create parameter pins as is appropriate.
I have found that radiobuttons and checkbuttons already had an <initval> field, but it is not documented
(it was not even documented in the code for radiobox widgets)
Looks like the edit that added initvals may have been in 2007.
Try this code in an .xml file
<hbox>
<hbox>
<radiobutton>
<choices>["one","two","three"]</choices>
<halpin>"radio0"</halpin>
<initval>0</initval>
</radiobutton>
<radiobutton>
<choices>["four","five","six"]</choices>
<halpin>"radio1"</halpin>
<initval>1</initval>
</radiobutton>
<radiobutton>
<choices>["seven","eight","nine"]</choices>
<halpin>"radio2"</halpin>
<initval>2</initval>
</radiobutton>
</hbox>
<hbox>
<vbox>
<checkbutton>
<halpin>"checkbutton0"</halpin>
<text>"Button 0"</text>
<initval>1</initval>
</checkbutton>
<checkbutton>
<halpin>"checkbutton1"</halpin>
<text>"Button 1"</text>
<initval>0</initval>
</checkbutton>
<checkbutton>
<halpin>"checkbutton2"</halpin>
<text>"Button 2"</text>
<initval>0</initval>
</checkbutton>
</vbox>
<vbox>
<checkbutton>
<halpin>"checkbutton3"</halpin>
<text>"Button 3"</text>
<initval>0</initval>
</checkbutton>
<checkbutton>
<halpin>"checkbutton4"</halpin>
<text>"Button 4"</text>
<initval>1</initval>
</checkbutton>
<checkbutton>
<halpin>"checkbutton5"</halpin>
<text>"Button 5"</text>
<initval>0</initval>
</checkbutton>
</vbox>
<vbox>
<checkbutton>
<halpin>"checkbutton6"</halpin>
<text>"Button 6"</text>
<initval>0</initval>
</checkbutton>
<checkbutton>
<halpin>"checkbutton7"</halpin>
<text>"Button 7"</text>
<initval>0</initval>
</checkbutton>
<checkbutton>
<halpin>"checkbutton8"</halpin>
<text>"Button 8"</text>
<initval>1</initval>
</checkbutton>
</vbox>
</hbox>
I have edited the radiobuttons update function, to be more efficient but there is nothing to be done for checkbuttons, they work already.
regards
Please Log in or Create an account to join the conversation.
- ArcEye
- Offline
- Junior Member
-
- Posts: 24
- Thank you received: 758
Attached is a copy of the fully patched pyvcp_widgets.py file.
I have submitted the patch via sourceforge, will see how that goes.
Included in the zip is a directory you can copy to your /home/yourname/linuxcnc/configs/ directory and run the sim contained therein for a demo of the different widgets that were altered
Open a HAL configuration window to see the various pins and see the custompanel.xml file for the extra widget .xml fields.
If you find any bugs let me know, seems to be OK
regards
Please Log in or Create an account to join the conversation.
- bigalex
- Offline
- Premium Member
-
- Posts: 148
- Thank you received: 4
What you are doing on the pyVCP widgets is really remarkable.
In this way the pyVCP functionality is more flexible and usable.
I've not used GladeVCP because I'm working on an Hardy 8.04 PC and I also think that is a bit complicated (for me) at the moment.
These modifications are available as a patch or I just have to overwrite the existing installed pyvcp_widgets.py file?
Another functionality for the PyVCP widgets like buttons,radio buttons and others that can select or command something
could be an <enable> pin that enable/disable the widget from the mouse or input events dinamically from HAL logic.
Thanks
bigalex

Please Log in or Create an account to join the conversation.
- ArcEye
- Offline
- Junior Member
-
- Posts: 24
- Thank you received: 758
Glad you like the changes.
There is a patch at Sourceforge awaiting decision, but the file does not appear to have changed since 2007, so you can just re-name your old copy to be safe and copy it over.
Keyboard and mouse focus is another subject altogether.
The python gtk / Tk used with Axis and pyVCP does have some issues with focus in embedded widgets.
I am a C programmer not python, I will stay away from that area, the changes I have made are quite simple.

regards
Please Log in or Create an account to join the conversation.
- bigalex
- Offline
- Premium Member
-
- Posts: 148
- Thank you received: 4
I clearly understand that my wish is not as easy as speak .

Anyway what you did is really appreciated and should be fit as a part of the next release.
I red about your skill in C programming language in some other threads for create HAL components and you should be a good candidate
to make " a good tutorial on how to create an HAL component using comp and C lamguage ".
A widget that is still missing is a label that can change his "caption" or "text" from HAL logic using a pin .
But maybe this is OT.
Thanks
bigalex

Please Log in or Create an account to join the conversation.