From 27c00f1a908ecff4da0dea5580945fbd674420bd Mon Sep 17 00:00:00 2001 From: Jonathan Harris Date: Tue, 23 Aug 2016 02:55:39 +0100 Subject: [PATCH] Allow one copy of the app at a time --- EDMarketConnector.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index d6e866c4..dc71e36e 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -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()