Python PySide如何在QDialog类对象中组合多个布局

Python PySide如何在QDialog类对象中组合多个布局,python,class,dialog,pyside,Python,Class,Dialog,Pyside,这可能是一个简单的问题,但我想我会把它抛给专家们:-) 如何在单个(QDialog派生的)类中组合多个布局 这是我最初的尝试-但是行self.setLayout(mainloayout)不起作用,我收到一个namererror。。。有人能帮忙吗(我是PySide编程的新手) 编辑 完整错误输出为: Traceback (most recent call last): File "..\FindDialog.py", line 36, in <module> class F

这可能是一个简单的问题,但我想我会把它抛给专家们:-) 如何在单个(QDialog派生的)类中组合多个布局

这是我最初的尝试-但是行
self.setLayout(mainloayout)
不起作用,我收到一个
namererror
。。。有人能帮忙吗(我是PySide编程的新手)

编辑

完整错误输出为:

Traceback (most recent call last):
  File "..\FindDialog.py", line 36, in <module>
    class FindDialog(QDialog):
  File "..\FindDialog.py", line 109, in FindDialog
    self.setLayout(mainLayout)
NameError: name 'self' is not defined
回溯(最近一次呼叫最后一次):
文件“.\FindDialog.py”,第36行,在
类FindDialog(QDialog):
文件“.\FindDialog.py”,FindDialog中的第109行
self.setLayout(主布局)
NameError:未定义名称“self”

PS向电台致歉-我的评论格式不好…

这些行有冲突:

topLayout = QGridLayout(self)
bottomLayout = QGridLayout(self)
...
self.setLayout(mainLayout)
错误/警告消息表明布局相互过度写入,最后,
setLayout
试图设置一些已设置的属性

QLayout: Attempting to add QLayout "" to FindDialog "", which already has a layout
QLayout::addChildLayout: layout "" already has a parent
这种快速修复方法可以:

topLayout = QGridLayout()
bottomLayout = QGridLayout()
...
self.setLayout(mainLayout)

我没有收到任何NameError——如果您仍然收到错误消息,请发布整个文本。可能是缩进错误,请确保该行与
\uuuuuu init\uuuuuu
中的其他行处于相同的缩进级别。感谢收音机的建议-我已经尝试了您建议的更改,但我仍然收到了那个可怕的名称错误:
回溯(最近一次调用最后一次):


`File.\FindDialog.py”,在`
`class FindDialog(QDialog):`
`File.\FindDialog.py',第109行,在FindDialog`
`self.setLayout(mainloayout)`
名称错误:没有定义'self'`
topLayout = QGridLayout()
bottomLayout = QGridLayout()
...
self.setLayout(mainLayout)