我正在写一本书,用raspberry pi学习python,我有点难过,因为我收到了这种类型的错误。我的IDE在下面吐出这条消息,我不确定它是否是构造函数类型问题
control_window = TurtleControl(babbage)TypeError: 使用错误的参数类型调用'PySide.QtGui.QWidget': PySide.QtGui.QWidget(Turtle)支持的签名: PySide.QtGui.QWidget(PySide.QtGui.QWidget = None, PySide.QtCore.Qt.WindowFlags = 0)
import turtle
import sys
from PySide.QtCore import *
from PySide.QtGui import *
class TurtleControl (QWidget):
def __init_(self, turtle):
super(TurtleControl, self) .__init__()
self.turtle = turtle
self.left_btn = QPushButton("Left", self)
self.right_btn = QPushButton("Right", self)
self.move_btn = QPushButton("Move", self)
self.distance_spin = QSpinBox()
self.controlsLayout = QGridLayout()
self.controlsLayout.addWidget(self.left_btn, 0, 0)
self.controlsLayout.addWidget(self.right_btn, 0, 1)
self.controlsLayout.addWidget(self.distance_spin,1, 0)
self.controlsLayout.addWidget(self.move_btn,1, 1)
self.setLayout(self.controlsLayout)
self.distance_spin.setRange(0, 100)
self.distance_spin.setSingleStep(5)
self.distance_spin.setValue(20)
self.move_btn.clicked.connect(self.move_turtle)
self.move_btn.clicked.connect(self.move_turtle_right)
self.move_btn.clicked.connect(self.move_turtle_left)
# set up turtle
window = turtle.Screen()
babbage = turtle.Turtle()
# Create a QT application
app = QApplication(sys.argv)
control_window = TurtleControl(babbage)
control_window.show()
# Enter QT application main loop
app.exec_()
sys.exit()