from PyQt4.QtGui: NameError: name 'QtGui' is not defined
from PyQt4.QtGui: NameError: name 'QtGui' is not defined
我遵循了特定类型的导入而不是写 *.
from PyQt4.QtGui
我还缺少什么?
import sys
from PyQt4.QtGui import QMainWindow, QSizePolicy, QWidget, QVBoxLayout, QAction,\
QKeySequence, QLabel, QItemSelectionModel, QMessageBox, QFileDialog, QFrame, \
QDockWidget, QProgressBar, QProgressDialog
from PyQt4.QtCore import SIGNAL, QSettings, QSize, QPoint, QVariant, QFileInfo, QTimer, pyqtSignal, QObject
class Window(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QGraphicsView.__init__(self, parent)
self.scene = QtGui.QGraphicsScene(self)
self.scene.setBackgroundBrush(QtGui.QBrush(QtCore.Qt.darkGray, QtCore.Qt.SolidPattern))
self.setScene(self.scene)
self.setDragMode(QtGui.QGraphicsView.ScrollHandDrag)
self.setTransformationAnchor(QtGui.QGraphicsView.AnchorUnderMouse)
self.viewport().setCursor(QtCore.Qt.CrossCursor)
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self._pan = False
self._draw = False
self._moved = False
self._sel = False
self.pen = None
self.penid = None
self.cmap = None
self.penwidth = 4
self._redoStack = []
self._histStates = []
self._baseRects = []
app = QtGui.QApplication(sys.argv)
GUI = Window()
sys.exit(app.exec_())
我添加了 并解决了错误:
from PyQt4 import QtGui
from PyQt4 import QtCore
现在看起来是这样的:
import sys
from PyQt4 import QtGui
from PyQt4 import QtCore
from PyQt4.QtGui import QMainWindow, QSizePolicy, QWidget, QVBoxLayout, QAction,\
QKeySequence, QLabel, QItemSelectionModel, QMessageBox, QFileDialog, QFrame, \
QDockWidget, QProgressBar, QProgressDialog
from PyQt4.QtCore import SIGNAL, QSettings, QSize, QPoint, QVariant, QFileInfo, QTimer, pyqtSignal, QObject
我遵循了特定类型的导入而不是写 *.
from PyQt4.QtGui
我还缺少什么?
import sys
from PyQt4.QtGui import QMainWindow, QSizePolicy, QWidget, QVBoxLayout, QAction,\
QKeySequence, QLabel, QItemSelectionModel, QMessageBox, QFileDialog, QFrame, \
QDockWidget, QProgressBar, QProgressDialog
from PyQt4.QtCore import SIGNAL, QSettings, QSize, QPoint, QVariant, QFileInfo, QTimer, pyqtSignal, QObject
class Window(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QGraphicsView.__init__(self, parent)
self.scene = QtGui.QGraphicsScene(self)
self.scene.setBackgroundBrush(QtGui.QBrush(QtCore.Qt.darkGray, QtCore.Qt.SolidPattern))
self.setScene(self.scene)
self.setDragMode(QtGui.QGraphicsView.ScrollHandDrag)
self.setTransformationAnchor(QtGui.QGraphicsView.AnchorUnderMouse)
self.viewport().setCursor(QtCore.Qt.CrossCursor)
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self._pan = False
self._draw = False
self._moved = False
self._sel = False
self.pen = None
self.penid = None
self.cmap = None
self.penwidth = 4
self._redoStack = []
self._histStates = []
self._baseRects = []
app = QtGui.QApplication(sys.argv)
GUI = Window()
sys.exit(app.exec_())
我添加了
from PyQt4 import QtGui
from PyQt4 import QtCore
现在看起来是这样的:
import sys
from PyQt4 import QtGui
from PyQt4 import QtCore
from PyQt4.QtGui import QMainWindow, QSizePolicy, QWidget, QVBoxLayout, QAction,\
QKeySequence, QLabel, QItemSelectionModel, QMessageBox, QFileDialog, QFrame, \
QDockWidget, QProgressBar, QProgressDialog
from PyQt4.QtCore import SIGNAL, QSettings, QSize, QPoint, QVariant, QFileInfo, QTimer, pyqtSignal, QObject