-
Notifications
You must be signed in to change notification settings - Fork 0
/
GridTable.py
executable file
·65 lines (56 loc) · 2.1 KB
/
GridTable.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import wx
import wx.grid as gridlib
from wx.lib.pubsub import pub
import project
import globaldata
class GenericTable(wx.grid.PyGridTableBase):
def __init__(self, data, rowLabels=None, colLabels=None):
wx.grid.PyGridTableBase.__init__(self)
self.data = data
self.rowLabels = globaldata.rowLabels
self.colLabels = globaldata.colLabels
def GetNumberRows(self):
return len(self.data)
# return globaldata.days_per_week
def GetNumberCols(self):
return len(self.data[0])
# return globaldata.lectures_per_day
def GetColLabelValue(self, col):
if self.colLabels:
return self.colLabels[col]
def GetRowLabelValue(self, row):
if self.rowLabels:
return self.rowLabels[row]
def IsEmptyCell(self, row, col):
return self.data[row][col] == None
def GetValue(self, row, col):
if self.data[row][col] == None:
return ''
else:
res = ''
for i in range(len(self.data[row][col])):
for j in range(len(self.data[row][col][i])):
if self.data[row][col][i][j] != None:
t = str(self.data[row][col][i][j]) + ' '
res += t
res += '\n'
#to fix - there's some garbage at the end of line
# print res
return res
# return self.data[row][col]
def SetValue(self, row, col, value):
print 'set value', row, col, value
#deletion not perfect - when cell has batch entries it wont work
# if value == '':
# data = self.data[row][col]
# if len(data) == 4:
# project.remove_all(data[0], data[1], data[2], row, col)
# else:
# project.remove_lunch(data[1], row, col)
# else:
value = value.split(' ')
try:
project.insert_entry(value[0], value[1], value[2], value[3], row, col)
except:
print 'Cant update cell', row, col
pub.sendMessage('UPDATE_VIEW', data = None)