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

Annotation of /PyGUI/AGGetPubDialog.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (view) (download) (as text)

1 : hwang 1.1 from wxPython.wx import *
2 :     from wxPython.grid import *
3 :    
4 :     import random
5 :    
6 :     class AGGetPubDialog(wxDialog):
7 :     # def __init__(self, parent, ID, title,
8 :     # def onDialogCancel(self, evt):
9 :     # def onDialogOK(self, evt):
10 :    
11 :    
12 :     #------------------------------------------------------------------------
13 :     def __init__(self, parent, ID, title,
14 :     pos=wxDefaultPosition, size=wxDefaultSize,
15 :     style=wxDEFAULT_DIALOG_STYLE):
16 :     #------------------------------------------------------------------------
17 :    
18 :     wxDialog.__init__(self, parent, ID, title, pos, size, style)
19 :    
20 :     self.parent= parent
21 :    
22 :     agServerPagePanel = wxPanel(self, -1)
23 :    
24 :     self.okDialogBtn = wxButton(agServerPagePanel, wxID_OK, "ok")
25 :     self.cancelDialogBtn = wxButton(agServerPagePanel, wxID_CANCEL, "cancel")
26 :    
27 :    
28 :     self.agServerPageGrid = wxGrid(agServerPagePanel, -1)
29 : ctreatma 1.2 self.agServerPageGrid.CreateGrid(0, 6)
30 :     self.agServerPageGrid.SetColLabelValue(0,"Add")
31 :     self.agServerPageGrid.AutoSizeColumn(0)
32 :     self.agServerPageGrid.SetColLabelValue(1,"Name")
33 :     self.agServerPageGrid.SetColLabelValue(2,"Type")
34 : hwang 1.1 self.agServerPageGrid.AutoSizeColumn(2)
35 : ctreatma 1.2 self.agServerPageGrid.SetColLabelValue(3,"Id")
36 : hwang 1.1 self.agServerPageGrid.AutoSizeColumn(3)
37 : ctreatma 1.2 self.agServerPageGrid.SetColLabelValue(4,"Host")
38 :     self.agServerPageGrid.SetColLabelValue(5,"Port")
39 :    
40 : hwang 1.1 self.agServerPageGrid.SetColFormatBool(0)
41 :     #self.agServerPageGrid.SetColFormatBool(1)
42 :    
43 :     agServerPageMainSizer = wxBoxSizer(wxVERTICAL)
44 :     dialogChoicesHSizer = wxBoxSizer(wxHORIZONTAL)
45 :    
46 :     dialogChoicesHSizer.Add (self.okDialogBtn)
47 :     dialogChoicesHSizer.Add (self.cancelDialogBtn)
48 :    
49 :     agServerPageMainSizer.Add (self.agServerPageGrid, 7, wxEXPAND)
50 :     agServerPageMainSizer.Add (20,20, 0, wxEXPAND)
51 :     agServerPageMainSizer.Add (dialogChoicesHSizer)
52 :    
53 :     agServerPagePanel.SetSizer(agServerPageMainSizer)
54 :     agServerPagePanel.SetAutoLayout(true)
55 :    
56 :     EVT_BUTTON(self, self.cancelDialogBtn.GetId(), self.onDialogCancel)
57 :     EVT_BUTTON(self, self.okDialogBtn.GetId(), self.onDialogOK)
58 : ctreatma 1.3 EVT_GRID_CELL_LEFT_CLICK(self, self.onSelectCell)
59 :    
60 : ctreatma 1.2 self.getServersFromAG()
61 : hwang 1.1
62 :     return
63 :    
64 :     #------------------------------------------------------------------------
65 :     def onDialogCancel(self, evt):
66 :     #------------------------------------------------------------------------
67 :     self.EndModal(wxID_CANCEL)
68 :     return
69 :    
70 :     #------------------------------------------------------------------------
71 :     def onDialogOK(self, evt):
72 :     #------------------------------------------------------------------------
73 :     self.EndModal(wxID_OK)
74 :     return
75 :    
76 : ctreatma 1.2 #------------------------------------------------------------------------
77 :     def getServersFromAG(self):
78 :     #------------------------------------------------------------------------
79 :     servers = self.parent.mainMenuBar.catManager.getPublished()
80 :     numServers = len(servers)
81 :    
82 :     i = 0
83 :     for server in servers:
84 :     self.agServerPageGrid.AppendRows(numRows=1)
85 :     self.agServerPageGrid.SetCellValue(i, 0, '0')
86 :     for j in range(1, 4):
87 :     print j
88 :     self.agServerPageGrid.SetCellValue(i, j, server[j-1])
89 :     print self.agServerPageGrid.GetCellValue(i, j)
90 :     self.agServerPageGrid.SetCellValue(i, 4, server[3][0])
91 :     self.agServerPageGrid.SetCellValue(i, 5, `server[3][1]`)
92 :     self.agServerPageGrid.FitInside()
93 :     i = i + 1
94 :    
95 :     return
96 :    
97 :     #------------------------------------------------------------------------
98 : ctreatma 1.3 def GetValue(self):
99 : ctreatma 1.2 #------------------------------------------------------------------------
100 : ctreatma 1.3 results = []
101 : ctreatma 1.2
102 : ctreatma 1.3 for n in range( self.agServerPageGrid.GetNumberRows() ):
103 :     if self.agServerPageGrid.GetCellValue(n, 0) != '0':
104 :     results.append([self.agServerPageGrid.GetCellValue(n, 1),
105 :     self.agServerPageGrid.GetCellValue(n, 2),
106 :     self.agServerPageGrid.GetCellValue(n, 3),
107 :     [self.agServerPageGrid.GetCellValue(n, 4),
108 :     int(self.agServerPageGrid.GetCellValue(n, 5))]])
109 : ctreatma 1.2
110 : ctreatma 1.3 return results
111 : ctreatma 1.2
112 : ctreatma 1.3 #------------------------------------------------------------------------
113 :     def onSelectCell(self, evt):
114 :     #------------------------------------------------------------------------
115 :    
116 :     cellRow = evt.GetRow()
117 :     cellCol = evt.GetCol()
118 :     cellValue = self.agServerPageGrid.GetCellValue(cellRow, cellCol)
119 :    
120 : ctreatma 1.4 if (cellCol==0):
121 :     self.agServerPageGrid.SetCellValue(cellRow, cellCol, `1 - int(cellValue)`)
122 :    
123 : ctreatma 1.2 return
124 : ctreatma 1.3

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3