From db3db48e5ce7c862ce02d0ef662189684fd25786 Mon Sep 17 00:00:00 2001 From: davide-romanini Date: Sun, 6 Oct 2019 05:15:18 -0700 Subject: [PATCH] Better console handling on Windows (#162) --- comictagger.spec | 4 +++- comictaggerlib/main.py | 14 ++++++-------- comictaggerlib/options.py | 5 +++-- comictaggerlib/taggerwindow.py | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/comictagger.spec b/comictagger.spec index 99197ec..bb4f935 100644 --- a/comictagger.spec +++ b/comictagger.spec @@ -4,6 +4,7 @@ import platform from os.path import join from comictaggerlib import ctversion +enable_console = False binaries = [] block_cipher = None @@ -15,6 +16,7 @@ if platform.system() == "Windows": (join(sitepackages, "PyQt5/Qt/bin/libeay32.dll"), "./PyQt5/Qt/bin"), (join(sitepackages, "PyQt5/Qt/bin/ssleay32.dll"), "./PyQt5/Qt/bin") ]) + enable_console = True a = Analysis(['comictagger.py'], binaries=binaries, @@ -39,7 +41,7 @@ exe = EXE(pyz, debug=False, strip=False, upx=True, - console=True, + console=enable_console, icon="windows/app.ico" ) app = BUNDLE(exe, diff --git a/comictaggerlib/main.py b/comictaggerlib/main.py index 0a647ae..1354ca4 100755 --- a/comictaggerlib/main.py +++ b/comictaggerlib/main.py @@ -61,14 +61,7 @@ def ctmain(): if opts.no_gui: cli.cli_mode(opts, SETTINGS) else: - - os.environ['QT_AUTO_SCREEN_SCALE_FACTOR'] = '1' - - #if platform.system() == "Darwin": - # QtWidgets.QApplication.setStyle("macintosh") - #else: - # QtWidgets.QApplication.setStyle("Fusion") - + os.environ['QT_AUTO_SCREEN_SCALE_FACTOR'] = '1' app = QtWidgets.QApplication(sys.argv) if platform.system() == "Darwin": # Set the MacOS dock icon @@ -81,6 +74,11 @@ def ctmain(): import ctypes myappid = u'comictagger' # arbitrary string ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid) + # force close of console window + SWP_HIDEWINDOW = 0x0080 + consoleWnd = ctypes.windll.kernel32.GetConsoleWindow() + if consoleWnd != 0: + ctypes.windll.user32.SetWindowPos(consoleWnd, None, 0, 0, 0, 0, SWP_HIDEWINDOW) if platform.system() != "Linux": img = QtGui.QPixmap(ComicTaggerSettings.getGraphic('tags.png')) diff --git a/comictaggerlib/options.py b/comictaggerlib/options.py index a4e055b..eff0c78 100644 --- a/comictaggerlib/options.py +++ b/comictaggerlib/options.py @@ -25,6 +25,7 @@ try: except ImportError: pass +from datetime import datetime from .genericmetadata import GenericMetadata from .comicarchive import MetaDataStyle from .versionchecker import VersionChecker @@ -103,7 +104,7 @@ If no options are given, {0} will run in windowed mode. --version Display version. -h, --help Display this message. -For more help visit the wiki at: http://code.google.com/p/comictagger/ +For more help visit the wiki at: https://github.com/comictagger/comictagger/wiki """ def __init__(self): @@ -341,7 +342,7 @@ For more help visit the wiki at: http://code.google.com/p/comictagger/ self.only_set_key = True if o == "--version": print(( - "ComicTagger {0}: Copyright (c) 2012-2014 Anthony Beville".format(ctversion.version))) + "ComicTagger {}: Copyright (c) 2012-{:%Y} ComicTagger Team".format(ctversion.version, datetime.today()))) print( "Distributed under Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)") sys.exit(0) diff --git a/comictaggerlib/taggerwindow.py b/comictaggerlib/taggerwindow.py index 62bf4cc..726b860 100644 --- a/comictaggerlib/taggerwindow.py +++ b/comictaggerlib/taggerwindow.py @@ -2103,7 +2103,7 @@ class TaggerWindow(QtWidgets.QMainWindow): def versionCheckComplete(self, new_version): if (new_version != self.version and new_version != self.settings.dont_notify_about_this_version): - website = "http://code.google.com/p/comictagger" + website = "https://github.com/comictagger/comictagger" checked = OptionalMessageDialog.msg( self, "New version available!",