command gladevcp button call python
29 Dec 2019 16:12 #153448
by jurod
command gladevcp button call python was created 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<format_masiv> 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?
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<format_masiv> 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.
29 Dec 2019 16:55 #153457
by cmorley
Replied by cmorley on topic command gladevcp button call python
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
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.
29 Dec 2019 20:16 #153492
by jurod
Replied by jurod on topic command gladevcp button call python
OK, simple requirement. I need call from gladevcp button the .ngc file.
This (<property name="command">O<format_masiv> call </property>) work at once. It is bad. I need only load to AXIS.
The mentioned above returns an error: seeking "o" words
This (<property name="command">O<format_masiv> call </property>) work at once. It is bad. I need only load to AXIS.
The mentioned above returns an error: seeking "o" words
Please Log in or Create an account to join the conversation.
29 Dec 2019 22:03 #153517
by cmorley
Replied by cmorley on topic command gladevcp button call python
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
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.
30 Dec 2019 18:46 #153559
by jurod
Replied by jurod on topic command gladevcp button call python
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)
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)
Please Log in or Create an account to join the conversation.
30 Dec 2019 19:30 #153562
by cmorley
Replied by cmorley on topic command gladevcp button call python
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.
31 Dec 2019 09:09 #153596
by jurod
Replied by jurod on topic command gladevcp button call python
Great thanks to "Cmorley"
It works perfectly.
It works perfectly.
Please Log in or Create an account to join the conversation.
Moderators: HansU
Time to create page: 0.071 seconds