[Tutor] passing arguments to a make a graph
Che M
pine508 at hotmail.com
Fri Mar 23 23:33:31 CET 2007
>Instead of using the class create an instance(aka object)
>
> self.plotPanel = PlotPanel(mypoints,self.notebook1)
>
>That creates an instance passing the mypoints list in
>to youir init method along with the notebook1 that you
>pass when you create an instance later (see below).
This worked great, thanks! One question: you mention that in this way it
is passing in the mypoints list and also the notebook1. What I am unclear
is, why are you allowed to pass in the notebook? If you look at the
original class PlotPanel():
class PlotPanel(wx.lib.plot.PlotCanvas):
def __init__(self, points=[], *args, **kwargs):
wx.lib.plot.PlotCanvas.__init__(self, *args, **kwargs)
self.points = points
[some methods deleted]
...in the __init__ function, it has parameters for self, points, *args, and
**kwargs. But you are passing it the notebook1, so how does it know which
"slot" of these four parameters notebook1 refers to?
>See my OOP topic for more on classes, objects etc.
I will look at it, and it should make even more sense given this example.
Gracias,
Che
_________________________________________________________________
The average US Credit Score is 675. The cost to see yours: $0 by Experian.
http://www.freecreditreport.com/pm/default.aspx?sc=660600&bcd=EMAILFOOTERAVERAGE
More information about the Tutor
mailing list