src/eric7/eric7_snap.py

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8881
54e42bc2437a
child 9221
bf71ee032bb4
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3
4 # Copyright (c) 2012 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
5 #
6
7 """
8 eric Snap.
9
10 This is the main Python script that performs the necessary initialization
11 of the snapshot module and starts the Qt event loop.
12 """
13
14 import sys
15 import os
16
17 sys.path.insert(1, os.path.dirname(__file__))
18
19 for arg in sys.argv[:]:
20 if arg.startswith("--config="):
21 import Globals
22 configDir = arg.replace("--config=", "")
23 Globals.setConfigDir(configDir)
24 sys.argv.remove(arg)
25 elif arg.startswith("--settings="):
26 from PyQt6.QtCore import QSettings
27 settingsDir = os.path.expanduser(arg.replace("--settings=", ""))
28 if not os.path.isdir(settingsDir):
29 os.makedirs(settingsDir)
30 QSettings.setPath(
31 QSettings.Format.IniFormat, QSettings.Scope.UserScope, settingsDir)
32 sys.argv.remove(arg)
33
34 from Globals import AppInfo
35
36 from Toolbox import Startup
37
38
39 def createMainWidget(argv):
40 """
41 Function to create the main widget.
42
43 @param argv list of commandline parameters (list of strings)
44 @return reference to the main widget (QWidget)
45 """
46 from Snapshot.SnapWidget import SnapWidget
47 return SnapWidget()
48
49
50 def main():
51 """
52 Main entry point into the application.
53 """
54 from PyQt6.QtGui import QGuiApplication
55 QGuiApplication.setDesktopFileName("eric7_snap.desktop")
56
57 options = [
58 ("--config=configDir",
59 "use the given directory as the one containing the config files"),
60 ("--settings=settingsDir",
61 "use the given directory to store the settings files"),
62 ]
63 appinfo = AppInfo.makeAppInfo(
64 sys.argv,
65 "eric Snap",
66 "",
67 "Simple utility to do snapshots of the screen.",
68 options)
69 res = Startup.simpleAppStartup(sys.argv,
70 appinfo,
71 createMainWidget)
72 sys.exit(res)
73
74 if __name__ == '__main__':
75 main()

eric ide

mercurial