[Tutor] what is the meaning of variable e
Dave Angel
davea at davea.name
Fri Apr 26 08:17:04 CEST 2013
On 04/26/2013 01:45 AM, wang yong wrote:
> Hi tutors,
>
> I am a newb. Please bear with my simple question.
If you're new to Python, then any GUI question isn't "simple." But
perhaps you're not new to Python, but only to PyQT. I'll qualify my
remarks with the statement that I'm not familiar with PyQt, but I am
with GUI's in general. So I hope I can help.
Please refer to the code
> as following. The question is: what is the special meaning of 'e' variable
> in the class of 'Button'.
'e' is not special to the class at all. It's just a parameter specified
in two of the class methods. So somebody makes a call something like:
context = --instance of some class that has a mimeData method--
mybutton.dragEnterEvent(context)
The second one is how function 'dragEnterEvent'
> and 'dropEvent' got executed with calling from class 'example'. Thanks a
> lot for the help.
By making your Button class a child of QtGui.QPushButton, you inherit a
lot of behavior. Apparently two pieces of that is the binding of these
two methods to the button. Whenever somebody calls a method on
QtGui.QPushButton that you have also defined, they end up calling your
version instead of the default one in the base class.
Apparently, when a user does a drag-drop targeting a QPushButton, it
fires one or both of those events.
For more details, you need to ask someone who knows PyQt. I don't see
it discussed here very much, so you'd probably be better off with the
docs, or on a PyQt forum.
--
DaveA
More information about the Tutor
mailing list