Setting initval of a spinbox in hal

More
23 Apr 2013 18:50 #33052 by BigJohnT
I think it would be very useful to be able to set the initial value of just about every pyvcp widget. I always want my light check box on when I start up my lathe and only turn it off after it is off and running.

John

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

More
23 Apr 2013 23:29 #33075 by ArcEye
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

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

More
24 Apr 2013 04:09 #33090 by mariusl
I have to agree with John. This is very useful.
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.

More
24 Apr 2013 18:04 #33128 by BigJohnT

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.

More
24 Apr 2013 18:30 #33130 by ArcEye
Hi JT

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 B) ) if nothing else

regards
The following user(s) said Thank You: BigJohnT

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

More
24 Apr 2013 23:44 - 25 Apr 2013 13:30 #33153 by ArcEye
Hi JT

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
Last edit: 25 Apr 2013 13:30 by ArcEye.

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

More
25 Apr 2013 23:21 #33204 by ArcEye
Hi

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


File Attachment:

File Name: pyvcp_widgets.zip
File Size:19 KB
Attachments:

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

More
30 Apr 2013 16:38 - 30 Apr 2013 16:51 #33429 by bigalex
Hi ArcEye.
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 :blink:
Last edit: 30 Apr 2013 16:51 by bigalex.

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

More
30 Apr 2013 18:22 - 30 Apr 2013 18:23 #33433 by ArcEye
Hi

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. :P

regards
Last edit: 30 Apr 2013 18:23 by ArcEye.

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

More
30 Apr 2013 19:31 - 30 Apr 2013 19:43 #33434 by bigalex
Hi ArcEye.
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 :blink:
Last edit: 30 Apr 2013 19:43 by bigalex.

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

Time to create page: 0.077 seconds
Powered by Kunena Forum