- Posts: 27
- Thank you received: 0
pyVCP button to call a python script
9 years 7 months ago #89095
by AThayer
pyVCP button to call a python script was created by AThayer
Hey,
I would like to put buttons on my VCP that will run a python script. I want to call hole_circle.py with a button. Thank you for the help as I'm new to linuxcnc and making custom panels.
I would like to put buttons on my VCP that will run a python script. I want to call hole_circle.py with a button. Thank you for the help as I'm new to linuxcnc and making custom panels.
Please Log in to join the conversation.
9 years 7 months ago #89101
by andypugh
Replied by andypugh on topic pyVCP button to call a python script
You can easily embed code in a GladeVCP panel (in which case you use ordinary Glade buttons, rather than a hal_button).
This would be helpful if you were using GladeVCP.
stackoverflow.com/questions/3781851/run-...ript-passing-in-args
You would need a very minimal Python handler loaded at the same time as the GladeVCP.
However, you are trying to do it with PyVCP, and that is somewhat more kludgy.
The only way that I know to do it with PyVCP is to have the PyVCP pin connect to a halui.mdi-command-NN pin, and then have that MDI_COMMAND call the script as a custom M-code.
This would be helpful if you were using GladeVCP.
stackoverflow.com/questions/3781851/run-...ript-passing-in-args
You would need a very minimal Python handler loaded at the same time as the GladeVCP.
However, you are trying to do it with PyVCP, and that is somewhat more kludgy.
The only way that I know to do it with PyVCP is to have the PyVCP pin connect to a halui.mdi-command-NN pin, and then have that MDI_COMMAND call the script as a custom M-code.
Please Log in to join the conversation.
3 years 8 months ago #265005
by foxkid
Replied by foxkid on topic pyVCP button to call a python script
I'm not the OP, but I used the pyvcp->pin->MDI_COMMANDxx->M<xxxx>->remapped M codes to Python code. It works.
But, I've been intrigued by the fact that some of the XML is interpreted as full Python. It is difficult to know what the environment is, and how other code might be called. I've been printing information from the global environment, but haven't yet found what is accessible to Python, or how to use additional modules.
Is there a guide to the evaluation environment of the Python code embedded in the XML for pyvcp?
-- Carl
But, I've been intrigued by the fact that some of the XML is interpreted as full Python. It is difficult to know what the environment is, and how other code might be called. I've been printing information from the global environment, but haven't yet found what is accessible to Python, or how to use additional modules.
Is there a guide to the evaluation environment of the Python code embedded in the XML for pyvcp?
-- Carl
Please Log in to join the conversation.
3 years 8 months ago #265107
by cmorley
Replied by cmorley on topic pyVCP button to call a python script
Maybe you could show a sample bit of code?
Because Pyvcp doesn't run user python code.
Gladevcp and Qtvcp can though.
Because Pyvcp doesn't run user python code.
Gladevcp and Qtvcp can though.
Please Log in to join the conversation.
Time to create page: 0.076 seconds
