eric6/eric6_qregularexpression.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
child 6949
a5255f1ba3f0
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3
4 # Copyright (c) 2013 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
5 #
6
7 """
8 Eric6 QRegularExpression.
9
10 This is the main Python script that performs the necessary initialization
11 of the QRegularExpression wizard module and starts the Qt event loop. This is
12 a standalone version of the integrated QRegularExpression wizard.
13 """
14
15 from __future__ import unicode_literals
16
17 import Toolbox.PyQt4ImportHook # __IGNORE_WARNING__
18
19 try: # Only for Py2
20 import Globals.compatibility_fixes # __IGNORE_WARNING__
21 except (ImportError):
22 pass
23
24 import sys
25 import os
26
27 for arg in sys.argv[:]:
28 if arg.startswith("--config="):
29 import Globals
30 configDir = arg.replace("--config=", "")
31 Globals.setConfigDir(configDir)
32 sys.argv.remove(arg)
33 elif arg.startswith("--settings="):
34 from PyQt5.QtCore import QSettings
35 settingsDir = os.path.expanduser(arg.replace("--settings=", ""))
36 if not os.path.isdir(settingsDir):
37 os.makedirs(settingsDir)
38 QSettings.setPath(QSettings.IniFormat, QSettings.UserScope,
39 settingsDir)
40 sys.argv.remove(arg)
41
42 from Globals import AppInfo
43
44 from Toolbox import Startup
45
46
47 def createMainWidget(argv):
48 """
49 Function to create the main widget.
50
51 @param argv list of commandline parameters (list of strings)
52 @return reference to the main widget (QWidget)
53 """
54 from Plugins.WizardPlugins.QRegularExpressionWizard\
55 .QRegularExpressionWizardDialog import QRegularExpressionWizardWindow
56 return QRegularExpressionWizardWindow()
57
58
59 def main():
60 """
61 Main entry point into the application.
62 """
63 options = [
64 ("--config=configDir",
65 "use the given directory as the one containing the config files"),
66 ("--settings=settingsDir",
67 "use the given directory to store the settings files"),
68 ]
69 appinfo = AppInfo.makeAppInfo(
70 sys.argv,
71 "Eric6 QRegularExpression",
72 "",
73 "Regexp editor for Qt's QRegularExpression class",
74 options)
75 res = Startup.simpleAppStartup(sys.argv,
76 appinfo,
77 createMainWidget)
78 sys.exit(res)
79
80 if __name__ == '__main__':
81 main()

eric ide

mercurial