command gladevcp button call python

More
29 Dec 2019 16:12 #153448 by jurod
Hi people, i would like call python script from gladevcp button. I need open file to AXIS via python.
This no working:

<child>
<object class="HAL_Button" id="for_mas">
<property name="label" translatable="yes">ODOSLAT</property>
<property name="width_request">100</property>
<property name="height_request">25</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="related_action">form_mas_run</property>
</object>
<packing>
<property name="x">50</property>
<property name="y">450</property>
</packing>
<object class="EMC_Action_MDI" id="form_mas_run">
<property name="command">O&lt;format_masiv&gt; call </property>
</object>
</child>



from math import *
import sys
import linuxcnc
c = linuxcnc . command ()
c.mode(linuxcnc.MODE_AUTO)
c.reset_interpreter()
c.program_open("format_masiv.ngc")


Any idea?

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

More
29 Dec 2019 16:55 #153457 by cmorley
There are really too many thing that could be wrong to begin meaningful trouble shooting.
In general posting code and saying that it doesn't work is not going to get good responses - It's like saying your car doesn't start and asking why - could be a million things.
You didn't even mention if linuxcnc crashes or just didn't do what you thought it should.

The gladevcp loading line in the INI may not find the python file.
Some small name typo could be the problem.

Often linuxcnc will print clues in the terminal.

There is a sample sim axis/gladevcp that demonstrates how to get commands to be run using gladevcp - I suggest playing with it to gain experience.

Also posting copies of the related files, mentioning the version of linuxcnc and stating what you thought should happen and also what did or didn't happen helps pinpoint issues.

Finally I believe if you load a program for axis in this way the graphics plot will not update properly - but there is a work around (you can ask AXIS to load the program in various ways depending on what version of linuxcnc you are using).

I know this very request has been done in the forum already i just couldn't find it...

Chris

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

More
29 Dec 2019 20:16 #153492 by jurod
OK, simple requirement. I need call from gladevcp button the .ngc file.
This (<property name="command">O&lt;format_masiv&gt; call </property>) work at once. It is bad. I need only load to AXIS.
The mentioned above returns an error: seeking "o" words
Attachments:

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

More
29 Dec 2019 22:03 #153517 by cmorley
MDI_Actions can only call MDI commands - there is no MDI command to open a progam.
You must use a python gladevcp extension to do what you want.

linuxcnc.org/docs/2.7/html/gui/gladevcp....user_defined_actions

Chris

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

More
30 Dec 2019 18:46 #153559 by jurod
Thanks for help. This is the right way.
Now I have another problem.
This python works, but badly:


#!/usr/bin/env python

import os,sys
from gladevcp.persistence import IniFile,widget_defaults,set_debug,select_widgets
import hal
import hal_glib
import gtk
import glib
import linuxcnc
from Tkinter import *
from math import *
s = linuxcnc.stat()
c = linuxcnc.command()
e = linuxcnc.error_channel()

def on_for_mas_pressed(data=None):

c.mode(linuxcnc.MODE_AUTO)
c.wait_complete()
c.program_open("Format_masiv.ngc")
c.wait_complete()
c.mode(linuxcnc.MODE_MANUAL)

When the button is pressed, the program overwrites only the top names but nothing in the system.
Gcod without changes. (my gcod is ok, link also)
Attachments:

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

More
30 Dec 2019 19:30 #153562 by cmorley
Try something like this:
#!/usr/bin/env python
from subprocess import call

def on_for_mas_pressed(data=None):
   call(['axis-remote','Format_masiv.ngc'])

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

More
31 Dec 2019 09:09 #153596 by jurod
Great thanks to "Cmorley"
It works perfectly.

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

Moderators: mhaberlerHansU
Time to create page: 0.094 seconds
Powered by Kunena Forum