Setting initval of a spinbox in hal

More
30 Apr 2013 21:15 #33446 by ArcEye

A widget that is still missing is a label that can change his "caption" or "text" from HAL logic using a pin .


It would be nice just to have a simple way of changing a label text from On to Off for instance

When pyVCP was written I don't suppose it was envisaged what people might try to use it for.
It does a very good job of its prime purpose, a fairly simple virtual control panel.

You could trigger pre-defined text changes quite easily, so long as you can find a way to access the widgets text display mechanism.

But passing actual strings to hal pins, would have to use something like byte encoding to pass characters, which might be messy
and complicated.

I have in mind to try and find a good graphical debugger for python, something that will allow me to browse the structures and classes in the same way
that I can in C / C++.
If I can do that, I may make some progress figuring the best way to implement at least pre-defined label change.

regards

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

More
30 Apr 2013 21:37 #33448 by bigalex
Hi ArcEye.
Are you talking about an IDE for Python ?
Can I suggest to you Geany small and light and free ?
But I think you will find out some others with Google .
I'm just a Python beginner and no C language knowledge so I do not have the expertise to do this kind of stuff. :blush:
But I think that you and maybe Andy can help to implement pyVCP features.
I do not know if Anders Wallin was the Author of pyVCP but if yes why do not try to involve him ?

regards

bigalex :blink:

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

More
30 Apr 2013 22:26 #33450 by ArcEye
It's a debugger rather than an IDE I wanted.

I think I have found one, winpdb.
Looks like it should allow me to step through the execution and browse the structures, I'll see where it gets me.

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

More
30 Apr 2013 22:42 #33455 by BigJohnT
I'm watching to see what you find...

John

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

More
30 Apr 2013 23:28 - 30 Apr 2013 23:33 #33459 by bigalex
I think you have found the right one.
Just in case another one it is free for personal and non commercial use.

I love this forum , every day is a learning experience . :woohoo:
Thank you masters.


bigalex :blink:
Last edit: 30 Apr 2013 23:33 by bigalex.

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

More
01 May 2013 00:19 #33462 by ArcEye

I'm watching to see what you find...


Finally getting somewhere.

To debug a running pyvcp panel, you first need to start Axis in another screen to have a linuxcnc instance which the component can register with and create pins etc
You could probably do it through halrun, but this is easier.
(You must halt and re-start each session or you will get duplicate component errors trying to create another pyvcp component)

Then from a terminal run winpdb pyvcp ./nameofxml.xml

This will allow you to step through and create the panel whilst examining all the structures



What I had not appreciated was that the widgets used in pyvcp are not tkinter widgets but the extended tkinter bwidgets from jeplers bwidget.py

Knowing that I have now found out why the tkinter method Label.set("Text") did not work.

Now I have used the bwidget Label.config(..) method and eureka I can reset the label text at will :woohoo:

I will return to it tomorrow, but selection of per-defined text fields, such as "On" / "Off" is definitely achievable.
If I create a bit pin as a trigger for each field it should be possible to link those to the signal associated with a button say
and then the text would change dependent upon which button is active.

Need to give that side of it a bit more thought, rest my grey cells for now.

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

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

More
01 May 2013 15:50 #33478 by bigalex
A m a z i n g ! ! ! :woohoo:
If you can upgrade the usabilty of the pyVCP widgets a lot of people will deeply appreciate.
Thank you ArcEye.

bigalex :blink:

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

More
01 May 2013 18:14 - 10 Jul 2013 17:38 #33480 by ArcEye
OK, think it is sorted.

I have written a new widget called pyvcp_multilabel
It can display up to 6 different legends in the label text field, each one has a triggering bit pin which can be linked to anything suitable
It will display the text associated with the last pin triggered, so if you want to display one and then another you will have to leave a pause between triggers

The .xml format is
        <multilabel>
            <legends>["Label0" "Label1" "Label2" "Label3" "Label4" "Label5"]</legends>
            <font>("Helvetica", 20)</font>
            <disable_pin>False</disable_pin>
            <initval>0</initval>    Which legend to display by default (make sure it matches initval for linked widget if any) 
            <halpin>None</halpin>   Optional alternative name base for pins
        </multilabel>

The hal pins are created basename.widgetnumber.legendN
so in the above example the first pin would be
EDIT: pyvcp.multilabel.0.label0

Below is proof of concept screen print
EDIT: (the hal pins still have old experimental names, now set as per above to prevent huge unweildly pin names based on label text)




I have attached a zip of the new pyvcp_widgets.py to replace your old one with and a directory to be inserted into your /home/you/linuxcnc/configs directory,
which will run the example above and allow you to see how widget pins were linked etc.

In the absence of any major reported problems, once I have finished some other stuff I will add this to the patch submission

regards

EDIT:
Amended file to fix oversight which would have led to very long pin names


File Attachment:

File Name: pyvcp_widgets3.zip
File Size:21 KB
Attachments:
Last edit: 10 Jul 2013 17:38 by ArcEye.

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

More
02 May 2013 13:29 #33511 by bigalex
Hi ArcEye.
What to say ... thank you.
This feature is very nice and useful .
One question ... please do not blame me.
Are you using a "tuple" for the text list ?
To make this widget more flexible is it possible to have instead of boolean pins an integer (unsigned) pin
to define which text have to be displayed ?

bigalex :blink:

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

More
02 May 2013 15:17 #33513 by ArcEye

Are you using a "tuple" for the text list ?
To make this widget more flexible is it possible to have instead of boolean pins an integer (unsigned) pin
to define which text have to be displayed ?


The code is in the zip.

I have not used tuples, they just seem to be some sort of inflexible, bastardised string array.
Python lists are just string arrays too, you can index through them just as easily.

Far from making the widget more flexible, restricting the ability to trigger label text changes, to widgets or components that can emit the correct s32 or u32 value, would reduce its flexibility hugely.
Most state changes are signalled by a bit pin flag, the appropriate bit pin in the widget can just be linked to it in a hal file.

If you want to make changes for your own special purposes then feel free, that is what open source is about.

regards

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

Time to create page: 0.191 seconds
Powered by Kunena Forum