1#!/usr/bin/env python 2 3 4############################################################################# 5## 6## Copyright (C) 2013 Riverbank Computing Limited. 7## All rights reserved. 8## 9## This file is part of the examples of PyQt. 10## 11## You may use this file under the terms of the BSD license as follows: 12## 13## "Redistribution and use in source and binary forms, with or without 14## modification, are permitted provided that the following conditions are 15## met: 16## * Redistributions of source code must retain the above copyright 17## notice, this list of conditions and the following disclaimer. 18## * Redistributions in binary form must reproduce the above copyright 19## notice, this list of conditions and the following disclaimer in 20## the documentation and/or other materials provided with the 21## distribution. 22## * Neither the name of Riverbank Computing Limited nor the names of 23## its contributors may be used to endorse or promote products 24## derived from this software without specific prior written 25## permission. 26## 27## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 30## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 31## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 32## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 33## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 34## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 35## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 36## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 38## 39############################################################################# 40 41 42import sys 43import os 44 45from PyQt5.QtCore import QLibraryInfo, QProcess, QProcessEnvironment 46from PyQt5.QtWidgets import QApplication, QMessageBox 47 48 49app = QApplication(sys.argv) 50 51QMessageBox.information(None, "PyQt Designer Plugins", 52 "<p>This example will start Qt Designer when you click the <b>OK</b> " 53 "button.</p>" 54 "<p>Before doing so it sets the <tt>PYQTDESIGNERPATH</tt> environment " 55 "variable to the <tt>python</tt> directory that is part of this " 56 "example. This directory contains all the example Python plugin " 57 "modules.</p>" 58 "<p>It also sets the <tt>PYTHONPATH</tt> environment variable to the " 59 "<tt>widgets</tt> directory that is also part of this example. This " 60 "directory contains the Python modules that implement the example " 61 "custom widgets.</p>" 62 "<p>All of the example custom widgets should then appear in " 63 "Designer's widget box in the <b>PyQt Examples</b> group.</p>") 64 65# Tell Qt Designer where it can find the directory containing the plugins and 66# Python where it can find the widgets. 67base = os.path.dirname(__file__) 68env = QProcessEnvironment.systemEnvironment() 69env.insert('PYQTDESIGNERPATH', os.path.join(base, 'python')) 70env.insert('PYTHONPATH', os.path.join(base, 'widgets')) 71 72# Start Designer. 73designer = QProcess() 74designer.setProcessEnvironment(env) 75 76designer_bin = QLibraryInfo.location(QLibraryInfo.BinariesPath) 77 78if sys.platform == 'darwin': 79 designer_bin += '/Designer.app/Contents/MacOS/Designer' 80else: 81 designer_bin += '/designer' 82 83designer.start(designer_bin) 84designer.waitForFinished(-1) 85 86sys.exit(designer.exitCode()) 87