GUI Modification Plasma

More
01 Dec 2016 15:25 #83526 by islander261
Replied by islander261 on topic GUI Modification Plasma
Hello

Well it's off to 3 days of selling at a holiday craft fair on another island for the next 4 days so Ill have some time away from this.

Things were doing going well until I tried to add a feed override control to one of the tabs will the plasma.glade file and plasma.py file. Now I get a funny screen, it looks like the plasma.glade file doesn't load at all, see screen shot. Other things I noticed;
1. The other tab expands to take the space of the plasma.glade tab.
2. The plasma.py file doesn't run correctly, no plasma.pyc file or plasma.var file created.

John
Attachments:

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

More
01 Dec 2016 19:18 #83535 by newbynobi
Replied by newbynobi on topic GUI Modification Plasma

Ultimately I want control and display of persistent variables in more than one tab from any tab they are visible in, I am sure this is not a trivial matter.


That is trivial, just handle only one and connect that hal pin to the slave displays!
net sync_hal hal_slave_pin1 <= hal_slave_pin2 <= hal_slave_pin3 <= source_hal_pin

I still can't find the SpeedControl widget when using the Glade editor, is it possible to add it editing the Glade file with a text editor? The best solution is if someone can point me to instructions for adding it. I am using Glade 3.8.5 and think that I have most of the other HAL widgets.


It is not included in the normal releases, but only in master branch.
You need the files:
speedcontrol.py
widget_gladevcp_speedcontrol.png
hal_python.xml
hal_pythonplugin.py
from master.

Just copy them to your catalog, usually in
/usr/lib/pymodules/python2.7/gladevcp
and
/usr/share/pyshared/gladevcp

Just copy them to both directories.

gladevcp -c switch

the switch needs an argument, have you added it?
gladevcp -x {XID} -c myname -u plasma.py -H plasma.hal plasma.glade

Norbert

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

More
01 Dec 2016 19:21 #83536 by newbynobi
Replied by newbynobi on topic GUI Modification Plasma
Please start your config from a terminal. You will be able to see the output / error that prevent the tab to load.

Norbert

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

More
01 Dec 2016 20:18 #83539 by islander261
Replied by islander261 on topic GUI Modification Plasma
Norbert

Thank you, I didn't know about starting from the terminal. This will save me a lot of head scratching when things don't work.

John

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

More
01 Dec 2016 20:35 #83540 by islander261
Replied by islander261 on topic GUI Modification Plasma
Norbert

Well I thought I was on my way down a directed path.. Please find attached a screen capture from the terminal when I start Linuxcnc. There appear to be a number of errors but the messages don't make much sense to me.

John
Attachments:

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

More
01 Dec 2016 22:03 - 01 Dec 2016 22:08 #83542 by newbynobi
Replied by newbynobi on topic GUI Modification Plasma
Hallo John,

Very clear:-)
Traceback (most recent call last): File "/usr/bin/gladevcp", line 309, in <module> main() File "/usr/bin/gladevcp", line 210, in main 
handlers = load_handlers(opts.usermod,halcomp,builder,opts.useropts) File "/usr/bin/gladevcp", line 111, in load_handlers 
mod = __import__(basename) File "./plasma.py", line 110 
self.target_voltage = hal_glib.GPin(halcomp.newpin("Target-Voltage-Main", hal.HAL_FLOAT, hal.HAL_OUT))

IndentationError: unexpected indent

Just correct that!

It is a typical python error, please use only spaces, mot tabs to ident!

Norbert
Last edit: 01 Dec 2016 22:08 by newbynobi.

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

More
02 Dec 2016 02:48 #83554 by islander261
Replied by islander261 on topic GUI Modification Plasma
Norbert

Thank you.

"
That is trivial, just handle only one and connect that hal pin to the slave displays!

net sync_hal hal_slave_pin1 <= hal_slave_pin2 <= hal_slave_pin3 <= source_hal_pin
"
Ok this very similar to what I did to get the arc voltage to display in both tabs. I assume that to do this for other values I will need to change the GTK label widgets to HAL label widgets? Or is there some way to access the GTK widgets from the HAL?

