1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-18 18:07:37 +03:00

Allow one copy of the app at a time

This commit is contained in:
Jonathan Harris 2016-08-23 02:55:39 +01:00
parent 7bfa188e90
commit 27c00f1a90

View File

@ -598,6 +598,16 @@ class AppWindow:
# Run the app
if __name__ == "__main__":
# Ensure only one copy of the app is running. OSX does this automatically. Linux TODO.
if platform == 'win32':
import ctypes
h = ctypes.windll.user32.FindWindowW(u'TkTopLevel', unicode(applongname))
if h:
ctypes.windll.user32.ShowWindow(h, 9) # SW_RESTORE
ctypes.windll.user32.SetForegroundWindow(h) # Probably not necessary
sys.exit(0)
root = tk.Tk()
app = AppWindow(root)
root.mainloop()