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

Annotation of /PyGUI/AGGetPubDialog.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (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.SetColLabelValue(1,"Name")
32 :     self.agServerPageGrid.SetColLabelValue(2,"Type")
33 :     self.agServerPageGrid.SetColLabelValue(3,"Id")
34 :     self.agServerPageGrid.SetColLabelValue(4,"Host")
35 :     self.agServerPageGrid.SetColLabelValue(5,"Port")
36 : efrank 1.5 self.agServerPageGrid.AutoSizeColumn(0)
37 :     self.agServerPageGrid.AutoSizeColumn(1)
38 :     self.agServerPageGrid.AutoSizeColumn(2)
39 :     self.agServerPageGrid.AutoSizeColumn(3)
40 :     self.agServerPageGrid.AutoSizeColumn(4)
41 :     self.agServerPageGrid.AutoSizeColumn(5)
42 :    
43 : ctreatma 1.2
44 : hwang 1.1 self.agServerPageGrid.SetColFormatBool(0)
45 :     #self.agServerPageGrid.SetColFormatBool(1)
46 :    
47 :     agServerPageMainSizer = wxBoxSizer(wxVERTICAL)
48 :     dialogChoicesHSizer = wxBoxSizer(wxHORIZONTAL)
49 :    
50 :     dialogChoicesHSizer.Add (self.okDialogBtn)
51 :     dialogChoicesHSizer.Add (self.cancelDialogBtn)
52 :    
53 :     agServerPageMainSizer.Add (self.agServerPageGrid, 7, wxEXPAND)
54 :     agServerPageMainSizer.Add (20,20, 0, wxEXPAND)
55 :     agServerPageMainSizer.Add (dialogChoicesHSizer)
56 :    
57 :     agServerPagePanel.SetSizer(agServerPageMainSizer)
58 :     agServerPagePanel.SetAutoLayout(true)
59 :    
60 :     EVT_BUTTON(self, self.cancelDialogBtn.GetId(), self.onDialogCancel)
61 :     EVT_BUTTON(self, self.okDialogBtn.GetId(), self.onDialogOK)
62 : ctreatma 1.3 EVT_GRID_CELL_LEFT_CLICK(self, self.onSelectCell)
63 :    
64 : ctreatma 1.2 self.getServersFromAG()
65 : hwang 1.1
66 :     return
67 :    
68 :     #------------------------------------------------------------------------
69 :     def onDialogCancel(self, evt):
70 :     #------------------------------------------------------------------------
71 :     self.EndModal(wxID_CANCEL)
72 :     return
73 :    
74 :     #------------------------------------------------------------------------
75 :     def onDialogOK(self, evt):
76 :     #------------------------------------------------------------------------
77 :     self.EndModal(wxID_OK)
78 :     return
79 :    
80 : ctreatma 1.2 #------------------------------------------------------------------------
81 :     def getServersFromAG(self):
82 :     #------------------------------------------------------------------------
83 :     servers = self.parent.mainMenuBar.catManager.getPublished()
84 :     numServers = len(servers)
85 :    
86 :     i = 0
87 :     for server in servers:
88 : efrank 1.5 print "getServersFromAG: ", server
89 : ctreatma 1.2 self.agServerPageGrid.AppendRows(numRows=1)
90 :     self.agServerPageGrid.SetCellValue(i, 0, '0')
91 :     for j in range(1, 4):
92 :     print j
93 :     self.agServerPageGrid.SetCellValue(i, j, server[j-1])
94 :     print self.agServerPageGrid.GetCellValue(i, j)
95 :     self.agServerPageGrid.SetCellValue(i, 4, server[3][0])
96 :     self.agServerPageGrid.SetCellValue(i, 5, `server[3][1]`)
97 :     self.agServerPageGrid.FitInside()
98 :     i = i + 1
99 :    
100 : efrank 1.5 self.agServerPageGrid.AutoSize()
101 :    
102 : ctreatma 1.2 return
103 :    
104 :     #------------------------------------------------------------------------
105 : ctreatma 1.3 def GetValue(self):
106 : ctreatma 1.2 #------------------------------------------------------------------------
107 : ctreatma 1.3 results = []
108 : ctreatma 1.2
109 : ctreatma 1.3 for n in range( self.agServerPageGrid.GetNumberRows() ):
110 :     if self.agServerPageGrid.GetCellValue(n, 0) != '0':
111 :     results.append([self.agServerPageGrid.GetCellValue(n, 1),
112 :     self.agServerPageGrid.GetCellValue(n, 2),
113 :     self.agServerPageGrid.GetCellValue(n, 3),
114 :     [self.agServerPageGrid.GetCellValue(n, 4),
115 :     int(self.agServerPageGrid.GetCellValue(n, 5))]])
116 : ctreatma 1.2
117 : ctreatma 1.3 return results
118 : ctreatma 1.2
119 : ctreatma 1.3 #------------------------------------------------------------------------
120 :     def onSelectCell(self, evt):
121 :     #------------------------------------------------------------------------
122 :    
123 :     cellRow = evt.GetRow()
124 :     cellCol = evt.GetCol()
125 :     cellValue = self.agServerPageGrid.GetCellValue(cellRow, cellCol)
126 :    
127 : ctreatma 1.4 if (cellCol==0):
128 :     self.agServerPageGrid.SetCellValue(cellRow, cellCol, `1 - int(cellValue)`)
129 :    
130 : ctreatma 1.2 return
131 : ctreatma 1.3

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3