Qt Designer:找不到自定义PyQt小部件插件 [英] Qt Designer: could not find custom PyQt widget plugins

查看:438
本文介绍了Qt Designer:找不到自定义PyQt小部件插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了许多自定义窗口小部件插件,以便在Qt Designer和我的管道中使用它们.

I wrote a lot of custom widget plug-ins for using them in the Qt Designer and my Pipeline.

这在我的Mac(Mavericks,PyQt4,Python 2.7)上运行良好,本周我也想在Windows环境中实现这些插件.但这没有用.插件未出现在左侧Qt Designer的小部件框中(Windows 7,PyQt4,Python 2.7).

This is working fine on my Mac (Mavericks, PyQt4, Python 2.7), and this week I wanted to implement those plugins on my Windows environment as well. But it wasn't working. The plug-ins are not appear in the Qt Designer's Widget Box on the left (Windows 7, PyQt4, Python 2.7).

经过大量尝试,我下载了PyQt4示例文件,并按照以下说明进行操作: PyQt参考指南以及说明 来自示例启动器文件 examples/designer/plugins/plugins.py 本身,但仍然无法正常运行.

After a lot of try's, I downloaded the PyQt4 example files and followed the instructions from: PyQt Reference Guide and also the instructions from the example launcher file examples/designer/plugins/plugins.py itself, but it was still not working.

所以我复制了以下示例文件:

So I copied the the following example files:

  • 将文件插入"C:\ designer_plugins"
  • 小工具文件到"C:\ designer_widgets"
  • plugin files to "C:\designer_plugins"
  • widget files to "C:\designer_widgets"

只是使代码尽可能简单,以找出问题所在.

Just to making the code as simple as possible to figure out what is going wrong.

所以,这是我测试的 plugins.py 文件:

So, this is my testing plugins.py file:

#!/usr/bin/env python
import sys
import os

from PyQt4 import QtCore, QtGui, uic

env = os.environ.copy()

env['PYTHONPATH']       = r"C:\designer_widgets" #("%s"%os.pathsep).join(sys.path)
env['PYQTDESIGNERPATH'] = r"C:\designer_plugins"

qenv = ['%s="%s"' % (name, value) for name, value in env.items()]

# Start Designer.
designer = QtCore.QProcess()
designer.setEnvironment(qenv)

designer_bin = r"C:\Python27x64\Lib\site-packages\PyQt4\designer.exe"

designer.start(designer_bin)
designer.waitForFinished(-1)

sys.exit(designer.exitCode())

我以为我的 designer 对象没有正确的路径,所以我实施了以下检查其环境的方法:

I thought that my designer object didn't get the right path, so I implemented the folowing to check it's environment:

# Check if paths are right
print "\n # Designer Env:"
for pypath in designer.environment():
    if "PYTHONPATH" in pypath:
        print " #  ",pypath
    if "PYQTDESIGNERPATH" in pypath:
        print " #  ",pypath

控制台输出:

 # Designer Env:
 #   PYQTDESIGNERPATH="C:\designer_plug"
 #   PYTHONPATH="C:\designer_widgets"

路径正确.就像我说的那样,在我的Mac上,它运行完美. 我也尝试了不同的Qt Designer安装.但是(PyQt4和PySide)设计人员都没有显示任何示例插件.两个Qt Designer都找不到示例插件.我使用帮助/关于插件在设计器中对其进行了仔细检查.

The paths are right. And like I said, on my mac it works perfectly. I was trying this also with different Qt Designer installations. But both (PyQt4 and PySide) designers doesn't show any of the example plugins. Both Qt Designer couldn't find the example plugins. I double checked it inside the designer with Help/About Plugins).

任何想法我做错了什么?还是在Windows 7系统上通常不起作用?

Any ideas what I did wrong? Or is this generally not working on a Windows 7 System?

推荐答案

已全部修复.我重建了PyQt4,所以我认为我过去可能在Qt的源代码中犯了一个错误.

All fixed. I rebuild PyQt4, so I think I made probably a mistake in the source code of Qt in the past.

这篇关于Qt Designer:找不到自定义PyQt小部件插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