Hi tutors, I am a newb. Please bear with my simple question. Please refer to the code as following. The question is: what is the special meaning of 'e' variable in the class of 'Button'. The second one is how function 'dragEnterEvent' and 'dropEvent' got executed with calling from class 'example'. Thanks a lot for the help.
Best, Yong The code is here: #!/usr/bin/python # -*- coding: utf-8 -*- """ ZetCode PyQt4 tutorial This is a simple drag and drop example. author: Jan Bodnar website: zetcode.com last edited: December 2010 """ import sys from PyQt4 import QtGui class Button(QtGui.QPushButton): def __init__(self, title, parent): super(Button, self).__init__(title, parent) self.setAcceptDrops(True) def dragEnterEvent(self, e): if e.mimeData().hasFormat('text/plain'): e.accept() else: e.ignore() def dropEvent(self, e): self.setText(e.mimeData().text()) class Example(QtGui.QWidget): def __init__(self): super(Example, self).__init__() self.initUI() def initUI(self): edit = QtGui.QLineEdit('', self) edit.setDragEnabled(True) edit.move(30, 65) button = Button("Button", self) button.move(190, 65) self.setWindowTitle('Simple Drag & Drop') self.setGeometry(300, 300, 300, 150) def main(): app = QtGui.QApplication(sys.argv) ex = Example() ex.show() app.exec_() if __name__ == '__main__': main()
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor