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

View of /PyGUI/AGGetPubDialog.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (download) (as text) (annotate)
Wed Jul 14 20:22:13 2004 UTC (15 years, 3 months ago) by efrank
Branch: MAIN
CVS Tags: V00-00-03, MigrateToNewPackage, mass-spec-01, forRick-14Jul04-0, mass-spec-03, mass-spec-02, forRick-14Jul04-1, HEAD
Changes since 1.4: +10 -3 lines
getting it to work.  in a rush for rick demo.

from wxPython.wx import *
from wxPython.grid import *

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,"Host")
        self.agServerPageGrid.SetColLabelValue(5,"Port")
        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.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):
    #------------------------------------------------------------------------
        servers = self.parent.mainMenuBar.catManager.getPublished()
        numServers = len(servers)

        i = 0
        for server in servers:
            print "getServersFromAG: ", server
            self.agServerPageGrid.AppendRows(numRows=1)
            self.agServerPageGrid.SetCellValue(i, 0, '0')
            for j in range(1, 4):
                print j
                self.agServerPageGrid.SetCellValue(i, j, server[j-1])
                print self.agServerPageGrid.GetCellValue(i, j)
            self.agServerPageGrid.SetCellValue(i, 4, server[3][0])
            self.agServerPageGrid.SetCellValue(i, 5, `server[3][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':
                results.append([self.agServerPageGrid.GetCellValue(n, 1),
                                self.agServerPageGrid.GetCellValue(n, 2),
                                self.agServerPageGrid.GetCellValue(n, 3),
                                [self.agServerPageGrid.GetCellValue(n, 4),
                                 int(self.agServerPageGrid.GetCellValue(n, 5))]])

        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