我不断收到这个错误,我有点卡住了。我知道它与最后一段代码有关,但除此之外,我很困惑,我不确定如何修复它/实施修复。
调用 Panel 的部分(可视选项菜单的一部分):
self.AutojoinMemosPanel = GUI.Options.Panels.AutojoinMemos.Panel(self.config,self)
self.pages.addWidget(self.AutojoinMemosPanel)
控制板:
from PyQt4 import QtCore
from PyQt4 import QtGui
class MemoEntryItem(QtGui.QListWidgetItem):
def __init__(self,MemoName):
QtGui.QListWidgetItem.__init__(self,MemoName)
self.MemoName = MemoName
class Panel(QtGui.QWidget):
def __init__(self,Config,userprofile):
QtGui.QWidget.__init__(self)
self.Config = Config
self.AutoIdentifyCheck = QtGui.QCheckBox("Automatically identify with nickserv")
self.PasswordLabel = QtGui.QLabel("Password:")
self.PasswordEntry = QtGui.QLineEdit()
self.PasswordEntry.setEchoMode(QtGui.QLineEdit.Password)
self.TitleLabel = QtGui.QLabel("Memos to join on startup:")
self.MemosList = QtGui.QListWidget()
self.MemoNameEntry = QtGui.QLineEdit()
self.RemoveButton = QtGui.QPushButton("REMOVE")
self.AddButton = QtGui.QPushButton("ADD")
Layout = QtGui.QVBoxLayout(self)
Layout.setAlignment(QtCore.Qt.AlignTop)
Layout.addWidget(self.AutoIdentifyCheck)
NickservPasswordLayout = QtGui.QHBoxLayout()
NickservPasswordLayout.addWidget(self.PasswordLabel)
NickservPasswordLayout.addWidget(self.PasswordEntry)
Layout.addLayout(NickservPasswordLayout)
Layout.addWidget(self.TitleLabel)
Layout.addWidget(self.MemosList)
Layout.addWidget(self.MemoNameEntry)
AddRemoveButtonLayout = QtGui.QHBoxLayout()
AddRemoveButtonLayout.addWidget(self.RemoveButton)
AddRemoveButtonLayout.addWidget(self.AddButton)
Layout.addLayout(AddRemoveButtonLayout)
self.connect(self.RemoveButton,QtCore.SIGNAL("clicked()"),self,QtCore.SLOT("RemoveSelectedMemo()"))
self.connect(self.AddButton,QtCore.SIGNAL("clicked()"),self,QtCore.SLOT("AddMemoFromTextEntry()"))
if self.Config.userprofile.userprofile.get("AutoIdentify",False):
self.AutoIdentifyCheck.setChecked(True)
self.PasswordEntry.setText(self.Config.userprofile.userprofile.get("NickservPassword",""))
for MemoName in self.Config.config.get("AutojoinMemos",[]):
self.AddMemoEntry(MemoName)
@QtCore.pyqtSlot()
def RemoveSelectedMemo(self):
self.MemosList.takeItem(self.MemosList.currentRow())
@QtCore.pyqtSlot()
def AddMemoFromTextEntry(self):
MemoName = str(self.MemoNameEntry.text()).strip()
if (MemoName != ""):
self.AddMemoEntry(MemoName)
self.MemoNameEntry.setText("")
def AddMemoEntry(self,MemoName):
self.MemosList.addItem(MemoEntryItem(MemoName))
def SaveOptions(self):
MemosListed = []
for MemoIndex in range(self.MemosList.count()):
MemoItem = self.MemosList.item(MemoIndex)
MemosListed.append(MemoItem.MemoName)
self.Config.set("AutojoinMemos",MemosListed)
self.Config.userprofile.userprofile["AutoIdentify"] = self.AutoIdentifyCheck.isChecked()
self.Config.userprofile.userprofile["NickservPassword"] = str(self.PasswordEntry.text())
self.Config.userprofile.save()
有什么帮助吗?