class mp3Line(object):
def __init__(self, parent, country, path):
line = QtGui.QHBoxLayout()
countryLabel = QtGui.QLabel(country)
playButton = QtGui.QPushButton("Play")
countryLabel.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.MinimumExpanding)
line.addWidget(countryLabel)
line.addWidget(playButton)
parent.addLayout(line)
self.path = path
playButton.clicked.connect(self.play)
def play(self):
print "play bleat"
class Ui_Form(object):
def __init__(self, Form):
Form.setObjectName(_fromUtf8("Form"))
Form.resize(775, 49)
self.horizontalLayout = QtGui.QHBoxLayout(Form)
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
self.verticalLayout = QtGui.QVBoxLayout()
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
self.horizontalLayout_2 = QtGui.QHBoxLayout()
self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
self.word = QtGui.QLineEdit(Form)
self.word.setObjectName(_fromUtf8("word"))
self.horizontalLayout_2.addWidget(self.word)
self.searchButton = QtGui.QPushButton(Form)
self.searchButton.setFocusPolicy(QtCore.Qt.WheelFocus)
self.searchButton.setObjectName(_fromUtf8("searchButton"))
self.horizontalLayout_2.addWidget(self.searchButton)
self.verticalLayout.addLayout(self.horizontalLayout_2)
self.horizontalLayout.addLayout(self.verticalLayout)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
self.searchButton.clicked.connect(self.search)
self.word.returnPressed.connect(self.search)
self.Form = Form
def retranslateUi(self, Form):
Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None, QtGui.QApplication.UnicodeUTF8))
self.searchButton.setText(QtGui.QApplication.translate("Form", "Search", None, QtGui.QApplication.UnicodeUTF8))
def search(self):
....
mp3Info = [("/tmp/ololo.mp3", "Russia"), ("/tmp/trololo.mp3", "USA")]
for path, country in mp3Info:
mp3 = mp3Line(self.verticalLayout, country, path)
В классе Ui_Form конструкция вида
self.searchButton.clicked.connect(self.search)
Пробовал в класс mp3Line добавлять уже и вот такие кусочки кода:
QtCore.QMetaObject.connectSlotsByName(Form)
widget.setObjectName(_fromUtf8("widgetName"))
Рассчитываю на Вашу помощь.