John

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

More
02 Dec 2016 09:44 #83563 by newbynobi
Replied by newbynobi on topic GUI Modification Plasma
Hallo John,

the best solution would be to replace the normal labels with hal labels.
If you do not want to do that, you would need to use python code and include a hal pin change event to react to changes and update the labels.
self.adjustment = gtk.Adjustment(self._value, self._min, self._max, self._increment, 0)
self.adjustment.connect("value_changed", self._on_value_changed)

Does include a gtk adjustment and emits a signal if the value change. Your code must have a function
def _on_value_changed(self, data = None):

Same can be done with hal pin ;-)

Do you know this doku / tutorial?
Cutom GUI Tutorial
extending linuxcnc

Norbert

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

More
09 Dec 2016 20:57 #83845 by islander261
Replied by islander261 on topic GUI Modification Plasma
Hello

I am figuring out more about using Glade and Python to work on button in my custom tabs. I am still missing a vital part in my understanding of how everything connects together. What I want to do is have controls in two tabs that modify the same HAL pin and display the correct value as a label in each tab. I looked at trying to use HAL pins but quickly got tangled up in the whole direction issue with them. I am sure now that Python is the correct way to go for this. So what I want to do is:

1. Have two separate tabs, one as a tab over the preview and one as a replacement for the spindle speed-coolant part of the main screen. I presently have this implemented by hacking the Norbert's plasma edition of Gmoccapy. Each section is stand alone and works.
2. I want to have some of the controls common to both tabs.
3. I want to have the variables for both tabs, both common and unique saved at shutdown and restored on starting. I now have this working with the hacked plasma screen files as unique variables for each tab only.

What I have tried to do. Leaving the Glade files for each tab alone I have tried modify the Python code so that a button push in one tab modifies the value in both tabs. In the case I experimented with I did this:
1. I added this statement at the top of the Python file so I could get to the variables and widgets contained in the other file.
import plasma_tab
While some things seemed to work the statements that actually modified the variables always caused errors.
        self.halcomp["Target-Voltage-Main"] = widget.get_value()          #stock statement works
        self.lbl_prog_volt_main.set_label("%d" % (widget.get_value()))  #stock statement works
        plasma_tab.halcomp["Target-Voltage"] = widget.get_value()     #my additional statements referencing the other tab
        plasma_tab.lbl_prog_volt.set_label("%d" % (widget.get_value()))
The error works back to a problem with "builder" as reported when LCNC is started from the terminal.
I have this line with the rest of the connections and it causes the same problem:
        self.lbl_prog_volt_main = self.builder.get_object("lbl_prog_volt_main")         #stock works
        plasma_tab.lbl_prog_volt = plasma_tab.builder.get_object("lbl_prog_volt")   #my added statement doesn't work

I am sure that this is a problem with variable visibility between Python files but I don't know how to do equal of including a header file in the Python code.

Any tips or tuts on doing this will be helpful. I have Googled both Python and Glade references and have quickly descended in to version hell with no examples of the exact thing I want to do.

John
Attachments:

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

More
09 Dec 2016 21:37 #83847 by andypugh
Replied by andypugh on topic GUI Modification Plasma

What I want to do is have controls in two tabs that modify the same HAL pin and display the correct value as a label in each tab. I looked at trying to use HAL pins but quickly got tangled up in the whole direction issue with them. I am sure now that Python is the correct way to go for this.


I don't think that HAL or Python are the right way.

Try the attached glade file

(you can test it with:
halrun
loadusr gladevecp test.ui
loadusr halmeter pin test.hal_spinbutton1-s

It has one tab with a HAL_spinbutton and 2 more tabs with a standard Glade Spinbutton. But they all share the same "Adjustment" so display the same value. Changing the normal spindbuttons changes the adjustment which changes the HAL_spinbutton which changes the HAL pin.
Attachments:

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

Moderators: newbynobiHansU
Time to create page: 0.219 seconds
Powered by Kunena Forum