Aug-13-2019, 03:40 PM
(This post was last modified: Aug-13-2019, 03:40 PM by LavaCreeperKing.)
I am using PyQt. I have tried to use subprocess.run() and subprocess.call(). From what I understand is that it executes a command, but then waits for it to exit before I can continue and I don't want it to wait. I need it to run the program/file then allow me to also run other commands. A good way to describe what I want to do is basically create a program like the start menu in windows. Here is an example of some code that I tried where I create a new thread for launching programs.
class thread(QtCore.QThread): def __init__(self): super(thread, self).__init__() self.program = ''#path to program self.target = ''#path to file for program to open def run(self): while True: print('-')#prints when loop runs. Shows that loop stops after command executed until you close the created process if self.Program != '': call(r'%s' % self.program)#runs command self.program = ''#resets time.sleep(0.7)#Prevents CPU use by waiting a short time between runsIf I set the program to 'explorer' then the loop does not freeze, but I can't set a target file if I set the program to 'explorer' because I would have to set the target as the program I want to run so I won't be able to set a target file. Or I use explorer to open a file but It will only open with the default program set to open it.