[Bio] / PyGUI / Catalogpanel.py Repository:
ViewVC logotype

View of /PyGUI/Catalogpanel.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (download) (as text) (annotate)
Fri Aug 1 18:54:31 2003 UTC (16 years, 5 months ago) by efrank
Branch: MAIN
Changes since 1.3: +72 -12 lines
Catalogpanel:
	modify so that the catalog is a tree.  the top level nodes in the tree
	list the data factories, e.g., Bss, Wit, etc.

main.py
	to match above.

from wxPython.wx import *
from FaST.BssFactory import BssFactory
from FaST.WitFactory import WitFactory
from FaST.RecoElem import RecoElem
from RecoElempanel import RecoElemWindow

class CatalogWindow:
    #------------------------------------------------------------------------
    def __init__(self, parent):
    #------------------------------------------------------------------------
        self.parent = parent
        self.to_re = parent.re 
        self.selected = None       #remember last selected catalog entry
                                   #..is used when LOAD button is hit.

        self.initCatEvents()
        self.initCatData()
        return

    
    #------------------------------------------------------------------------
    def initCatEvents(self ):
    #------------------------------------------------------------------------
        button1= self.parent.OK_button
        EVT_BUTTON(self.parent, self.parent.loadbtn.GetId(),
                   self.onLoadBtnPress)
        return
        
    #------------------------------------------------------------------------
    def initCatData( self ):
    #------------------------------------------------------------------------
        self.parent.catalogRootId = self.parent.catalog_tree.AddRoot("Available Sources")

        bssItemId=self.parent.catalog_tree.AppendItem(self.parent.catalogRootId,
                                                   "BioSimScratch" )
        witItemId=self.parent.catalog_tree.AppendItem(self.parent.catalogRootId,
                                                   "WIT3" )

        self.loadBssCatalog( bssItemId )
#        self.loadWitCatalog( witItemId )
        return

    #------------------------------------------------------------------------
    def loadBssCatalog(self, bssItemId):
    #------------------------------------------------------------------------
        b=BssFactory()
        for catEntryTuple in b.getLsCat():
            id=self.parent.catalog_tree.AppendItem(bssItemId, catEntryTuple[0])
            self.parent.catalog_tree.SetPyData(id, catEntryTuple)
            EVT_LEFT_DCLICK(self.parent.catalog_tree, self.onLeftClickBss)

        return
        
    #------------------------------------------------------------------------
    def loadWitCatalog(self, witItemId):
    #------------------------------------------------------------------------
        w=WitFactory()
        pwyList = w.listPathways( )
        for pwy in pwyList: 
            id=self.parent.catalog_tree.AppendItem(witItemId, pwy)
            self.parent.catalog_tree.SetPyData(id, pwy)
            EVT_LEFT_DCLICK(self.parent.catalog_tree, self.onLeftClickWitPwy)

        return
        
    #------------------------------------------------------------------------
    def InitLsCat(self):
    #------------------------------------------------------------------------
        return

    #------------------------------------------------------------------------
    def onLeftClickBss(self,event):
    #------------------------------------------------------------------------
        pt=event.GetPosition()
        item, flags = self.parent.catalog_tree.HitTest(pt)
        catEntryTuple = self.parent.tree_ctr.GetPyData(item)
        print catEntryTuple
        self.selected = catEntryTuple[1]

        return

    #------------------------------------------------------------------------
    def onLeftClickWitPwy(self,event):
    #------------------------------------------------------------------------
        pt=event.GetPosition()
        item, flags = self.parent.catalog_tree.HitTest(pt)
        pwy = self.parent.tree_ctr.GetPyData(item)
        print "request to fetch pathway from wit: ", pwy

        return

        
    #------------------------------------------------------------------------
    def onLoadBtnPress(self, event):
    #------------------------------------------------------------------------
        if ( self.selected == None ): return 

        wxBeginBusyCursor()
        b=BssFactory()
        top= b.getRecoElemById( self.selected )
        self.to_re.AddRecoElemTree(self.parent.rootId, top)
        wxEndBusyCursor()
        return
    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3