Update the Python script without restarting the user interface

More
15 Apr 2021 11:04 #205993 by elisa
Hello everybody,

I have a question, is it possible to update a Python script without restarting the UI?


In my case, I have a Python scrpt in which I have to change the value of a variable depending on the task to be performed. However, every time I update the python script, I have to restart the UI and re-home each axis, which is a waste of time.


Any suggestions?

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

More
15 Apr 2021 18:57 #206034 by cmorley
that's usually what GUIs are for - take input from the user and process it somehow.
I suggest you do that.

Your question is vague, so i may have not understood exactly what you want.
The following user(s) said Thank You: elisa

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

More
15 Apr 2021 19:39 #206036 by elisa
I try to explain myself better: I have a python script that saves the current joints angles if the value measured by a sensor is less than a threshold, for example less than 50.
However, depending on the task to be performed, this value varies. So, I have to update the threshold in the python script but unfortunately the GUI won't update accordingly. That is, it executes the old python script as if it were not up to date. As a result, I have to close the GUI, rerun it and re-home the joints, which is a waste of time ...

I was wondering if there was a way to make the GUI read the updated python script without closing it and restarting it from the terminal

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

More
15 Apr 2021 20:58 #206045 by andypugh
One possibility here would be to have the Python script create a HAL pin, then you can change the value of the HAL pin and the Python code can use the new value.
The following user(s) said Thank You: elisa

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

More
15 Apr 2021 21:41 #206052 by cmorley
If your script is imported to the main python program, you could try this - never tried it.

docs.python.org/2/library/functions.html#reload

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

More
16 Apr 2021 09:23 #206097 by elisa
Yes, this would be perfect.

But how can I change the value of the HAL pin? From the MDI?

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

More
18 Apr 2021 10:29 #206288 by andypugh

But how can I change the value of the HAL pin? From the MDI?


You could link the HAL pin to a GUI element such as a slider (using PyVCP, GLadeVCP, QTVCP) or to a G-code "Analog out" pin (See the docs for M67 ), write a custom M-code to set it via the "halcmd setp" method, or simply set it from the command-line with " halcmd setp"
The following user(s) said Thank You: elisa

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

More
18 Apr 2021 12:41 #206302 by elisa
I linked it to a GUI element. Thank you!

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

Time to create page: 0.075 seconds
Powered by Kunena Forum