eric6/eric6_re.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7960
e8fc383322f7
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 #!/usr/bin/env python3
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
4 # Copyright (c) 2004 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5 #
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 """
7960
e8fc383322f7 Harmonized some user visible strings and changed the term 'eric6' to the more generic 'eric'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
8 eric Re.
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 This is the main Python script that performs the necessary initialization
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
11 of the PyRegExp wizard module and starts the Qt event loop. This is a
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
12 standalone version of the integrated PyRegExp wizard.
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 """
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
6949
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
15 import sys
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
16 import os
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
17
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
18 sys.path.insert(1, os.path.dirname(__file__))
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
19
4343
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
20 for arg in sys.argv[:]:
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 if arg.startswith("--config="):
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
22 import Globals
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 configDir = arg.replace("--config=", "")
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
24 Globals.setConfigDir(configDir)
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 sys.argv.remove(arg)
4343
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
26 elif arg.startswith("--settings="):
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
27 from PyQt5.QtCore import QSettings
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
28 settingsDir = os.path.expanduser(arg.replace("--settings=", ""))
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
29 if not os.path.isdir(settingsDir):
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
30 os.makedirs(settingsDir)
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
31 QSettings.setPath(QSettings.IniFormat, QSettings.UserScope,
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
32 settingsDir)
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
33 sys.argv.remove(arg)
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
35 from Globals import AppInfo
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
36
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
37 from Toolbox import Startup
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 def createMainWidget(argv):
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 """
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 Function to create the main widget.
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 @param argv list of commandline parameters (list of strings)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 @return reference to the main widget (QWidget)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 """
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
47 from Plugins.WizardPlugins.PyRegExpWizard.PyRegExpWizardDialog import (
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 PyRegExpWizardWindow
7257
c4d0cac9b5c9 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
49 )
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 return PyRegExpWizardWindow()
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
52
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 def main():
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 """
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 Main entry point into the application.
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 """
7380
c99320e859ca Fixed an issue related to showing the application name in the menu bar of Gnome desktop under Wayland.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
57 from PyQt5.QtGui import QGuiApplication
c99320e859ca Fixed an issue related to showing the application name in the menu bar of Gnome desktop under Wayland.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
58 QGuiApplication.setDesktopFileName("eric6_re.desktop")
c99320e859ca Fixed an issue related to showing the application name in the menu bar of Gnome desktop under Wayland.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
59
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
60 options = [
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
61 ("--config=configDir",
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
62 "use the given directory as the one containing the config files"),
4343
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
63 ("--settings=settingsDir",
afe0da217745 Added the '--settings=' command line switch to store the settings files in a non-standard directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4289
diff changeset
64 "use the given directory to store the settings files"),
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 ]
2087
795992a5c561 Made the sixth set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
66 appinfo = AppInfo.makeAppInfo(sys.argv,
7960
e8fc383322f7 Harmonized some user visible strings and changed the term 'eric6' to the more generic 'eric'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
67 "eric RE",
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 "",
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 "Regexp editor for the Python re module",
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 options)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 res = Startup.simpleAppStartup(sys.argv,
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 appinfo,
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 createMainWidget)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 sys.exit(res)
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 if __name__ == '__main__':
97
c4086afea02b Finished cleaning up the code supported by py3flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 18
diff changeset
77 main()

eric ide

mercurial