diff --git a/novelWriter.py b/novelWriter.py index 9cd0784c..58af6c06 100755 --- a/novelWriter.py +++ b/novelWriter.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ -novelWriter – Linux Start Script -================================ -The main start script for Linux +novelWriter – Terminal Start Script +=================================== +The main start script for the terminal """ import sys diff --git a/novelWriter.pyw b/novelWriter.pyw index a85f38ce..6a39bd3c 100644 --- a/novelWriter.pyw +++ b/novelWriter.pyw @@ -3,7 +3,7 @@ """ novelWriter – Windows Start Script ================================== -The main start script for Windows +The main start script for Windows GUI """ import os diff --git a/setup.py b/setup.py index a13ab6c4..435db317 100755 --- a/setup.py +++ b/setup.py @@ -49,7 +49,7 @@ def installPackages(hostOS): """ print("") print("Installing Dependencies") - print("#######################") + print("=======================") print("") installQueue = ["pip", "-r requirements.txt"] @@ -427,7 +427,7 @@ def freezePackage(buildWindowed, oneFile, makeSetup, hostOS): print("") print("Running PyInstaller") - print("###################") + print("===================") print("") if hostOS == OS_WIN: @@ -685,6 +685,7 @@ def xdgInstall(): def winInstall(): """Will attempt to install icons and make a launcher for Windows. """ + import winreg from nw import __version__, __hexversion__ try: import win32com.client @@ -723,18 +724,6 @@ def winInstall(): targetPy = os.path.join(targetDir, "novelWriter.pyw") targetIcon = os.path.join(targetDir, "setup", "icons", "novelwriter.ico") - os.curdir = os.path.dirname(__file__) - with open(targetPy, mode="w") as outFile: - outFile.write( - "#!/usr/bin/env python3\n" - "# -*- coding: utf-8 -*-\n\n" - "import os\n\n" - "os.curdir = os.path.abspath(os.path.dirname(__file__))\n\n" - "if __name__ == \"__main__\":\n" - " import nw\n" - " nw.main()\n" - ) - print("Collecting Info ...") print("Desktop Folder: %s" % desktopDir) print("Start Menu Folder: %s" % startMenuDir) @@ -782,6 +771,28 @@ def winInstall(): wShortcut.save() print("Created: %s" % startMenuIcon) + print("") + print("Creating registry keys ...") + + def setKey(kPath, kName, kVal): + winreg.CreateKey(winreg.HKEY_CURRENT_USER, kPath) + regKey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, kPath, 0, winreg.KEY_WRITE) + winreg.SetValueEx(regKey, kName, 0, winreg.REG_SZ, kVal) + winreg.CloseKey(regKey) + + mimeIcon = os.path.join(targetDir, "assets", "icons", "x-novelwriter-project.ico") + mimeExec = '"%s" "%s" "%%1"' % (pythonExe, targetPy) + + try: + setKey(r"Software\Classes\.nwx\OpenWithProgids", "novelWriterProject.nwx", "") + setKey(r"Software\Classes\novelWriterProject.nwx", "", "novelWriter Project File") + setKey(r"Software\Classes\novelWriterProject.nwx\DefaultIcon", "", mimeIcon) + setKey(r"Software\Classes\novelWriterProject.nwx\shell\open\command", "", mimeExec) + setKey(r"Software\Classes\Applications\novelWriter.pyw\SupportedTypes", ".nwx", "") + except WindowsError: + print("ERROR: Failed to set registry keys.") + print("") + print("") print("Done!") print("") diff --git a/setup_windows.bat b/setup_windows.bat new file mode 100644 index 00000000..c912508f --- /dev/null +++ b/setup_windows.bat @@ -0,0 +1,31 @@ +@echo off + +:: Check for Python Installation +echo. +echo Looking for Python +python --version 2>NUL +if errorlevel 1 goto errorNoPython +echo Python found. OK. +echo. + +:: Generate the sample project +python setup.py sample + +:: Install the PyQt5, lxml and pyenchant dependencies +python setup.py pip + +:: Create the desktop and start menu icons +python setup.py win-install + +pause +goto:eof + +:errorNoPython +echo. +echo ERROR^: Python is not installed on your system, or cannot be found. +echo. +echo Please download and install it from https://www.python.org/downloads/ +echo Also make sure the "Add Python to PATH" option is selected during installation. +echo. + +pause diff --git a/win_install.bat b/win_install.bat deleted file mode 100644 index b36dab22..00000000 --- a/win_install.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -python setup.py pip -python setup.py win-install -pause