By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,563 Members | 1,023 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,563 IT Pros & Developers. It's quick & easy.

Need help in TREE MENU in PYTHON

P: 1
Hello all,
Am working on PYTHON +BRANWAVE(framework)
Actually am Trying 2 make a tree menu using d both. Am not able 2 target the (.tmpl) files and not getting how 2 make frames in .tmpl file...

Can anyone get me a demo screen 4 d same showing a tree on the left and when we click any link in the tree, corresponding page(.tmpl) page opens up on right...

This is a simple Tree Example>>>>>>> file name="mytreeapp.py"
Expand|Select|Wrap|Line Numbers
  1. import iris
  2. import aphrodite
  3. from plugins.CheetahPlugin import CheetahRender
  4.  
  5. class mytreeapp(iris.App):
  6.     def __init__(self):
  7.         iris.App.__init__(self)
  8.         self.aphrodite = aphrodite.Aphrodite('mytreeapp')
  9.  
  10.     @iris.expose
  11.     def default(self, *args, **kwargs):
  12.         pass
  13.  
  14.     @iris.expose
  15.     def index(self, *args, **kwargs):
  16.         return CheetahRender(template="index")
  17.  
  18.     @iris.expose    
  19.     def tree(self):
  20.         data = [
  21.         {'title':'Rock Music', 'description':'Rock Albums', 'icon':'/mytreeapp/resources/avatars/a1.png', 'items':[
  22.             {'title':'Reckless (1984)', 'description': 'Bryan Adams','items':[{'title':'Summer of 69','description':'B.Adams,J.Vallance','link':'javascript:show("Summer of 69")'},{'title':'One Night Love Affair','description':'B.Adams,J.Vallance','link':'javascript:show("One Night Love Affair")'},{'title':'Heaven','description':'B.Adams,J.Vallance','link':'javascript:show("Heaven")'}]},
  23.             {'title':'Bon Jovi (1984)', 'description': 'Jon Bon Jovi','items':[{'title':'Runaway','description':'Jon Bon Jovi, George Karak','link':'javascript:show("Runaway")'},{'title': "She Don't Know Me",'description':'Mark Avsec','link':'javascript:show("She Don\'t Know Me")'},{'title':'Shot Through The Heart','description':'Bon Jovi, Jack Ponti','link':'javascript:show("Shot Through The Heart")'}]},
  24.             {'title':'The Open Door (2006)', 'description': 'Evanescence','items':[{'title':'Sweet Sacrifice','description':'Amy Lee, Terry Balsamo','link':'javascript:show("Sweet Sacrifice")'},{'title': "Call Me When You're Sober",'description':'Amy Lee, Terry Balsamo','link':'javascript:show("Call Me When You\'re Sober")'},{'title':'Weight of the World','description':'Amy Lee, Terry Balsamo','link':'javascript:show("Weight of the World")'}]}
  25.         ]},
  26.         {'title':'Pop Music', 'description':'Pop Albums', 'icon':'/mytreeapp/resources/avatars/a2.png','items':[
  27.             {'title':'Millennium (1999)', 'description': 'Backstreet Boys','items':[{'title':'Larger than life','description':'Littrell, Lundin, Martin, Orpin','link':'javascript:show("Larger than life")'},{'title':"I Want It That Way",'description':'Carlsson, Martin, Orpin','link':'javascript:show("I Want It That Way")'},{'title':"Show Me the Meaning of Being Lonely",'description':'Crichlow, Martin','link':'javascript:show("Show Me the Meaning of Being Lonely")'}]},
  28.             {'title':'Baby one more time (1999)', 'description': 'Britney Spears','items':[{'title':'...Baby One More Time','description':'M.Martin','link':'javascript:show("...Baby One More Time")'},{'title':'Sometimes','description':'J. Elofsson, P. Magnusson, D. Kreuger, M. Martin','link':'javascript:show("Sometimes")'},{'title':'From the Bottom of My Broken Heart','description':'E. Foster White','link':'javascript:show("From the Bottom of My Broken Heart")'}]},
  29.             {'title':'Escape (2001)', 'description': 'Enrique Iglesias','items':[{'title':'Escape','description':'DioGuardi,Iglesias,Morales,Siegel','link':'javascript:show("Escape")'},{'title':"Don't Turn Off the Lights",'description':'DioGuardi,Iglesias,Morales,Siegel','link':'javascript:show("Don\'t Turn Off the Lights")'},{'title':'Hero','description':'Taylor,Iglesias,Barry','link':'javascript:show("Hero")'}]}
  30.         ]}    
  31.         ]
  32.         iris.json(data)
  33.  
THE CORRESPONDING VIEW PAGE(index.tmpl) WILL BE>>>>


<window>
<script>
function show(text)
{
document.getElementById('song_title').innerHTML="" ;
document.getElementById('song_title').innerHTML=te xt;
}
</script>

<center><box title='Demo Tree' style="width:400px">
<div style="text-align:left;overflow:auto;height:300px;" >
<tree id="mytree" url="/mytreeapp/tree" />
</div>
</box>
<br/>
<box title="Song Title" style="width:500px;">
<div id='song_title'>
</div>

</box>
</center>
</window>


REGARDS,

Preet kanwal Singh
Sep 10 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.