On Saturday 28 March 2009 05:20:33 pm Ricardo Aráoz wrote:
> Paul McNett wrote:
> > Ricardo Aráoz wrote:
> >> Hi,
> >> been reading the wiki on dTreeView
> >> (http://dabodev.com/wiki/DTreeView) and is pretty clear save that I
> >> found no code examples (and I usually need them).
> >> What I'm trying to do is re-code an app so as to be able to present the
> >> main menu as a menu or a dTreeView. The menu is ok, but I couldn't find
> >> an onHit() method for dNode. Should I use bindEvent()? And could some
> >> charitable soul give an example? Just a couple of nodes bound to a
> >> couple of functions.
> >> Thanks a lot.
> >>
> >> Ricardo.
> >>
> >> P.S.: I couldn't find dNode (I thought it would be under dabo.ui.dNode,
> >> but no luck) where is it referenced in the framework?
> >
> > Take at look at dabo/dabo/ui/uiwx/dTreeView.py, the sample code at the
> > end. Run it to see the sample code in action.
> >
> > We've tried to provide get-you-going functional samples at the bottom of
> > all the ui classes. See them all in action by typing:
> >
> > python test.py from within the uiwx directory.
> >
> > Paul
>
> Thanks Paul.
> Nevertheless when in dShell I do :
> ----------------------------------------
>
> >>> dabo.ui.dTreeView(w)
> >>> dabo.ui.dNode(tv)
>
> ----------------------------------------
> <dTreeView1 (baseclass dabo.ui.dTreeView, id:-403)>
> Traceback (most recent call last):
> File "<input>", line 1, in <module>
> AttributeError: 'module' object has no attribute 'dNode'
> ----------------------------------------
> I get this ("w" is a dDialog and "tv" is a dTreeView).
> In dabo/dabo/ui/uiwx/dTreeView.py you use "class TestNode(dNode):" and
> "class _dTreeView_test(dTreeView):" so I would guess I should be able to
> call dNode the same way I call dTreeView. Am I doing something wrong?
> This is :
> Platform: Win
> Python Version: 2.5.4 on win32
> Dabo Version: Version 0.9.1; Revision ~5116
> UI Version: 2.8.9.1 on wxMSW
dNode is a class within dTreeView.py
"class _dTreeView_test(dTreeView):" is a class that inherits from the class
dTreeView.
The dabo form is an instance of "TreeViewTestForm"
So let's follow the example.
def afterInit(self):
## create an instance of a panel
mp = dabo.ui.dPanel(self)
## add the panel to the form
self.Sizer.append1x(mp)
## define a sizer for the dabo panel we just added
sz = mp.Sizer = dabo.ui.dSizer("v")
## next we create a instance of the "_dTreeView_test"
## and we pass 'mp' a dabo panel to the class.
tree = self.tree = _dTreeView_test(mp)
## we better check out why we passed the panel.
## If we check out the class "_dTreeView_test" we discover
## there is no " __init__"
## Therefore the 'mp' must be passed to the class "dTreeView"
## the parent of "_dTreeView_test"
## Sure enough - there is an "__init__" and it needs at least one
## parameter the "parent". So we now why we passed
## 'mp'.
## let's continue with the "_dTreeView_test".
def afterInit(self):
## Wow somebody is getting tricky.
## They have created an instance of dNode by creating instance of "TestNode"
## and in "TestNode" we are just setting a few properties. Oh, we are getting
## deeper into to the world of OOP (watch your step). :-)
self.NodeClass = TestNode
## Oh what is this. Someone has decided to add a method to the
## "dTreeView" class for creating dummy data (maybe for testing).
## If you review what is in 'addDummyData' we discover that
## two ways of creating the nodes are shown - thanks for that.
self.addDummyData()
## the rest in "_dTreeView_test" is not to interesting.
self.expandAll() ....
## we followed the "_dTreeView_test" and have created the nodes (that includes
the root node)
## Let's now continue with our form "TreeViewTestForm"
## The next line after "tree = self.tree = _dTreeView_test(mp) "
## We add the just created tree to the sizer of the panel
## cool! Recall sz=mp.Sizer
sz.append1x(tree, border=12)
And as we say the rest is history.
--
John Fabiani
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message:
http://leafe.com/archives/byMID/[email protected]