[Eric] Re: QT Designer & Plugins on PyQT
Detlev Offenbach
detlev at die-offenbachs.de
Sat Jun 20 13:50:03 BST 2009
On Dienstag, 16. Juni 2009, Сергей Гринько wrote:
> I suggest to add at the level of the project, two new properties:
> 1) "PYQTDESIGNERPATH" - the way the search module plug-ins for QT-Designer
> (custom widgets)
> 2) "PYTHONPATH" - module search path for the realization of QT-Designer
> (custom widgets)
>
> The module UserInterface.py in class UserInterface method __designer () add
> the code reads these properties and changing environment.
> Example:
>
> import os
> ...
> class UserInterface(KQMainWindow):
> ...
> # Set a specified environment variable with a directory name.
> def setEnvDesigner(self, var_name, dir_name):
> # Convert the relative directory name to an absolute one.
> os.putenv(var_name, os.path.join(self.project.ppath, dir_name))
>
> def __designer(self, fn = None, version = 0):
> ...
> # Tell Qt Designer where it can find the directory containing the
> plugins and
> # Python where it can find the widgets.
> # "kernel/UI/widgets/plugins" - sample path (must be read from the
> properties of the project)
> # "kernel/UI/widgets" - sample path (must be read from the
> properties of the project)
Which properties should this be in order to work in general? Right now I don't
see a generic approach.
> self.setEnvDesigner("PYQTDESIGNERPATH",
> "kernel/UI/widgets/plugins") self.setEnvDesigner("PYTHONPATH",
> "kernel/UI/widgets")
> #
> proc = QProcess()
> if not proc.startDetached(designer, args):
> KQMessageBox.critical(self,
> self.trUtf8('Process Generation Error'),
> self.trUtf8(
> '<p>Could not start Qt-Designer.<br>'
> 'Ensure that it is available as <b>%1</b>.</p>'
> ).arg(designer))
>
> Following these changes, everything works well.
>
> 9 июня 2009 г. 13:08 пользователь Сергей Гринько
>
> <sergey.grinko at gmail.com>написал:
> > I use Eric 4.3.4
> > How to make it possible to start with QT Designer, designate the path
> > search directory containing the plugins and Python where it can find the
> > widgets.
> > Example:
> >
> > # Set a specified environment variable with a directory name.
> > def setEnvironment(env, var_name, dir_name):
> > # Convert the relative directory name to an absolute one.
> > dir = os.path.join(os.path.dirname(os.path.abspath(__file__)),
> > dir_name)
> >
> > # Remove any existing value so that we have a controlled environment.
> > idx = env.indexOf(QtCore.QRegExp("^%s=.*" % var_name,
> > QtCore.Qt.CaseInsensitive))
> >
> > if idx >= 0:
> > env.removeAt(idx)
> >
> > env << "%s=%s" % (var_name, dir)
> >
> > # Tell Qt Designer where it can find the directory containing the plugins
> > and
> > # Python where it can find the widgets.
> > env = QtCore.QProcess.systemEnvironment()
> > setEnvironment(env, "PYQTDESIGNERPATH", "python")
> > setEnvironment(env, "PYTHONPATH", "widgets")
> >
> > # Start Designer.
> > designer = QtCore.QProcess()
> > designer.setEnvironment(env)
> > ....
--
Detlev Offenbach
detlev at die-offenbachs.de
More information about the Eric
mailing list