src/eric7/eric7_tray.py

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

eric ide

mercurial