0

我是 QtDesigner/Pyside(和 stackoverflow)的新手。我有一个预览良好的 QtDesigner 界面。我通过 pyside-uic 运行它,没有“存根”外部信号,它工作正常(没有做太多!)。当我添加外部信号时,我遇到了问题。我查看了所有似乎可能的信号/插槽的引用,但没有任何问题指向我的问题。我用谷歌搜索了错误消息,结果也很少。经过两天的头撞后,我得出结论,无论我在做什么都是如此愚蠢,通常不值得提问!任何指针将不胜感激。Ui_tunerSym 父类大约 600 行,由 pyside 自动生成。

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on Mon May 05 10:01:00 2014

@author: Gordon
"""

from PySide import QtCore, QtGui
#import UI produced by QtDesigner after running through: pyside-uic -x TunerSymWindow.ui -o ui_tunerSym.py
from ui_tunerSym import Ui_tunerSym

# subclass my UI class
class tView(Ui_tunerSym):
    def __init__(self):
        QtCore.QObject.connect(self.coarse_commandLinkButton, QtCore.SIGNAL("clicked()"), self.execute_coarse_tune)
        QtCore.QObject.connect(self.fine_commandLinkButton, QtCore.SIGNAL("clicked()"), self.execute_fine_tune)
        QtCore.QMetaObject.connectSlotsByName(tunerSym)

    def execute_coarse_tune(self):
        print "Coarse tune button pushed"

    def execute_fine_tune(self):
        print "Fine tune button pushed"

#example from web site used as basis
#QtCore.QObject.connect(button, QtCore.SIGNAL('clicked()'), someFunc)

#  copied from ui_tunerSym.pi. Shows the buttons and signals are in fact there...
#    QtCore.QObject.connect(self.coarse_commandLinkButton, QtCore.SIGNAL("clicked()"), tunerSym.execute_coarse_tune)
#    QtCore.QObject.connect(self.fine_commandLinkButton, QtCore.SIGNAL("clicked()"), tunerSym.execute_fine_tune)
#    QtCore.QMetaObject.connectSlotsByName(tunerSym)


if __name__ == '__main__':
    import sys
    app = QtGui.QApplication(sys.argv)
    frame = tView()
    frame.show()
    app.exec_()

# throws the following error:
# AttributeError: 'tView' object has no attribute 'coarse_commandLinkButton'
4

0 回答 0