[Bio] / ModelEditor / AGGetPubDialog.py Repository:
ViewVC logotype

View of /ModelEditor/AGGetPubDialog.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (download) (as text) (annotate)
Mon Jan 31 16:52:09 2005 UTC (13 years, 8 months ago) by efrank
Branch: MAIN
CVS Tags: before-dynamics-persistence, lwc, treatman-lastDay-0, preTreatmanDyn, HEAD
Changes since 1.6: +1 -1 lines
migration to wxPy 2.5.1.5.  basic function on mac now ok.

from wxPython.wx import *
from wxPython.grid import *
from KahDataServices.KahCatAGCfgMgr import KahCatAGEntry

import random

class AGGetPubDialog(wxDialog):
#    def __init__(self, parent, ID, title,
#    def onDialogCancel(self, evt):
#    def onDialogOK(self, evt):
    

    #------------------------------------------------------------------------
    def __init__(self, parent, ID, title,
                 pos=wxDefaultPosition, size=wxDefaultSize,
                 style=wxDEFAULT_DIALOG_STYLE):
    #------------------------------------------------------------------------

        wxDialog.__init__(self, parent, ID, title, pos, size, style)
        
        self.parent= parent
        
        agServerPagePanel  = wxPanel(self, -1)

        self.okDialogBtn       = wxButton(agServerPagePanel, wxID_OK, "ok")
        self.cancelDialogBtn   = wxButton(agServerPagePanel, wxID_CANCEL, "cancel")

                
        self.agServerPageGrid = wxGrid(agServerPagePanel, -1)
        self.agServerPageGrid.CreateGrid(0, 6)
        self.agServerPageGrid.SetColLabelValue(0,"Add")
        self.agServerPageGrid.SetColLabelValue(1,"Name")
        self.agServerPageGrid.SetColLabelValue(2,"Type")
        self.agServerPageGrid.SetColLabelValue(3,"Id")
        self.agServerPageGrid.SetColLabelValue(4,"IfaceType")
        self.agServerPageGrid.SetColLabelValue(5,"info1")
        #self.agServerPageGrid.SetColLabelValue(6,"info2")
        self.agServerPageGrid.AutoSizeColumn(0)
        self.agServerPageGrid.AutoSizeColumn(1)
        self.agServerPageGrid.AutoSizeColumn(2)
        self.agServerPageGrid.AutoSizeColumn(3)
        self.agServerPageGrid.AutoSizeColumn(4)
        self.agServerPageGrid.AutoSizeColumn(5)
        #self.agServerPageGrid.AutoSizeColumn(6)

        
        self.agServerPageGrid.SetColFormatBool(0)
        #self.agServerPageGrid.SetColFormatBool(1)

        agServerPageMainSizer   = wxBoxSizer(wxVERTICAL)
        dialogChoicesHSizer    = wxBoxSizer(wxHORIZONTAL)
        
        dialogChoicesHSizer.Add (self.okDialogBtn)
        dialogChoicesHSizer.Add (self.cancelDialogBtn)

        agServerPageMainSizer.Add (self.agServerPageGrid, 7, wxEXPAND)
        agServerPageMainSizer.Add ((20,20), 0, wxEXPAND)
        agServerPageMainSizer.Add (dialogChoicesHSizer)

        agServerPagePanel.SetSizer(agServerPageMainSizer)
        agServerPagePanel.SetAutoLayout(true)

        EVT_BUTTON(self, self.cancelDialogBtn.GetId(), self.onDialogCancel)
        EVT_BUTTON(self, self.okDialogBtn.GetId(),     self.onDialogOK)
        EVT_GRID_CELL_LEFT_CLICK(self, self.onSelectCell)
        
        self.getServersFromAG()
        
        return

    #------------------------------------------------------------------------
    def onDialogCancel(self, evt):
    #------------------------------------------------------------------------
        self.EndModal(wxID_CANCEL)
        return

    #------------------------------------------------------------------------
    def onDialogOK(self, evt):
    #------------------------------------------------------------------------
        self.EndModal(wxID_OK)
        return

    #------------------------------------------------------------------------
    def getServersFromAG(self):
    #------------------------------------------------------------------------
        serverDescriptors = self.parent.meAGMgr.getPublished()
        numServers = len(serverDescriptors)


        # quick hack to keep connect string out of display. 
        self.connectInfoDict = {}

        i = 0
        for d in serverDescriptors:
            print "getServersFromAG: ", d
            self.connectInfoDict[i] = [str(d.connectInfo[0]),
                                       str(d.connectInfo[1])]

            self.agServerPageGrid.AppendRows(numRows=1)
            self.agServerPageGrid.SetCellValue(i, 0, '0')


            self.agServerPageGrid.SetCellValue(i, 1, d.fId)
            self.agServerPageGrid.SetCellValue(i, 2, d.fType)
            self.agServerPageGrid.SetCellValue(i, 3, d.fVal)
            self.agServerPageGrid.SetCellValue(i, 4, d.ifaceType)
            self.agServerPageGrid.SetCellValue(i, 5, str(i) )
            #self.agServerPageGrid.SetCellValue(i, 5, str(d.connectInfo[0]))
            #self.agServerPageGrid.SetCellValue(i, 6, str(d.connectInfo[1]))
            self.agServerPageGrid.FitInside()
            i = i + 1

        self.agServerPageGrid.AutoSize()

        return

    #------------------------------------------------------------------------
    def GetValue(self):
    #------------------------------------------------------------------------
        results = []
        
        for n in range( self.agServerPageGrid.GetNumberRows() ):
            if self.agServerPageGrid.GetCellValue(n, 0) != '0':
                i = int( self.agServerPageGrid.GetCellValue(n, 5) )

                e = KahCatAGEntry( (self.agServerPageGrid.GetCellValue(n, 1),
                                   self.agServerPageGrid.GetCellValue(n, 2),
                                   self.agServerPageGrid.GetCellValue(n, 3),
                                   self.agServerPageGrid.GetCellValue(n, 4),
                                   self.connectInfoDict[ i ] ) )
                           
                results.append( e )

        return results

    #------------------------------------------------------------------------
    def onSelectCell(self, evt):
    #------------------------------------------------------------------------
                
        cellRow = evt.GetRow()
        cellCol = evt.GetCol()
        cellValue = self.agServerPageGrid.GetCellValue(cellRow, cellCol)

        if (cellCol==0):
            self.agServerPageGrid.SetCellValue(cellRow, cellCol, `1 - int(cellValue)`)

        return


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3