[Tutor] Super In tkinter class inheritance
Prasad, Ramit
ramit.prasad at jpmorgan.com
Thu Dec 8 23:39:59 CET 2011
>> class ChooseDestinationWindow(Frame): def __init__(self,master):
>>super(ChooseDestinationWindow,self).__init_
_(master)
>What exactly does this super method since I have seen it numerous
>times before and as far as I can see it is not anything the user
>created himself in the class?
This has to do a lot with inheritance in object-oriented programming.
If you are not aware of this, you might want to read some basics on that.
The gist of the reason to call super is that the TKinter (or whatever base class)
does some work in the background to create a "Frame" type, so if you are inheriting
from the Frame class, you still (normally) want the Frame class to behave
normally with very specific deviations. For instance, you may want to setup
the Frame but (like an Office-type application) have it ask the user to save when
the app tries to close. You use super in a function to call the behavior
of the base class so that you do not need to duplicate the code. It is
a fairly language-agnostic OOP idea.
Ramit
Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423
--
This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.
More information about the Tutor
mailing list