src/eric7/eric7_pdf.py

branch
pdf_viewer
changeset 9697
cdaa3cc805f7
child 9698
69e183e4db6f
equal deleted inserted replaced
9696:669dabfa1319 9697:cdaa3cc805f7
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3
4 # Copyright (c) 2016 - 2023 Detlev Offenbach <detlev@die-offenbachs.de>
5 #
6
7 """
8 eric PDF Viewer.
9
10 This is the main Python script that performs the necessary initialization
11 of the PDF viewer and starts the Qt event loop. This is a standalone version
12 of the integrated PDF viewer.
13 """
14
15 import os
16 import sys
17
18 from PyQt6.QtGui import QGuiApplication
19
20 for arg in sys.argv[:]:
21 if arg.startswith("--config="):
22 from eric7 import Globals
23
24 configDir = arg.replace("--config=", "")
25 Globals.setConfigDir(configDir)
26 sys.argv.remove(arg)
27 elif arg.startswith("--settings="):
28 from PyQt6.QtCore import QSettings
29
30 settingsDir = os.path.expanduser(arg.replace("--settings=", ""))
31 if not os.path.isdir(settingsDir):
32 os.makedirs(settingsDir)
33 QSettings.setPath(
34 QSettings.Format.IniFormat, QSettings.Scope.UserScope, settingsDir
35 )
36 sys.argv.remove(arg)
37
38 from eric7.Globals import AppInfo
39 from eric7.Toolbox import Startup
40
41
42 def createMainWidget(argv):
43 """
44 Function to create the main widget.
45
46 @param argv list of commandline parameters (list of strings)
47 @return reference to the main widget (QWidget)
48 """
49 from eric7.PdfViewer.PdfViewerWindow import PdfViewerWindow
50
51 try:
52 fileName = argv[1]
53 except IndexError:
54 fileName = ""
55
56 editor = PdfViewerWindow(fileName, None)
57 return editor
58
59
60 def main():
61 """
62 Main entry point into the application.
63 """
64 QGuiApplication.setDesktopFileName("eric7_pdf.desktop")
65
66 options = [
67 (
68 "--config=configDir",
69 "use the given directory as the one containing the config files",
70 ),
71 (
72 "--settings=settingsDir",
73 "use the given directory to store the settings files",
74 ),
75 ("", "name of file to edit"),
76 ]
77 appinfo = AppInfo.makeAppInfo(
78 sys.argv, "eric PDF Viewer", "", "Little tool to view PDF files.", options
79 )
80 res = Startup.simpleAppStartup(sys.argv, appinfo, createMainWidget)
81 sys.exit(res)
82
83
84 if __name__ == "__main__":
85 main()

eric ide

mercurial