17 sys.path.insert(1, os.path.dirname(__file__)) |
17 sys.path.insert(1, os.path.dirname(__file__)) |
18 |
18 |
19 for arg in sys.argv[:]: |
19 for arg in sys.argv[:]: |
20 if arg.startswith("--config="): |
20 if arg.startswith("--config="): |
21 import Globals |
21 import Globals |
|
22 |
22 configDir = arg.replace("--config=", "") |
23 configDir = arg.replace("--config=", "") |
23 Globals.setConfigDir(configDir) |
24 Globals.setConfigDir(configDir) |
24 sys.argv.remove(arg) |
25 sys.argv.remove(arg) |
25 elif arg.startswith("--settings="): |
26 elif arg.startswith("--settings="): |
26 from PyQt6.QtCore import QSettings |
27 from PyQt6.QtCore import QSettings |
|
28 |
27 settingsDir = os.path.expanduser(arg.replace("--settings=", "")) |
29 settingsDir = os.path.expanduser(arg.replace("--settings=", "")) |
28 if not os.path.isdir(settingsDir): |
30 if not os.path.isdir(settingsDir): |
29 os.makedirs(settingsDir) |
31 os.makedirs(settingsDir) |
30 QSettings.setPath( |
32 QSettings.setPath( |
31 QSettings.Format.IniFormat, QSettings.Scope.UserScope, settingsDir) |
33 QSettings.Format.IniFormat, QSettings.Scope.UserScope, settingsDir |
|
34 ) |
32 sys.argv.remove(arg) |
35 sys.argv.remove(arg) |
33 |
36 |
34 from Globals import AppInfo |
37 from Globals import AppInfo |
35 |
38 |
36 from Toolbox import Startup |
39 from Toolbox import Startup |
37 |
40 |
38 |
41 |
39 def createMainWidget(argv): |
42 def createMainWidget(argv): |
40 """ |
43 """ |
41 Function to create the main widget. |
44 Function to create the main widget. |
42 |
45 |
43 @param argv list of commandline parameters |
46 @param argv list of commandline parameters |
44 @type list of str |
47 @type list of str |
45 @return reference to the main widget |
48 @return reference to the main widget |
46 @rtype QWidget |
49 @rtype QWidget |
47 """ |
50 """ |
48 from VirtualEnv.VirtualenvManagerWidgets import VirtualenvManagerWindow |
51 from VirtualEnv.VirtualenvManagerWidgets import VirtualenvManagerWindow |
|
52 |
49 return VirtualenvManagerWindow(None) |
53 return VirtualenvManagerWindow(None) |
50 |
54 |
51 |
55 |
52 def main(): |
56 def main(): |
53 """ |
57 """ |
54 Main entry point into the application. |
58 Main entry point into the application. |
55 """ |
59 """ |
56 from PyQt6.QtGui import QGuiApplication |
60 from PyQt6.QtGui import QGuiApplication |
|
61 |
57 QGuiApplication.setDesktopFileName("eric7_virtualenv.desktop") |
62 QGuiApplication.setDesktopFileName("eric7_virtualenv.desktop") |
58 |
63 |
59 options = [ |
64 options = [ |
60 ("--config=configDir", |
65 ( |
61 "use the given directory as the one containing the config files"), |
66 "--config=configDir", |
62 ("--settings=settingsDir", |
67 "use the given directory as the one containing the config files", |
63 "use the given directory to store the settings files"), |
68 ), |
|
69 ( |
|
70 "--settings=settingsDir", |
|
71 "use the given directory to store the settings files", |
|
72 ), |
64 ] |
73 ] |
65 appinfo = AppInfo.makeAppInfo( |
74 appinfo = AppInfo.makeAppInfo( |
66 sys.argv, |
75 sys.argv, |
67 "eric Virtualenv Manager", |
76 "eric Virtualenv Manager", |
68 "", |
77 "", |
69 "Utility to manage Python Virtual Environments.", |
78 "Utility to manage Python Virtual Environments.", |
70 options |
79 options, |
71 ) |
80 ) |
72 res = Startup.simpleAppStartup( |
81 res = Startup.simpleAppStartup(sys.argv, appinfo, createMainWidget) |
73 sys.argv, appinfo, createMainWidget) |
|
74 sys.exit(res) |
82 sys.exit(res) |
75 |
83 |
76 if __name__ == '__main__': |
84 |
|
85 if __name__ == "__main__": |
77 main() |
86 main() |