- Posts: 56
- Thank you received: 0
FlexGui custom buttons
1 year 2 weeks ago #336214
by Dave3891
FlexGui custom buttons was created by Dave3891
Hi,
I am working on a FlexGui for a waterjet and I want to have some custom buttons that call hal and emc functions.
I see I can import a python module and do the "from functools import partial" to get the parent, but does the parent also pass access to hal and emc?
I am trying to make a custom stop button that will turn off some hal output pins with hal.set_p() and then call emc.abort() in python so it will turn off the jet and sand when pressed. I also need to make one that will pause by setting the hal pins off and setting the motion.adaptivefeed to 0.
Any help would be appreciated
I am working on a FlexGui for a waterjet and I want to have some custom buttons that call hal and emc functions.
I see I can import a python module and do the "from functools import partial" to get the parent, but does the parent also pass access to hal and emc?
I am trying to make a custom stop button that will turn off some hal output pins with hal.set_p() and then call emc.abort() in python so it will turn off the jet and sand when pressed. I also need to make one that will pause by setting the hal pins off and setting the motion.adaptivefeed to 0.
Any help would be appreciated
Please Log in to join the conversation.
1 year 2 weeks ago #336437
by Dave3891
Replied by Dave3891 on topic FlexGui custom buttons
For anyone else with this question, this seems to work
parent.command passes the connection to emc
parent.command passes the connection to emc
Code:
from functools import partial
import hal
def startup(parent):
parent.JetOnBtn.clicked.connect(jet_on)
parent.JetOffBtn.clicked.connect(partial(jet_off, parent))
def jet_on():
hal.set_p("lcec.0.4.out-01", "True")
print('Jet On')
def jet_off(parent):
hal.set_p("lcec.0.4.out-01", "False")
parent.command.abort()
print('Jet Off')
Please Log in to join the conversation.
1 year 2 weeks ago #336444
by JT
Replied by JT on topic FlexGui custom buttons
If you use partial and pass the parent then you have access to everything.
There is a #flex-dev channel on the Libera.Chat which I monitor usually.
JT
There is a #flex-dev channel on the Libera.Chat which I monitor usually.
JT
Please Log in to join the conversation.
Time to create page: 0.207 seconds
