Hillo
When the user clicks on the program icon, there is a code that checks whether the program is running in the background or not, if the condition is met, the switch to or open this background process, or the program opens again if it was not running before
(I have a problem because it opens more than once in the taskbar)
def process():
import psutil
PROCNAME = 'test.exe'
for proc in psutil.process_iter():
try:
if proc.name().lower() == PROCNAME.lower():
return
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
pass
MainThred = QApplication([])
MainGUI = MainWindow()
MainGUI.show()
sysExit(MainThred.exec_())
if __name__ == "__main__":
process()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…