HOW  TO
HOW TO

Reputation: 5

I want to prevent tkinter .exe from starting multiple times

I compile my Python tkinter code, when I run *.exe twice, there are two main tkinter windows (same as when I run windows notepad.exe twice).

But I want to prevent tkinter .exe from being able to start twice. What can I do so that tkinter can only be started once? Whether or not I click tkinter.exe on the windows desktop dozens of times.

Upvotes: 0

Views: 525

Answers (1)

Ferret
Ferret

Reputation: 162

Requirements pip install wmi

Suggested Solution

if "tkinkter.exe" in [ x.Name for x in wmi.WMI().Win32_Process() ]:
   exit()

Source: https://www.geeksforgeeks.org/python-get-list-of-running-processes/#:~:text=Win32_Process%20function%20in%20order%20to,and%20stored%20in%20variable%20process.

Upvotes: 1

Related Questions