I've created a TreeCtrl class
*class MyTreeCtrl(wxTreeCtrl):
def __ini__(self,parent,id,pos,size):
wxTreeCtrl.__init__(self,parent,id,pos,size
#now I want to add a item
self.root = self.AddRoot("Root item")
*but this doesn't work
I have to make an instance of the class and then do : self.root = self.instanceofclass.AddRoot("Root item")
Is it possible to add items in the class self ?
First of all, there are a couple of typographical errors, but I
assume that you did not copy and paste, because the code as posted
should not even run at all.
Secondly, self.root = self.AddRoot("Root item") should work fine,
but technically this statement adds a root item *to each instance*
not to the class. The object "self" is the instance that is being
initialized by the __init__ method at instantiation.
Regards,
···
--- Jonas Geiregat <eniac@sdf-eu.org> wrote:
I've created a TreeCtrl class
*class MyTreeCtrl(wxTreeCtrl):
def __ini__(self,parent,id,pos,size):
wxTreeCtrl.__init__(self,parent,id,pos,size
#now I want to add a item
self.root = self.AddRoot("Root item")
*but this doesn't work
I have to make an instance of the class and then do : self.root =
self.instanceofclass.AddRoot("Root item")
Is it possible to add items in the class self ?
=====
Donnal Walter
Arkansas Children's Hospital
Donnal Walter wrote:
I've created a TreeCtrl class
*class MyTreeCtrl(wxTreeCtrl):
def __ini__(self,parent,id,pos,size):
wxTreeCtrl.__init__(self,parent,id,pos,size
#now I want to add a item
self.root = self.AddRoot("Root item")
*but this doesn't work
I have to make an instance of the class and then do : self.root =
self.instanceofclass.AddRoot("Root item")
Is it possible to add items in the class self ?
First of all, there are a couple of typographical errors, but I
assume that you did not copy and paste, because the code as posted
should not even run at all.
Secondly, self.root = self.AddRoot("Root item") should work fine,
but technically this statement adds a root item *to each instance*
not to the class. The object "self" is the instance that is being
initialized by the __init__ method at instantiation.
Regards,
=====
Donnal Walter
Arkansas Children's Hospital
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
For me it doesn't work
here is my code this time I copy past it
*class MyTreeCtrl(wxTreeCtrl):
def __ini__(self,parent,id,pos,size):
wxTreeCtrl.__init__(self,parent,id,pos,size)
self.root = self.AddRoot("Root item")
return 1
*I make an instance of the class in my frame like this
*self.treeCtrl = MyTreeCtrl(splitter,-1,wxDefaultPosition,wxDefaultSize);*
···
--- Jonas Geiregat <eniac@sdf-eu.org> wrote:
Try this:
class MyTreeCtrl(wxTreeCtrl):
def __init__(self,parent,id):
wxTreeCtrl.__init__(self,parent,id)
self.root = self.AddRoot("Root item")
class MyFrame(wxFrame):
def __init__(self):
wxFrame.__init__(self, None, -1, 'Tree Test',
size=(200,200))
self.tc1 = MyTreeCtrl(self, -1)
self.tc1.AppendItem(self.tc1.root, 'test1')
class MyApp(wxApp):
def OnInit(self):
frame = MyFrame()
frame.Show(true)
return true
if __name__ == '__main__':
app = MyApp(0)
app.MainLoop()
···
--- Jonas Geiregat <eniac@sdf-eu.org> wrote:
For me it doesn't work
here is my code this time I copy past it
*class MyTreeCtrl(wxTreeCtrl):
def __ini__(self,parent,id,pos,size):
wxTreeCtrl.__init__(self,parent,id,pos,size)
self.root = self.AddRoot("Root item")
return 1
*I make an instance of the class in my frame like this
*self.treeCtrl =
MyTreeCtrl(splitter,-1,wxDefaultPosition,wxDefaultSize);*
=====
Donnal Walter
Arkansas Children's Hospital
Constructors are named "__init__" (with a "t"; not "__ini__").
Also, __init__ should not return anything (if you fix the "__ini__"
typo, the interpreter will tell you this ;))
···
On Sat, May 31, 2003 at 04:20:36AM -0700, Jonas Geiregat wrote:
For me it doesn't work
here is my code this time I copy past it
*class MyTreeCtrl(wxTreeCtrl):
def __ini__(self,parent,id,pos,size):
wxTreeCtrl.__init__(self,parent,id,pos,size)
self.root = self.AddRoot("Root item")
return 1
--
"If you were plowing a field, which would you rather use?
Two strong oxen or 1024 chickens?" --Seymour Cray