Basically, I need to run a script that tells a running process (python script) to do something.
I have a pyside UI with a listview that i need to update. This is executed as a subprocess of a program (Vicon Blade).
Now I need to update the listview by running a second python script from the same program.
How do I do that? I have looked into signal, subprocess and other modules, but i can't find a proper solution, where the UI stays responsive or doesn't close.
Thanks,
Related
I wrote a program to start and stop an AutoHotKey script in the tkinter GUI for my non-coding coworkers to use but the autohotkey script has to be able to send commands through the python shell and I just realized that while the tkinter window is open, I am unable to send commands through the shell. I know theres an AutoHotKey library for Python but I really don't want to have to rewrite too much if possible. Is there anyway to keep the tkinter window up and running while also calling other functions from the shell?
I don't know what to try other than rewriting the whole thing using the AHK library.
In my code I would like to launch a function/script in another python window (say, when you run one script, a back window pops up, I want that script to manage other scripts. They don't need to communicate).
Similar to multiprocessing but they have their own pop up windows and outputs. All their information is going to be written to a file there after.
I have searched a fair amount but it seems like no one want a script to run another script in another window, potentially running 4 or 5 python windows consecutively, each using a separate core.
You should be able to use os.startfile(filename) Here is an example that runs another python file:
import os
os.startfile("File.py")
print("Started Running!")
This will open and run another python program, allowing this program to continue running.
I have a python script and I imported another script (a simple GUI window) using:
import gui
So when I run the code, the GUI pops up and I need to close the GUI in order for the script to continue executing.
Is there any way to run the entire script while keeping the GUI window open the whole time?
You might be able to do this with threading in which the GUI is running off a child thread while the rest of the script runs on the main thread.
I'm developing a script in PyScripter. When I run it in PyScripter it runs fairly well.
However, the script contains two separate threads (one Thread object, and the main flow of the script). When I run the script from the Command prompt it gets stuck in the Thread. It gives no impression of executeing the main process, and it never ends, which it does when I run it inside PyScripter. What should I do?
In your code, use timeout in join() to put time constrain on the thread. For instance
....
yourThread = threading.Thread()
yourThread.start()
yourThread.join(10.0)
....
Instructions of multithreading checks here. Hope it helps you.
I'm making a drawing program with python and pygame. I am trying to incorporate a script-fu thing in which the program opens a python live interpreter upon startup and allows the user to execute commands in the interpreter alongside the graphical interface.
My current strategy is to run the main loop inside its own thread, then have the application opened using a bash script that does 'python -i main.py'
Is this a safe/effective/ideal way of doing this? How can I use locks to ensure that commands coming in from the interpreter are executed between main loop iterations?
This is my first time using threads, so please explain to me like I am 7.
Thanks :)
The interpreter won't cooperate with locks you set (since it doesn't know about them). Thus, you cannot guarantee when the code entered by the user will execute.
Consider using the code module to build your own interactive console (it's really easy!). Then you can do the locking every time you go to execute user input.
Why are you using a third party live interpreter? Do you realize that pygame comes with one built in? The documentation is here. This will eliminate all of your problems quite easily.