src/eric7/eric7_testing.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9264
18a7312cfdb3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
18 sys.path.insert(1, os.path.dirname(__file__)) 18 sys.path.insert(1, os.path.dirname(__file__))
19 19
20 for arg in sys.argv[:]: 20 for arg in sys.argv[:]:
21 if arg.startswith("--config="): 21 if arg.startswith("--config="):
22 import Globals 22 import Globals
23
23 configDir = arg.replace("--config=", "") 24 configDir = arg.replace("--config=", "")
24 Globals.setConfigDir(configDir) 25 Globals.setConfigDir(configDir)
25 sys.argv.remove(arg) 26 sys.argv.remove(arg)
26 elif arg.startswith("--settings="): 27 elif arg.startswith("--settings="):
27 from PyQt6.QtCore import QSettings 28 from PyQt6.QtCore import QSettings
29
28 settingsDir = os.path.expanduser(arg.replace("--settings=", "")) 30 settingsDir = os.path.expanduser(arg.replace("--settings=", ""))
29 if not os.path.isdir(settingsDir): 31 if not os.path.isdir(settingsDir):
30 os.makedirs(settingsDir) 32 os.makedirs(settingsDir)
31 QSettings.setPath( 33 QSettings.setPath(
32 QSettings.Format.IniFormat, QSettings.Scope.UserScope, settingsDir) 34 QSettings.Format.IniFormat, QSettings.Scope.UserScope, settingsDir
35 )
33 sys.argv.remove(arg) 36 sys.argv.remove(arg)
34 37
35 from Globals import AppInfo 38 from Globals import AppInfo
36 39
37 from Toolbox import Startup 40 from Toolbox import Startup
38 41
39 42
40 def createMainWidget(argv): 43 def createMainWidget(argv):
41 """ 44 """
42 Function to create the main widget. 45 Function to create the main widget.
43 46
44 @param argv list of commandline parameters 47 @param argv list of commandline parameters
45 @type list of str 48 @type list of str
46 @return reference to the main widget 49 @return reference to the main widget
47 @rtype QWidget 50 @rtype QWidget
48 """ 51 """
49 from Testing.TestingWidget import TestingWindow 52 from Testing.TestingWidget import TestingWindow
53
50 try: 54 try:
51 fn = argv[1] 55 fn = argv[1]
52 except IndexError: 56 except IndexError:
53 fn = None 57 fn = None
54 return TestingWindow(fn) 58 return TestingWindow(fn)
57 def main(): 61 def main():
58 """ 62 """
59 Main entry point into the application. 63 Main entry point into the application.
60 """ 64 """
61 from PyQt6.QtGui import QGuiApplication 65 from PyQt6.QtGui import QGuiApplication
66
62 QGuiApplication.setDesktopFileName("eric7_testing.desktop") 67 QGuiApplication.setDesktopFileName("eric7_testing.desktop")
63 68
64 options = [ 69 options = [
65 ("--config=configDir", 70 (
66 "use the given directory as the one containing the config files"), 71 "--config=configDir",
67 ("--settings=settingsDir", 72 "use the given directory as the one containing the config files",
68 "use the given directory to store the settings files"), 73 ),
74 (
75 "--settings=settingsDir",
76 "use the given directory to store the settings files",
77 ),
69 ] 78 ]
70 appinfo = AppInfo.makeAppInfo(sys.argv, 79 appinfo = AppInfo.makeAppInfo(
71 "eric Testing", 80 sys.argv, "eric Testing", "file", "Graphical test application", options
72 "file", 81 )
73 "Graphical test application", 82 res = Startup.simpleAppStartup(sys.argv, appinfo, createMainWidget)
74 options)
75 res = Startup.simpleAppStartup(sys.argv,
76 appinfo,
77 createMainWidget)
78 sys.exit(res) 83 sys.exit(res)
79 84
80 if __name__ == '__main__': 85
86 if __name__ == "__main__":
81 main() 87 main()

eric ide

mercurial