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_())
else: pyside = 'PySide2' except ImportError: pyside = 'PySide2' os.environ['QT_PREFERRED_BINDING'] = pyside 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 nukepalette from PythonEditor.ui.Qt import QtWidgets, QtGui try: app = QtWidgets.QApplication(sys.argv) except RuntimeError: # for running inside an existing app app = QtWidgets.QApplication.instance() PDF = 'PYTHONEDITOR_DEFAULT_FONT' os.environ[PDF] = 'Consolas' _ide = ide.IDE() app.setPalette(nukepalette.getNukePalette()) _ide.showMaximized() # 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: