|
1 #!/usr/bin/env python3 |
|
2 # -*- coding: utf-8 -*- |
|
3 |
|
4 # Copyright (c) 2002 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
|
5 # |
|
6 |
|
7 """ |
|
8 eric testing. |
|
9 |
|
10 This is the main Python script that performs the necessary initialization |
|
11 of the testing module and starts the Qt event loop. This is a standalone |
|
12 version of the integrated testing module. |
|
13 """ |
|
14 |
|
15 import sys |
|
16 import os |
|
17 |
|
18 sys.path.insert(1, os.path.dirname(__file__)) |
|
19 |
|
20 for arg in sys.argv[:]: |
|
21 if arg.startswith("--config="): |
|
22 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 Globals import AppInfo |
|
39 |
|
40 from Toolbox import Startup |
|
41 |
|
42 |
|
43 def createMainWidget(argv): |
|
44 """ |
|
45 Function to create the main widget. |
|
46 |
|
47 @param argv list of commandline parameters |
|
48 @type list of str |
|
49 @return reference to the main widget |
|
50 @rtype QWidget |
|
51 """ |
|
52 from Testing.TestingWidget import TestingWindow |
|
53 |
|
54 try: |
|
55 fn = argv[1] |
|
56 except IndexError: |
|
57 fn = None |
|
58 return TestingWindow(fn) |
|
59 |
|
60 |
|
61 def main(): |
|
62 """ |
|
63 Main entry point into the application. |
|
64 """ |
|
65 from PyQt6.QtGui import QGuiApplication |
|
66 |
|
67 QGuiApplication.setDesktopFileName("eric7_testing.desktop") |
|
68 |
|
69 options = [ |
|
70 ( |
|
71 "--config=configDir", |
|
72 "use the given directory as the one containing the config files", |
|
73 ), |
|
74 ( |
|
75 "--settings=settingsDir", |
|
76 "use the given directory to store the settings files", |
|
77 ), |
|
78 ] |
|
79 appinfo = AppInfo.makeAppInfo( |
|
80 sys.argv, "eric Testing", "file", "Graphical test application", options |
|
81 ) |
|
82 res = Startup.simpleAppStartup(sys.argv, appinfo, createMainWidget) |
|
83 sys.exit(res) |
|
84 |
|
85 |
|
86 if __name__ == "__main__": |
|
87 main() |