I wrote code for one program, then I generated with a pypinstaller help program.exe The problem is that this program .exe starts 3 times at the same time if you click open 3 times. Tell me please how to limit a maximum of 1 launch at the same time.


Import OS
from tkinter import *
Import tkinter as tk
From Tkinter Import MessageBox
From Tkinter Import ScrolidText
From Future.Builtins Import Int
Import Logging.
From tkinter.tix Import Shell
Import Subprocess, SYS
From Subprocess Import Popen, Pipe
From Distutils Import Command
Import Logging.
Import logging.config
from asyncio.Tasks Import Sleep
from test.test_quopri import quopritestcase
from Tools.Scripts.Fixdiv Import Report
root= tk.tk ()
root.title ("autoloader_psv5000")
canvas1= tk.canvas (root, width= 615, height= 515, bg= 'gray94', relief= 'raised')
canvas1.pack ()
label1= tk.Label (Root, Text= 'Scan Please', bg= 'gray90', font= ('helvetica', 14))
canvas1.create_window (120, 50, window= label1)
label2= tk.Label (root, text= 'report window', bg= 'gray90', font= ('helvetica', 14))
canvas1.create_window (130, 150, Window= Label2)
entry1= tk.entry (root, width= 54, bd= 5, font= ('helvetica', 12, 'bold'))
canvas1.create_Window (310, 100, Window= Entry1)
report1= tk.scrolledtext.scrolidtext (width= 49, height= 17, bd= 5, state= 'disabled', font= ('helvetica', 10, 'bold'))
canvas1.create_window (250,320, Window= Report1)
Pass= "| Status: passed |"
Fail= "| Status: Failed |"
root.mainloop (0)
  • Answer # 1

    Check whether the process started, if it is run -do something if not -continue execution.

    Import Psutil
    For proc in psutil.process_iter ():
        Name= prc.name ()
        IF Name== "Program.exe":