Pyside自定义信号抛出属性

时间:2014-05-07 01:35:55

标签: signals pyside custom-code

我是QtDesigner / Pyside(和stackoverflow)的新手。我有一个QtDesigner界面,可以很好地预览。我通过pyside-uic运行它,没有" stub"外部信号,它工作正常(没有做太多!)。当我添加外部信号时,我遇到了问题。我查看了所有可能的信号/插槽参考,但没有任何指向我的问题。我用谷歌搜索了错误信息,结果也很少。经过两天的抨击,我得出的结论是,无论我做什么都是如此愚蠢,它通常无法提出问题!任何指针都将非常感激。 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'

0 个答案:

没有答案