[PyQt] Reassigning resizeEvent -- changes in 4.6
Roshan Mathews
roshan at tachyontech.net
Mon Oct 12 11:17:30 BST 2009
In the attached code, I reassign setText and resizeEvent for a
label object.
The method for setText is called, but the one for resizeEvent isn't.
This behavior is changed from PyQt-4.5.4, is it a bug, or is it
the expected behavior from now on?
Regards,
[roshan;]
--
Roshan Mathews http://teamtalk.im
-------------- next part --------------
from PyQt4 import QtGui
class BroadLabel(QtGui.QLabel):
def __init__(self):
super(BroadLabel, self).__init__()
def setText(self, text):
super(BroadLabel, self).setText("~~~~ %s ~~~~" % text)
class Container(QtGui.QWidget):
def __init__(self):
super(Container, self).__init__()
self.label = BroadLabel()
self.label.setText = self.setText
self.label.resizeEvent = self.resizeLabel
layout = QtGui.QGridLayout()
layout.addWidget(self.label)
self.setLayout(layout)
def setText(self, text):
super(BroadLabel, self.label).setText('!!!! %s !!!!' % text)
def resizeLabel(self, event):
print 'Resizing label'
if __name__ == '__main__':
import sys
app = QtGui.QApplication(sys.argv)
widget = Container()
widget.label.setText('Roshan Mathews')
widget.show()
sys.exit(app.exec_())
More information about the PyQt
mailing list