eric7/eric7_snap.py

branch
eric7
changeset 8312
800c432b34c8
parent 8143
2c730d5fd177
child 8314
e3642a6a1e71
equal deleted inserted replaced
8311:4e8b98454baa 8312:800c432b34c8
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3
4 # Copyright (c) 2012 - 2021 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 PyQt5.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 PyQt5.QtGui import QGuiApplication
55 QGuiApplication.setDesktopFileName("eric6_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