forked from plasmax/PythonEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPythonEditorLaunch.py
More file actions
71 lines (58 loc) · 2.1 KB
/
PythonEditorLaunch.py
File metadata and controls
71 lines (58 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/net/homes/mlast/bin nuke-safe-python-tg
""" Launch PythonEditor as a Standalone Application.
This file can also be executed from within an existing
Qt QApplication to launch PythonEditor in a separate window.
"""
# from __future__ import absolute_import
import sys
import os
import time
sys.dont_write_bytecode = True
start = time.time()
os.environ['PYTHONEDITOR_CAPTURE_STARTUP_STREAMS'] = '1'
# with startup variables set,
# we can now import the package in earnest.
from PythonEditor.ui import ide
from PythonEditor.ui.features import ui_palette
from PythonEditor.ui.Qt import QtWidgets
from PythonEditor.ui.Qt import QtGui
from PythonEditor.ui.Qt import QtCore
def main():
app = QtWidgets.QApplication.instance()
if not app:
app = QtWidgets.QApplication(sys.argv)
for widget in app.allWidgets():
if widget.objectName() == 'IDE':
widget.close()
PDF = 'PYTHONEDITOR_DEFAULT_FONT'
fontbase = QtGui.QFontDatabase()
current_folder = os.path.dirname(__file__)
user_font_file = os.path.join(current_folder, 'scripts', 'fonts', 'DejaVu Sans Mono for Powerline.ttf')
fontbase.addApplicationFont(user_font_file)
os.environ[PDF] = 'DejaVu Sans Mono for Powerline'
_ide = ide.IDE()
_ide.setParent(app.activeWindow())
_ide.setWindowFlags(QtCore.Qt.Window)
_ide.setPalette(ui_palette.get_palette_style())
# Plastique isn't available on Windows, so try multiple styles.
styles = QtWidgets.QStyleFactory.keys()
style_found = False
for style_name in ['Plastique', 'Fusion']:
if style_name in styles:
print('Setting style to:', style_name)
style_found = True
break
if style_found:
style = QtWidgets.QStyleFactory.create(style_name)
_ide.setStyle(style)
print('PythonEditor import time: %.04f seconds' % (time.time() - start))
#_ide.showMaximized()
_ide.show()
if app.applicationName() in ['python', 'mayapy', 'UE4Editor']:
sys.exit(app.exec_())
if __name__ == '__main__':
try:
main()
except:
import traceback
traceback.print_exc()