mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-07 19:03:23 +03:00
Move "only run once" code into def enforce_single_instance()
This commit is contained in:
parent
5aaf88b281
commit
e1752506c5
@ -880,13 +880,12 @@ class AppWindow(object):
|
|||||||
self.theme_menubar.grid_remove()
|
self.theme_menubar.grid_remove()
|
||||||
self.blank_menubar.grid(row=0, columnspan=2, sticky=tk.NSEW)
|
self.blank_menubar.grid(row=0, columnspan=2, sticky=tk.NSEW)
|
||||||
|
|
||||||
# Run the app
|
|
||||||
if __name__ == "__main__":
|
|
||||||
|
|
||||||
|
def enforce_single_instance() -> None:
|
||||||
# Ensure only one copy of the app is running under this user account. OSX does this automatically. Linux TODO.
|
# Ensure only one copy of the app is running under this user account. OSX does this automatically. Linux TODO.
|
||||||
if platform == 'win32':
|
if platform == 'win32':
|
||||||
import ctypes
|
import ctypes
|
||||||
from ctypes.wintypes import *
|
from ctypes.wintypes import HWND, LPWSTR, LPCWSTR, INT, BOOL, LPARAM
|
||||||
EnumWindows = ctypes.windll.user32.EnumWindows
|
EnumWindows = ctypes.windll.user32.EnumWindows
|
||||||
GetClassName = ctypes.windll.user32.GetClassNameW
|
GetClassName = ctypes.windll.user32.GetClassNameW
|
||||||
GetClassName.argtypes = [HWND, LPWSTR, ctypes.c_int]
|
GetClassName.argtypes = [HWND, LPWSTR, ctypes.c_int]
|
||||||
@ -935,6 +934,10 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
EnumWindows(enumwindowsproc, 0)
|
EnumWindows(enumwindowsproc, 0)
|
||||||
|
|
||||||
|
# Run the app
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
enforce_single_instance()
|
||||||
if getattr(sys, 'frozen', False):
|
if getattr(sys, 'frozen', False):
|
||||||
# By default py2exe tries to write log to dirname(sys.executable) which fails when installed
|
# By default py2exe tries to write log to dirname(sys.executable) which fails when installed
|
||||||
import tempfile
|
import tempfile
|
||||||
|
Loading…
x
Reference in New Issue
Block a user