QtDesigner/Pyside (および stackoverflow) は初めてです。よくプレビューできる QtDesigner インターフェイスがあります。「スタブ」外部信号なしで pyside-uic を実行しましたが、正常に動作します (あまり効果がありません!)。外部信号を追加すると、問題が発生します。可能性が高いと思われるシグナル/スロットへの参照をすべて調べましたが、私の問題を指摘するものは何もありません。エラーメッセージをグーグルで検索しましたが、結果も最小限でした。2 日間頭をぶつけた後、私がしていることは何でもあまりにもばかげているので、通常は質問する必要がないという結論に達しました。どんなポインタでも大歓迎です。Ui_tunerSym 親クラスは pyside から自動生成された約 600 行です。
#!/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'