Update the Python script without restarting the user interface

More
5 years 6 months ago #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
5 years 6 months ago #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
5 years 6 months ago #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
5 years 6 months ago #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
5 years 6 months ago #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
5 years 6 months ago #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.

Time to create page: 0.309 seconds
Powered by Kunena Forum