导入 PyQt4 不包含 PyQt4.QtCore 或 QtGui [英] import PyQt4 does not include PyQt4.QtCore or QtGui
问题描述
为什么这些语句都没有导入 QtCore、QtGui、QtNetwork 或其他任何语句?我已经搜索了这么久,找不到任何人来回答这么简单的问题.或者至少我是这么认为的.
Why do neither of these statements import QtCore, QtGui, QtNetwork or any of the others? I've searched so long and can't find anyone to answer such a simple question. Or at least that's what I think it is.
import PyQt4
from PyQt4 import *
相反,我必须这样做:
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtNetwork import *
还有一堆.有什么捷径可以把它们全部抓住?
Plus a bunch more. Any shortcuts to grab them all?
编辑:我的解决方案是检查我正在使用的库(用于 Py2exe)并复制它们的导入.那奏效了.尽管如此,但没有那么乏味.
Edit: My solutions was to go through the libraries that I was using (for Py2exe) and just copy their imports. That worked. Still, but not as tedious.
推荐答案
如果你想将所有 PyQt4 类导入到一个命名空间中,你可以这样做:
If you want to import all PyQt4 classes into a single namespace, you can do:
from PyQt4 import Qt
这篇关于导入 PyQt4 不包含 PyQt4.QtCore 或 QtGui的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!