import sys from PyQt4 import QtCore, QtGui class myWidget(QtGui.QWidget): def __init__(self): super(myWidget, self).__init__() self.setWindowTitle("test") self.resize(300, 200) self.lab = QtGui.QLabel("label") self.btn = QtGui.QPushButton("button") hbox = QtGui.QHBoxLayout() hbox.addWidget(self.lab) hbox.addWidget(self.btn) self.setLayout(hbox) self.connect(self.btn, QtCore.SIGNAL(‘clicked()‘), self, QtCore.SLOT(‘OnClick()‘)) @QtCore.pyqtSlot() def OnClick(self): self.lab.setText("sdfasdf") app = QtGui.QApplication(sys.argv) wi = myWidget() wi.show() app.exec_()
时间: 2024-10-27 07:33:18