This diff has been collapsed as it changes many lines, (1528 lines changed)
Show them
Hide them
|
|
@@
-1,764
+1,764
|
|
1
|
# -*- coding: iso-8859-1 -*-
|
|
1
|
# -*- coding: iso-8859-1 -*-
|
|
2
|
|
|
2
|
|
|
3
|
import ipipe, os, webbrowser, urllib
|
|
3
|
import ipipe, os, webbrowser, urllib
|
|
4
|
import wx
|
|
4
|
import wx
|
|
5
|
import wx.grid, wx.html
|
|
5
|
import wx.grid, wx.html
|
|
6
|
|
|
6
|
|
|
7
|
try:
|
|
7
|
try:
|
|
8
|
sorted
|
|
8
|
sorted
|
|
9
|
except NameError:
|
|
9
|
except NameError:
|
|
10
|
from ipipe import sorted
|
|
10
|
from ipipe import sorted
|
|
11
|
|
|
11
|
|
|
12
|
|
|
12
|
|
|
13
|
__all__ = ["igrid"]
|
|
13
|
__all__ = ["igrid"]
|
|
14
|
|
|
14
|
|
|
15
|
|
|
15
|
|
|
16
|
class IGridRenderer(wx.grid.PyGridCellRenderer):
|
|
16
|
class IGridRenderer(wx.grid.PyGridCellRenderer):
|
|
17
|
"""
|
|
17
|
"""
|
|
18
|
This is a custom renderer for our IGridGrid
|
|
18
|
This is a custom renderer for our IGridGrid
|
|
19
|
"""
|
|
19
|
"""
|
|
20
|
def __init__(self, table):
|
|
20
|
def __init__(self, table):
|
|
21
|
self.maxchars = 200
|
|
21
|
self.maxchars = 200
|
|
22
|
self.table = table
|
|
22
|
self.table = table
|
|
23
|
self.colormap = (
|
|
23
|
self.colormap = (
|
|
24
|
( 0, 0, 0),
|
|
24
|
( 0, 0, 0),
|
|
25
|
(174, 0, 0),
|
|
25
|
(174, 0, 0),
|
|
26
|
( 0, 174, 0),
|
|
26
|
( 0, 174, 0),
|
|
27
|
(174, 174, 0),
|
|
27
|
(174, 174, 0),
|
|
28
|
( 0, 0, 174),
|
|
28
|
( 0, 0, 174),
|
|
29
|
(174, 0, 174),
|
|
29
|
(174, 0, 174),
|
|
30
|
( 0, 174, 174),
|
|
30
|
( 0, 174, 174),
|
|
31
|
( 64, 64, 64)
|
|
31
|
( 64, 64, 64)
|
|
32
|
)
|
|
32
|
)
|
|
33
|
|
|
33
|
|
|
34
|
wx.grid.PyGridCellRenderer.__init__(self)
|
|
34
|
wx.grid.PyGridCellRenderer.__init__(self)
|
|
35
|
|
|
35
|
|
|
36
|
def _getvalue(self, row, col):
|
|
36
|
def _getvalue(self, row, col):
|
|
37
|
try:
|
|
37
|
try:
|
|
38
|
value = self.table.displayattrs[col].value(self.table.items[row])
|
|
38
|
value = self.table.displayattrs[col].value(self.table.items[row])
|
|
39
|
(align, width, text) = ipipe.xformat(value, "cell", self.maxchars)
|
|
39
|
(align, width, text) = ipipe.xformat(value, "cell", self.maxchars)
|
|
40
|
except Exception, exc:
|
|
40
|
except Exception, exc:
|
|
41
|
(align, width, text) = ipipe.xformat(exc, "cell", self.maxchars)
|
|
41
|
(align, width, text) = ipipe.xformat(exc, "cell", self.maxchars)
|
|
42
|
return (align, text)
|
|
42
|
return (align, text)
|
|
43
|
|
|
43
|
|
|
44
|
def GetBestSize(self, grid, attr, dc, row, col):
|
|
44
|
def GetBestSize(self, grid, attr, dc, row, col):
|
|
45
|
text = grid.GetCellValue(row, col)
|
|
45
|
text = grid.GetCellValue(row, col)
|
|
46
|
(align, text) = self._getvalue(row, col)
|
|
46
|
(align, text) = self._getvalue(row, col)
|
|
47
|
dc.SetFont(attr.GetFont())
|
|
47
|
dc.SetFont(attr.GetFont())
|
|
48
|
(w, h) = dc.GetTextExtent(str(text))
|
|
48
|
(w, h) = dc.GetTextExtent(str(text))
|
|
49
|
return wx.Size(min(w+2, 600), h+2) # add border
|
|
49
|
return wx.Size(min(w+2, 600), h+2) # add border
|
|
50
|
|
|
50
|
|
|
51
|
def Draw(self, grid, attr, dc, rect, row, col, isSelected):
|
|
51
|
def Draw(self, grid, attr, dc, rect, row, col, isSelected):
|
|
52
|
"""
|
|
52
|
"""
|
|
53
|
Takes care of drawing everything in the cell; aligns the text
|
|
53
|
Takes care of drawing everything in the cell; aligns the text
|
|
54
|
"""
|
|
54
|
"""
|
|
55
|
text = grid.GetCellValue(row, col)
|
|
55
|
text = grid.GetCellValue(row, col)
|
|
56
|
(align, text) = self._getvalue(row, col)
|
|
56
|
(align, text) = self._getvalue(row, col)
|
|
57
|
if isSelected:
|
|
57
|
if isSelected:
|
|
58
|
bg = grid.GetSelectionBackground()
|
|
58
|
bg = grid.GetSelectionBackground()
|
|
59
|
else:
|
|
59
|
else:
|
|
60
|
bg = ["white", (240, 240, 240)][row%2]
|
|
60
|
bg = ["white", (240, 240, 240)][row%2]
|
|
61
|
dc.SetTextBackground(bg)
|
|
61
|
dc.SetTextBackground(bg)
|
|
62
|
dc.SetBrush(wx.Brush(bg, wx.SOLID))
|
|
62
|
dc.SetBrush(wx.Brush(bg, wx.SOLID))
|
|
63
|
dc.SetPen(wx.TRANSPARENT_PEN)
|
|
63
|
dc.SetPen(wx.TRANSPARENT_PEN)
|
|
64
|
dc.SetFont(attr.GetFont())
|
|
64
|
dc.SetFont(attr.GetFont())
|
|
65
|
dc.DrawRectangleRect(rect)
|
|
65
|
dc.DrawRectangleRect(rect)
|
|
66
|
dc.SetClippingRect(rect)
|
|
66
|
dc.SetClippingRect(rect)
|
|
67
|
# Format the text
|
|
67
|
# Format the text
|
|
68
|
if align == -1: # left alignment
|
|
68
|
if align == -1: # left alignment
|
|
69
|
(width, height) = dc.GetTextExtent(str(text))
|
|
69
|
(width, height) = dc.GetTextExtent(str(text))
|
|
70
|
x = rect[0]+1
|
|
70
|
x = rect[0]+1
|
|
71
|
y = rect[1]+0.5*(rect[3]-height)
|
|
71
|
y = rect[1]+0.5*(rect[3]-height)
|
|
72
|
|
|
72
|
|
|
73
|
for (style, part) in text:
|
|
73
|
for (style, part) in text:
|
|
74
|
if isSelected:
|
|
74
|
if isSelected:
|
|
75
|
fg = grid.GetSelectionForeground()
|
|
75
|
fg = grid.GetSelectionForeground()
|
|
76
|
else:
|
|
76
|
else:
|
|
77
|
fg = self.colormap[style.fg]
|
|
77
|
fg = self.colormap[style.fg]
|
|
78
|
dc.SetTextForeground(fg)
|
|
78
|
dc.SetTextForeground(fg)
|
|
79
|
(w, h) = dc.GetTextExtent(part)
|
|
79
|
(w, h) = dc.GetTextExtent(part)
|
|
80
|
dc.DrawText(part, x, y)
|
|
80
|
dc.DrawText(part, x, y)
|
|
81
|
x += w
|
|
81
|
x += w
|
|
82
|
elif align == 0: # center alignment
|
|
82
|
elif align == 0: # center alignment
|
|
83
|
(width, height) = dc.GetTextExtent(str(text))
|
|
83
|
(width, height) = dc.GetTextExtent(str(text))
|
|
84
|
x = rect[0]+0.5*(rect[2]-width)
|
|
84
|
x = rect[0]+0.5*(rect[2]-width)
|
|
85
|
y = rect[1]+0.5*(rect[3]-height)
|
|
85
|
y = rect[1]+0.5*(rect[3]-height)
|
|
86
|
for (style, part) in text:
|
|
86
|
for (style, part) in text:
|
|
87
|
if isSelected:
|
|
87
|
if isSelected:
|
|
88
|
fg = grid.GetSelectionForeground()
|
|
88
|
fg = grid.GetSelectionForeground()
|
|
89
|
else:
|
|
89
|
else:
|
|
90
|
fg = self.colormap[style.fg]
|
|
90
|
fg = self.colormap[style.fg]
|
|
91
|
dc.SetTextForeground(fg)
|
|
91
|
dc.SetTextForeground(fg)
|
|
92
|
(w, h) = dc.GetTextExtent(part)
|
|
92
|
(w, h) = dc.GetTextExtent(part)
|
|
93
|
dc.DrawText(part, x, y)
|
|
93
|
dc.DrawText(part, x, y)
|
|
94
|
x += w
|
|
94
|
x += w
|
|
95
|
else: # right alignment
|
|
95
|
else: # right alignment
|
|
96
|
(width, height) = dc.GetTextExtent(str(text))
|
|
96
|
(width, height) = dc.GetTextExtent(str(text))
|
|
97
|
x = rect[0]+rect[2]-1
|
|
97
|
x = rect[0]+rect[2]-1
|
|
98
|
y = rect[1]+0.5*(rect[3]-height)
|
|
98
|
y = rect[1]+0.5*(rect[3]-height)
|
|
99
|
for (style, part) in reversed(text):
|
|
99
|
for (style, part) in reversed(text):
|
|
100
|
(w, h) = dc.GetTextExtent(part)
|
|
100
|
(w, h) = dc.GetTextExtent(part)
|
|
101
|
x -= w
|
|
101
|
x -= w
|
|
102
|
if isSelected:
|
|
102
|
if isSelected:
|
|
103
|
fg = grid.GetSelectionForeground()
|
|
103
|
fg = grid.GetSelectionForeground()
|
|
104
|
else:
|
|
104
|
else:
|
|
105
|
fg = self.colormap[style.fg]
|
|
105
|
fg = self.colormap[style.fg]
|
|
106
|
dc.SetTextForeground(fg)
|
|
106
|
dc.SetTextForeground(fg)
|
|
107
|
dc.DrawText(part, x, y)
|
|
107
|
dc.DrawText(part, x, y)
|
|
108
|
dc.DestroyClippingRegion()
|
|
108
|
dc.DestroyClippingRegion()
|
|
109
|
|
|
109
|
|
|
110
|
def Clone(self):
|
|
110
|
def Clone(self):
|
|
111
|
return IGridRenderer(self.table)
|
|
111
|
return IGridRenderer(self.table)
|
|
112
|
|
|
112
|
|
|
113
|
|
|
113
|
|
|
114
|
class IGridTable(wx.grid.PyGridTableBase):
|
|
114
|
class IGridTable(wx.grid.PyGridTableBase):
|
|
115
|
# The data table for the ``IGridGrid``. Some dirty tricks were used here:
|
|
115
|
# The data table for the ``IGridGrid``. Some dirty tricks were used here:
|
|
116
|
# ``GetValue()`` does not get any values (or at least it does not return
|
|
116
|
# ``GetValue()`` does not get any values (or at least it does not return
|
|
117
|
# anything, accessing the values is done by the renderer)
|
|
117
|
# anything, accessing the values is done by the renderer)
|
|
118
|
# but rather tries to fetch the objects which were requested into the table.
|
|
118
|
# but rather tries to fetch the objects which were requested into the table.
|
|
119
|
# General behaviour is: Fetch the first X objects. If the user scrolls down
|
|
119
|
# General behaviour is: Fetch the first X objects. If the user scrolls down
|
|
120
|
# to the last object another bunch of X objects is fetched (if possible)
|
|
120
|
# to the last object another bunch of X objects is fetched (if possible)
|
|
121
|
def __init__(self, input, fontsize, *attrs):
|
|
121
|
def __init__(self, input, fontsize, *attrs):
|
|
122
|
wx.grid.PyGridTableBase.__init__(self)
|
|
122
|
wx.grid.PyGridTableBase.__init__(self)
|
|
123
|
self.input = input
|
|
123
|
self.input = input
|
|
124
|
self.iterator = ipipe.xiter(input)
|
|
124
|
self.iterator = ipipe.xiter(input)
|
|
125
|
self.items = []
|
|
125
|
self.items = []
|
|
126
|
self.hiddenattrs = []
|
|
126
|
self.hiddenattrs = []
|
|
127
|
self.attrs = attrs
|
|
127
|
self.attrs = attrs
|
|
128
|
self.displayattrs = []
|
|
128
|
self.displayattrs = []
|
|
129
|
self.fetch(1)
|
|
129
|
self.fetch(1)
|
|
130
|
self.sizing = False
|
|
130
|
self.sizing = False
|
|
131
|
self.fontsize = fontsize
|
|
131
|
self.fontsize = fontsize
|
|
132
|
|
|
132
|
|
|
133
|
def GetAttr(self, *args):
|
|
133
|
def GetAttr(self, *args):
|
|
134
|
attr = wx.grid.GridCellAttr()
|
|
134
|
attr = wx.grid.GridCellAttr()
|
|
135
|
attr.SetFont(wx.Font(self.fontsize, wx.TELETYPE, wx.NORMAL, wx.NORMAL))
|
|
135
|
attr.SetFont(wx.Font(self.fontsize, wx.TELETYPE, wx.NORMAL, wx.NORMAL))
|
|
136
|
return attr
|
|
136
|
return attr
|
|
137
|
|
|
137
|
|
|
138
|
def GetNumberRows(self):
|
|
138
|
def GetNumberRows(self):
|
|
139
|
return len(self.items)
|
|
139
|
return len(self.items)
|
|
140
|
|
|
140
|
|
|
141
|
def GetNumberCols(self):
|
|
141
|
def GetNumberCols(self):
|
|
142
|
return len(self.displayattrs)
|
|
142
|
return len(self.displayattrs)
|
|
143
|
|
|
143
|
|
|
144
|
def GetColLabelValue(self, col):
|
|
144
|
def GetColLabelValue(self, col):
|
|
145
|
if col < len(self.displayattrs):
|
|
145
|
if col < len(self.displayattrs):
|
|
146
|
return self.displayattrs[col].name()
|
|
146
|
return self.displayattrs[col].name()
|
|
147
|
else:
|
|
147
|
else:
|
|
148
|
return ""
|
|
148
|
return ""
|
|
149
|
|
|
149
|
|
|
150
|
def GetRowLabelValue(self, row):
|
|
150
|
def GetRowLabelValue(self, row):
|
|
151
|
return str(row)
|
|
151
|
return str(row)
|
|
152
|
|
|
152
|
|
|
153
|
def IsEmptyCell(self, row, col):
|
|
153
|
def IsEmptyCell(self, row, col):
|
|
154
|
return False
|
|
154
|
return False
|
|
155
|
|
|
155
|
|
|
156
|
def fetch(self, count):
|
|
156
|
def fetch(self, count):
|
|
157
|
# Try to fill ``self.items`` with at least ``count`` objects.
|
|
157
|
# Try to fill ``self.items`` with at least ``count`` objects.
|
|
158
|
have = len(self.items)
|
|
158
|
have = len(self.items)
|
|
159
|
work = False
|
|
159
|
work = False
|
|
160
|
while self.iterator is not None and have < count:
|
|
160
|
while self.iterator is not None and have < count:
|
|
161
|
try:
|
|
161
|
try:
|
|
162
|
item = self.iterator.next()
|
|
162
|
item = self.iterator.next()
|
|
163
|
except StopIteration:
|
|
163
|
except StopIteration:
|
|
164
|
self.iterator = None
|
|
164
|
self.iterator = None
|
|
165
|
break
|
|
165
|
break
|
|
166
|
except (KeyboardInterrupt, SystemExit):
|
|
166
|
except (KeyboardInterrupt, SystemExit):
|
|
167
|
raise
|
|
167
|
raise
|
|
168
|
except Exception, exc:
|
|
168
|
except Exception, exc:
|
|
169
|
have += 1
|
|
169
|
have += 1
|
|
170
|
self.items.append(exc)
|
|
170
|
self.items.append(exc)
|
|
171
|
work = True
|
|
171
|
work = True
|
|
172
|
self.iterator = None
|
|
172
|
self.iterator = None
|
|
173
|
break
|
|
173
|
break
|
|
174
|
else:
|
|
174
|
else:
|
|
175
|
have += 1
|
|
175
|
have += 1
|
|
176
|
self.items.append(item)
|
|
176
|
self.items.append(item)
|
|
177
|
work = True
|
|
177
|
work = True
|
|
178
|
if work:
|
|
178
|
if work:
|
|
179
|
self.calcdisplayattrs()
|
|
179
|
self.calcdisplayattrs()
|
|
180
|
|
|
180
|
|
|
181
|
def calcdisplayattrs(self):
|
|
181
|
def calcdisplayattrs(self):
|
|
182
|
# Calculate which attributes are available from the objects that are
|
|
182
|
# Calculate which attributes are available from the objects that are
|
|
183
|
# currently visible on screen (and store it in ``self.displayattrs``)
|
|
183
|
# currently visible on screen (and store it in ``self.displayattrs``)
|
|
184
|
attrs = set()
|
|
184
|
attrs = set()
|
|
185
|
self.displayattrs = []
|
|
185
|
self.displayattrs = []
|
|
186
|
if self.attrs:
|
|
186
|
if self.attrs:
|
|
187
|
# If the browser object specifies a fixed list of attributes,
|
|
187
|
# If the browser object specifies a fixed list of attributes,
|
|
188
|
# simply use it (removing hidden attributes).
|
|
188
|
# simply use it (removing hidden attributes).
|
|
189
|
for attr in self.attrs:
|
|
189
|
for attr in self.attrs:
|
|
190
|
attr = ipipe.upgradexattr(attr)
|
|
190
|
attr = ipipe.upgradexattr(attr)
|
|
191
|
if attr not in attrs and attr not in self.hiddenattrs:
|
|
191
|
if attr not in attrs and attr not in self.hiddenattrs:
|
|
192
|
self.displayattrs.append(attr)
|
|
192
|
self.displayattrs.append(attr)
|
|
193
|
attrs.add(attr)
|
|
193
|
attrs.add(attr)
|
|
194
|
else:
|
|
194
|
else:
|
|
195
|
endy = len(self.items)
|
|
195
|
endy = len(self.items)
|
|
196
|
for i in xrange(endy):
|
|
196
|
for i in xrange(endy):
|
|
197
|
for attr in ipipe.xattrs(self.items[i]):
|
|
197
|
for attr in ipipe.xattrs(self.items[i]):
|
|
198
|
attr = ipipe.upgradexattr(attr)
|
|
198
|
attr = ipipe.upgradexattr(attr)
|
|
199
|
if attr not in attrs and attr not in self.hiddenattrs:
|
|
199
|
if attr not in attrs and attr not in self.hiddenattrs:
|
|
200
|
self.displayattrs.append(attr)
|
|
200
|
self.displayattrs.append(attr)
|
|
201
|
attrs.add(attr)
|
|
201
|
attrs.add(attr)
|
|
202
|
|
|
202
|
|
|
203
|
def GetValue(self, row, col):
|
|
203
|
def GetValue(self, row, col):
|
|
204
|
# some kind of dummy-function: does not return anything but "";
|
|
204
|
# some kind of dummy-function: does not return anything but "";
|
|
205
|
# (The value isn't use anyway)
|
|
205
|
# (The value isn't use anyway)
|
|
206
|
# its main task is to trigger the fetch of new objects
|
|
206
|
# its main task is to trigger the fetch of new objects
|
|
207
|
had_cols = self.displayattrs[:]
|
|
207
|
had_cols = self.displayattrs[:]
|
|
208
|
had_rows = len(self.items)
|
|
208
|
had_rows = len(self.items)
|
|
209
|
if row == had_rows - 1 and self.iterator is not None and not self.sizing:
|
|
209
|
if row == had_rows - 1 and self.iterator is not None and not self.sizing:
|
|
210
|
self.fetch(row + 20)
|
|
210
|
self.fetch(row + 20)
|
|
211
|
have_rows = len(self.items)
|
|
211
|
have_rows = len(self.items)
|
|
212
|
have_cols = len(self.displayattrs)
|
|
212
|
have_cols = len(self.displayattrs)
|
|
213
|
if have_rows > had_rows:
|
|
213
|
if have_rows > had_rows:
|
|
214
|
msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED, have_rows - had_rows)
|
|
214
|
msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED, have_rows - had_rows)
|
|
215
|
self.GetView().ProcessTableMessage(msg)
|
|
215
|
self.GetView().ProcessTableMessage(msg)
|
|
216
|
self.sizing = True
|
|
216
|
self.sizing = True
|
|
217
|
self.GetView().AutoSizeColumns(False)
|
|
217
|
self.GetView().AutoSizeColumns(False)
|
|
218
|
self.sizing = False
|
|
218
|
self.sizing = False
|
|
219
|
if row >= have_rows:
|
|
219
|
if row >= have_rows:
|
|
220
|
return ""
|
|
220
|
return ""
|
|
221
|
if self.displayattrs != had_cols:
|
|
221
|
if self.displayattrs != had_cols:
|
|
222
|
msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED, have_cols - len(had_cols))
|
|
222
|
msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED, have_cols - len(had_cols))
|
|
223
|
self.GetView().ProcessTableMessage(msg)
|
|
223
|
self.GetView().ProcessTableMessage(msg)
|
|
224
|
return ""
|
|
224
|
return ""
|
|
225
|
|
|
225
|
|
|
226
|
def SetValue(self, row, col, value):
|
|
226
|
def SetValue(self, row, col, value):
|
|
227
|
pass
|
|
227
|
pass
|
|
228
|
|
|
228
|
|
|
229
|
|
|
229
|
|
|
230
|
class IGridGrid(wx.grid.Grid):
|
|
230
|
class IGridGrid(wx.grid.Grid):
|
|
231
|
# The actual grid
|
|
231
|
# The actual grid
|
|
232
|
# all methods for selecting/sorting/picking/... data are implemented here
|
|
232
|
# all methods for selecting/sorting/picking/... data are implemented here
|
|
233
|
def __init__(self, panel, input, *attrs):
|
|
233
|
def __init__(self, panel, input, *attrs):
|
|
234
|
wx.grid.Grid.__init__(self, panel)
|
|
234
|
wx.grid.Grid.__init__(self, panel)
|
|
235
|
fontsize = 9
|
|
235
|
fontsize = 9
|
|
236
|
self.input = input
|
|
236
|
self.input = input
|
|
237
|
self.table = IGridTable(self.input, fontsize, *attrs)
|
|
237
|
self.table = IGridTable(self.input, fontsize, *attrs)
|
|
238
|
self.SetTable(self.table, True)
|
|
238
|
self.SetTable(self.table, True)
|
|
239
|
self.SetSelectionMode(wx.grid.Grid.wxGridSelectRows)
|
|
239
|
self.SetSelectionMode(wx.grid.Grid.wxGridSelectRows)
|
|
240
|
self.SetDefaultRenderer(IGridRenderer(self.table))
|
|
240
|
self.SetDefaultRenderer(IGridRenderer(self.table))
|
|
241
|
self.EnableEditing(False)
|
|
241
|
self.EnableEditing(False)
|
|
242
|
self.Bind(wx.EVT_KEY_DOWN, self.key_pressed)
|
|
242
|
self.Bind(wx.EVT_KEY_DOWN, self.key_pressed)
|
|
243
|
self.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.cell_doubleclicked)
|
|
243
|
self.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.cell_doubleclicked)
|
|
244
|
self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_DCLICK, self.label_doubleclicked)
|
|
244
|
self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_DCLICK, self.label_doubleclicked)
|
|
245
|
self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_CLICK, self.on_label_leftclick)
|
|
245
|
self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_CLICK, self.on_label_leftclick)
|
|
246
|
self.Bind(wx.grid.EVT_GRID_RANGE_SELECT, self._on_selected_range)
|
|
246
|
self.Bind(wx.grid.EVT_GRID_RANGE_SELECT, self._on_selected_range)
|
|
247
|
self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self._on_selected_cell)
|
|
247
|
self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self._on_selected_cell)
|
|
248
|
self.current_selection = set()
|
|
248
|
self.current_selection = set()
|
|
249
|
self.maxchars = 200
|
|
249
|
self.maxchars = 200
|
|
250
|
|
|
250
|
|
|
251
|
def on_label_leftclick(self, event):
|
|
251
|
def on_label_leftclick(self, event):
|
|
252
|
event.Skip()
|
|
252
|
event.Skip()
|
|
253
|
|
|
253
|
|
|
254
|
def error_output(self, text):
|
|
254
|
def error_output(self, text):
|
|
255
|
wx.Bell()
|
|
255
|
wx.Bell()
|
|
256
|
frame = self.GetParent().GetParent().GetParent()
|
|
256
|
frame = self.GetParent().GetParent().GetParent()
|
|
257
|
frame.SetStatusText(text)
|
|
257
|
frame.SetStatusText(text)
|
|
258
|
|
|
258
|
|
|
259
|
def _on_selected_range(self, event):
|
|
259
|
def _on_selected_range(self, event):
|
|
260
|
# Internal update to the selection tracking lists
|
|
260
|
# Internal update to the selection tracking lists
|
|
261
|
if event.Selecting():
|
|
261
|
if event.Selecting():
|
|
262
|
# adding to the list...
|
|
262
|
# adding to the list...
|
|
263
|
self.current_selection.update(xrange(event.GetTopRow(), event.GetBottomRow()+1))
|
|
263
|
self.current_selection.update(xrange(event.GetTopRow(), event.GetBottomRow()+1))
|
|
264
|
else:
|
|
264
|
else:
|
|
265
|
# removal from list
|
|
265
|
# removal from list
|
|
266
|
for index in xrange( event.GetTopRow(), event.GetBottomRow()+1):
|
|
266
|
for index in xrange( event.GetTopRow(), event.GetBottomRow()+1):
|
|
267
|
self.current_selection.discard(index)
|
|
267
|
self.current_selection.discard(index)
|
|
268
|
event.Skip()
|
|
268
|
event.Skip()
|
|
269
|
|
|
269
|
|
|
270
|
def _on_selected_cell(self, event):
|
|
270
|
def _on_selected_cell(self, event):
|
|
271
|
# Internal update to the selection tracking list
|
|
271
|
# Internal update to the selection tracking list
|
|
272
|
self.current_selection = set([event.GetRow()])
|
|
272
|
self.current_selection = set([event.GetRow()])
|
|
273
|
event.Skip()
|
|
273
|
event.Skip()
|
|
274
|
|
|
274
|
|
|
275
|
def sort(self, key, reverse=False):
|
|
275
|
def sort(self, key, reverse=False):
|
|
276
|
"""
|
|
276
|
"""
|
|
277
|
Sort the current list of items using the key function ``key``. If
|
|
277
|
Sort the current list of items using the key function ``key``. If
|
|
278
|
``reverse`` is true the sort order is reversed.
|
|
278
|
``reverse`` is true the sort order is reversed.
|
|
279
|
"""
|
|
279
|
"""
|
|
280
|
row = self.GetGridCursorRow()
|
|
280
|
row = self.GetGridCursorRow()
|
|
281
|
col = self.GetGridCursorCol()
|
|
281
|
col = self.GetGridCursorCol()
|
|
282
|
curitem = self.table.items[row] # Remember where the cursor is now
|
|
282
|
curitem = self.table.items[row] # Remember where the cursor is now
|
|
283
|
# Sort items
|
|
283
|
# Sort items
|
|
284
|
def realkey(item):
|
|
284
|
def realkey(item):
|
|
285
|
return key(item)
|
|
285
|
return key(item)
|
|
286
|
try:
|
|
286
|
try:
|
|
287
|
self.table.items = ipipe.deque(sorted(self.table.items, key=realkey, reverse=reverse))
|
|
287
|
self.table.items = ipipe.deque(sorted(self.table.items, key=realkey, reverse=reverse))
|
|
288
|
except TypeError, exc:
|
|
288
|
except TypeError, exc:
|
|
289
|
self.error_output("Exception encountered: %s" % exc)
|
|
289
|
self.error_output("Exception encountered: %s" % exc)
|
|
290
|
return
|
|
290
|
return
|
|
291
|
# Find out where the object under the cursor went
|
|
291
|
# Find out where the object under the cursor went
|
|
292
|
for (i, item) in enumerate(self.table.items):
|
|
292
|
for (i, item) in enumerate(self.table.items):
|
|
293
|
if item is curitem:
|
|
293
|
if item is curitem:
|
|
294
|
self.SetGridCursor(i,col)
|
|
294
|
self.SetGridCursor(i,col)
|
|
295
|
self.MakeCellVisible(i,col)
|
|
295
|
self.MakeCellVisible(i,col)
|
|
296
|
self.Refresh()
|
|
296
|
self.Refresh()
|
|
297
|
|
|
297
|
|
|
298
|
def sortattrasc(self):
|
|
298
|
def sortattrasc(self):
|
|
299
|
"""
|
|
299
|
"""
|
|
300
|
Sort in ascending order; sorting criteria is the current attribute
|
|
300
|
Sort in ascending order; sorting criteria is the current attribute
|
|
301
|
"""
|
|
301
|
"""
|
|
302
|
col = self.GetGridCursorCol()
|
|
302
|
col = self.GetGridCursorCol()
|
|
303
|
attr = self.table.displayattrs[col]
|
|
303
|
attr = self.table.displayattrs[col]
|
|
304
|
frame = self.GetParent().GetParent().GetParent()
|
|
304
|
frame = self.GetParent().GetParent().GetParent()
|
|
305
|
if attr is ipipe.noitem:
|
|
305
|
if attr is ipipe.noitem:
|
|
306
|
self.error_output("no column under cursor")
|
|
306
|
self.error_output("no column under cursor")
|
|
307
|
return
|
|
307
|
return
|
|
308
|
frame.SetStatusText("sort by %s (ascending)" % attr.name())
|
|
308
|
frame.SetStatusText("sort by %s (ascending)" % attr.name())
|
|
309
|
def key(item):
|
|
309
|
def key(item):
|
|
310
|
try:
|
|
310
|
try:
|
|
311
|
return attr.value(item)
|
|
311
|
return attr.value(item)
|
|
312
|
except (KeyboardInterrupt, SystemExit):
|
|
312
|
except (KeyboardInterrupt, SystemExit):
|
|
313
|
raise
|
|
313
|
raise
|
|
314
|
except Exception:
|
|
314
|
except Exception:
|
|
315
|
return None
|
|
315
|
return None
|
|
316
|
self.sort(key)
|
|
316
|
self.sort(key)
|
|
317
|
|
|
317
|
|
|
318
|
def sortattrdesc(self):
|
|
318
|
def sortattrdesc(self):
|
|
319
|
"""
|
|
319
|
"""
|
|
320
|
Sort in descending order; sorting criteria is the current attribute
|
|
320
|
Sort in descending order; sorting criteria is the current attribute
|
|
321
|
"""
|
|
321
|
"""
|
|
322
|
col = self.GetGridCursorCol()
|
|
322
|
col = self.GetGridCursorCol()
|
|
323
|
attr = self.table.displayattrs[col]
|
|
323
|
attr = self.table.displayattrs[col]
|
|
324
|
frame = self.GetParent().GetParent().GetParent()
|
|
324
|
frame = self.GetParent().GetParent().GetParent()
|
|
325
|
if attr is ipipe.noitem:
|
|
325
|
if attr is ipipe.noitem:
|
|
326
|
self.error_output("no column under cursor")
|
|
326
|
self.error_output("no column under cursor")
|
|
327
|
return
|
|
327
|
return
|
|
328
|
frame.SetStatusText("sort by %s (descending)" % attr.name())
|
|
328
|
frame.SetStatusText("sort by %s (descending)" % attr.name())
|
|
329
|
def key(item):
|
|
329
|
def key(item):
|
|
330
|
try:
|
|
330
|
try:
|
|
331
|
return attr.value(item)
|
|
331
|
return attr.value(item)
|
|
332
|
except (KeyboardInterrupt, SystemExit):
|
|
332
|
except (KeyboardInterrupt, SystemExit):
|
|
333
|
raise
|
|
333
|
raise
|
|
334
|
except Exception:
|
|
334
|
except Exception:
|
|
335
|
return None
|
|
335
|
return None
|
|
336
|
self.sort(key, reverse=True)
|
|
336
|
self.sort(key, reverse=True)
|
|
337
|
|
|
337
|
|
|
338
|
def label_doubleclicked(self, event):
|
|
338
|
def label_doubleclicked(self, event):
|
|
339
|
row = event.GetRow()
|
|
339
|
row = event.GetRow()
|
|
340
|
col = event.GetCol()
|
|
340
|
col = event.GetCol()
|
|
341
|
if col == -1:
|
|
341
|
if col == -1:
|
|
342
|
self.enter(row)
|
|
342
|
self.enter(row)
|
|
343
|
|
|
343
|
|
|
344
|
def _getvalue(self, row, col):
|
|
344
|
def _getvalue(self, row, col):
|
|
345
|
"""
|
|
345
|
"""
|
|
346
|
Gets the text which is displayed at ``(row, col)``
|
|
346
|
Gets the text which is displayed at ``(row, col)``
|
|
347
|
"""
|
|
347
|
"""
|
|
348
|
try:
|
|
348
|
try:
|
|
349
|
value = self.table.displayattrs[col].value(self.table.items[row])
|
|
349
|
value = self.table.displayattrs[col].value(self.table.items[row])
|
|
350
|
(align, width, text) = ipipe.xformat(value, "cell", self.maxchars)
|
|
350
|
(align, width, text) = ipipe.xformat(value, "cell", self.maxchars)
|
|
351
|
except IndexError:
|
|
351
|
except IndexError:
|
|
352
|
raise IndexError
|
|
352
|
raise IndexError
|
|
353
|
except Exception, exc:
|
|
353
|
except Exception, exc:
|
|
354
|
(align, width, text) = ipipe.xformat(exc, "cell", self.maxchars)
|
|
354
|
(align, width, text) = ipipe.xformat(exc, "cell", self.maxchars)
|
|
355
|
return text
|
|
355
|
return text
|
|
356
|
|
|
356
|
|
|
357
|
def search(self, searchtext, startrow=0, startcol=0, search_forward=True):
|
|
357
|
def search(self, searchtext, startrow=0, startcol=0, search_forward=True):
|
|
358
|
"""
|
|
358
|
"""
|
|
359
|
search for ``searchtext``, starting in ``(startrow, startcol)``;
|
|
359
|
search for ``searchtext``, starting in ``(startrow, startcol)``;
|
|
360
|
if ``search_forward`` is true the direction is "forward"
|
|
360
|
if ``search_forward`` is true the direction is "forward"
|
|
361
|
"""
|
|
361
|
"""
|
|
362
|
row = startrow
|
|
362
|
row = startrow
|
|
363
|
searchtext = searchtext.lower()
|
|
363
|
searchtext = searchtext.lower()
|
|
364
|
if search_forward:
|
|
364
|
if search_forward:
|
|
365
|
while True:
|
|
365
|
while True:
|
|
366
|
for col in xrange(startcol, self.table.GetNumberCols()):
|
|
366
|
for col in xrange(startcol, self.table.GetNumberCols()):
|
|
367
|
try:
|
|
367
|
try:
|
|
368
|
foo = self.table.GetValue(row, col)
|
|
368
|
foo = self.table.GetValue(row, col)
|
|
369
|
text = self._getvalue(row, col)
|
|
369
|
text = self._getvalue(row, col)
|
|
370
|
if searchtext in text.string().lower():
|
|
370
|
if searchtext in text.string().lower():
|
|
371
|
self.SetGridCursor(row, col)
|
|
371
|
self.SetGridCursor(row, col)
|
|
372
|
self.MakeCellVisible(row, col)
|
|
372
|
self.MakeCellVisible(row, col)
|
|
373
|
return
|
|
373
|
return
|
|
374
|
except IndexError:
|
|
374
|
except IndexError:
|
|
375
|
return
|
|
375
|
return
|
|
376
|
startcol = 0
|
|
376
|
startcol = 0
|
|
377
|
row += 1
|
|
377
|
row += 1
|
|
378
|
else:
|
|
378
|
else:
|
|
379
|
while True:
|
|
379
|
while True:
|
|
380
|
for col in xrange(startcol, -1, -1):
|
|
380
|
for col in xrange(startcol, -1, -1):
|
|
381
|
try:
|
|
381
|
try:
|
|
382
|
foo = self.table.GetValue(row, col)
|
|
382
|
foo = self.table.GetValue(row, col)
|
|
383
|
text = self._getvalue(row, col)
|
|
383
|
text = self._getvalue(row, col)
|
|
384
|
if searchtext in text.string().lower():
|
|
384
|
if searchtext in text.string().lower():
|
|
385
|
self.SetGridCursor(row, col)
|
|
385
|
self.SetGridCursor(row, col)
|
|
386
|
self.MakeCellVisible(row, col)
|
|
386
|
self.MakeCellVisible(row, col)
|
|
387
|
return
|
|
387
|
return
|
|
388
|
except IndexError:
|
|
388
|
except IndexError:
|
|
389
|
return
|
|
389
|
return
|
|
390
|
startcol = self.table.GetNumberCols()-1
|
|
390
|
startcol = self.table.GetNumberCols()-1
|
|
391
|
row -= 1
|
|
391
|
row -= 1
|
|
392
|
|
|
392
|
|
|
393
|
def key_pressed(self, event):
|
|
393
|
def key_pressed(self, event):
|
|
394
|
"""
|
|
394
|
"""
|
|
395
|
Maps pressed keys to functions
|
|
395
|
Maps pressed keys to functions
|
|
396
|
"""
|
|
396
|
"""
|
|
397
|
frame = self.GetParent().GetParent().GetParent()
|
|
397
|
frame = self.GetParent().GetParent().GetParent()
|
|
398
|
frame.SetStatusText("")
|
|
398
|
frame.SetStatusText("")
|
|
399
|
sh = event.ShiftDown()
|
|
399
|
sh = event.ShiftDown()
|
|
400
|
ctrl = event.ControlDown()
|
|
400
|
ctrl = event.ControlDown()
|
|
401
|
|
|
401
|
|
|
402
|
keycode = event.GetKeyCode()
|
|
402
|
keycode = event.GetKeyCode()
|
|
403
|
if keycode == ord("P"):
|
|
403
|
if keycode == ord("P"):
|
|
404
|
row = self.GetGridCursorRow()
|
|
404
|
row = self.GetGridCursorRow()
|
|
405
|
if event.ShiftDown():
|
|
405
|
if event.ShiftDown():
|
|
406
|
col = self.GetGridCursorCol()
|
|
406
|
col = self.GetGridCursorCol()
|
|
407
|
self.pickattr(row, col)
|
|
407
|
self.pickattr(row, col)
|
|
408
|
else:
|
|
408
|
else:
|
|
409
|
self.pick(row)
|
|
409
|
self.pick(row)
|
|
410
|
elif keycode == ord("M"):
|
|
410
|
elif keycode == ord("M"):
|
|
411
|
if ctrl:
|
|
411
|
if ctrl:
|
|
412
|
col = self.GetGridCursorCol()
|
|
412
|
col = self.GetGridCursorCol()
|
|
413
|
self.pickrowsattr(sorted(self.current_selection), col)
|
|
413
|
self.pickrowsattr(sorted(self.current_selection), col)
|
|
414
|
else:
|
|
414
|
else:
|
|
415
|
self.pickrows(sorted(self.current_selection))
|
|
415
|
self.pickrows(sorted(self.current_selection))
|
|
416
|
elif keycode in (wx.WXK_BACK, wx.WXK_DELETE, ord("X")) and not (ctrl or sh):
|
|
416
|
elif keycode in (wx.WXK_BACK, wx.WXK_DELETE, ord("X")) and not (ctrl or sh):
|
|
417
|
self.delete_current_notebook()
|
|
417
|
self.delete_current_notebook()
|
|
418
|
elif keycode == ord("E") and not (ctrl or sh):
|
|
418
|
elif keycode == ord("E") and not (ctrl or sh):
|
|
419
|
row = self.GetGridCursorRow()
|
|
419
|
row = self.GetGridCursorRow()
|
|
420
|
self.enter(row)
|
|
420
|
self.enter(row)
|
|
421
|
elif keycode == ord("E") and sh and not ctrl:
|
|
421
|
elif keycode == ord("E") and sh and not ctrl:
|
|
422
|
row = self.GetGridCursorRow()
|
|
422
|
row = self.GetGridCursorRow()
|
|
423
|
col = self.GetGridCursorCol()
|
|
423
|
col = self.GetGridCursorCol()
|
|
424
|
self.enterattr(row, col)
|
|
424
|
self.enterattr(row, col)
|
|
425
|
elif keycode == ord("E") and ctrl:
|
|
425
|
elif keycode == ord("E") and ctrl:
|
|
426
|
row = self.GetGridCursorRow()
|
|
426
|
row = self.GetGridCursorRow()
|
|
427
|
self.SetGridCursor(row, self.GetNumberCols()-1)
|
|
427
|
self.SetGridCursor(row, self.GetNumberCols()-1)
|
|
428
|
elif keycode == wx.WXK_HOME or (keycode == ord("A") and ctrl):
|
|
428
|
elif keycode == wx.WXK_HOME or (keycode == ord("A") and ctrl):
|
|
429
|
row = self.GetGridCursorRow()
|
|
429
|
row = self.GetGridCursorRow()
|
|
430
|
self.SetGridCursor(row, 0)
|
|
430
|
self.SetGridCursor(row, 0)
|
|
431
|
elif keycode == ord("C") and sh:
|
|
431
|
elif keycode == ord("C") and sh:
|
|
432
|
col = self.GetGridCursorCol()
|
|
432
|
col = self.GetGridCursorCol()
|
|
433
|
attr = self.table.displayattrs[col]
|
|
433
|
attr = self.table.displayattrs[col]
|
|
434
|
returnobj = []
|
|
434
|
returnobj = []
|
|
435
|
for i in xrange(self.GetNumberRows()):
|
|
435
|
for i in xrange(self.GetNumberRows()):
|
|
436
|
returnobj.append(self.table.displayattrs[col].value(self.table.items[i]))
|
|
436
|
returnobj.append(self.table.displayattrs[col].value(self.table.items[i]))
|
|
437
|
self.quit(returnobj)
|
|
437
|
self.quit(returnobj)
|
|
438
|
elif keycode in (wx.WXK_ESCAPE, ord("Q")) and not (ctrl or sh):
|
|
438
|
elif keycode in (wx.WXK_ESCAPE, ord("Q")) and not (ctrl or sh):
|
|
439
|
self.quit()
|
|
439
|
self.quit()
|
|
440
|
elif keycode == ord("<"):
|
|
440
|
elif keycode == ord("<"):
|
|
441
|
row = self.GetGridCursorRow()
|
|
441
|
row = self.GetGridCursorRow()
|
|
442
|
col = self.GetGridCursorCol()
|
|
442
|
col = self.GetGridCursorCol()
|
|
443
|
if not event.ShiftDown():
|
|
443
|
if not event.ShiftDown():
|
|
444
|
newcol = col - 1
|
|
444
|
newcol = col - 1
|
|
445
|
if newcol >= 0:
|
|
445
|
if newcol >= 0:
|
|
446
|
self.SetGridCursor(row, col - 1)
|
|
446
|
self.SetGridCursor(row, col - 1)
|
|
447
|
else:
|
|
447
|
else:
|
|
448
|
newcol = col + 1
|
|
448
|
newcol = col + 1
|
|
449
|
if newcol < self.GetNumberCols():
|
|
449
|
if newcol < self.GetNumberCols():
|
|
450
|
self.SetGridCursor(row, col + 1)
|
|
450
|
self.SetGridCursor(row, col + 1)
|
|
451
|
elif keycode == ord("D"):
|
|
451
|
elif keycode == ord("D"):
|
|
452
|
col = self.GetGridCursorCol()
|
|
452
|
col = self.GetGridCursorCol()
|
|
453
|
row = self.GetGridCursorRow()
|
|
453
|
row = self.GetGridCursorRow()
|
|
454
|
if not sh:
|
|
454
|
if not sh:
|
|
455
|
self.detail(row, col)
|
|
455
|
self.detail(row, col)
|
|
456
|
else:
|
|
456
|
else:
|
|
457
|
self.detail_attr(row, col)
|
|
457
|
self.detail_attr(row, col)
|
|
458
|
elif keycode == ord("F") and ctrl:
|
|
458
|
elif keycode == ord("F") and ctrl:
|
|
459
|
frame.enter_searchtext(event)
|
|
459
|
frame.enter_searchtext(event)
|
|
460
|
elif keycode == wx.WXK_F3:
|
|
460
|
elif keycode == wx.WXK_F3:
|
|
461
|
if sh:
|
|
461
|
if sh:
|
|
462
|
frame.find_previous(event)
|
|
462
|
frame.find_previous(event)
|
|
463
|
else:
|
|
463
|
else:
|
|
464
|
frame.find_next(event)
|
|
464
|
frame.find_next(event)
|
|
465
|
elif keycode == ord("V"):
|
|
465
|
elif keycode == ord("V"):
|
|
466
|
if sh:
|
|
466
|
if sh:
|
|
467
|
self.sortattrdesc()
|
|
467
|
self.sortattrdesc()
|
|
468
|
else:
|
|
468
|
else:
|
|
469
|
self.sortattrasc()
|
|
469
|
self.sortattrasc()
|
|
470
|
else:
|
|
470
|
else:
|
|
471
|
event.Skip()
|
|
471
|
event.Skip()
|
|
472
|
|
|
472
|
|
|
473
|
def delete_current_notebook(self):
|
|
473
|
def delete_current_notebook(self):
|
|
474
|
"""
|
|
474
|
"""
|
|
475
|
deletes the current notebook tab
|
|
475
|
deletes the current notebook tab
|
|
476
|
"""
|
|
476
|
"""
|
|
477
|
panel = self.GetParent()
|
|
477
|
panel = self.GetParent()
|
|
478
|
nb = panel.GetParent()
|
|
478
|
nb = panel.GetParent()
|
|
479
|
current = nb.GetSelection()
|
|
479
|
current = nb.GetSelection()
|
|
480
|
count = nb.GetPageCount()
|
|
480
|
count = nb.GetPageCount()
|
|
481
|
if count > 1:
|
|
481
|
if count > 1:
|
|
482
|
for i in xrange(count-1, current-1, -1):
|
|
482
|
for i in xrange(count-1, current-1, -1):
|
|
483
|
nb.DeletePage(i)
|
|
483
|
nb.DeletePage(i)
|
|
484
|
nb.GetCurrentPage().grid.SetFocus()
|
|
484
|
nb.GetCurrentPage().grid.SetFocus()
|
|
485
|
else:
|
|
485
|
else:
|
|
486
|
frame = nb.GetParent()
|
|
486
|
frame = nb.GetParent()
|
|
487
|
frame.SetStatusText("This is the last level!")
|
|
487
|
frame.SetStatusText("This is the last level!")
|
|
488
|
|
|
488
|
|
|
489
|
def _doenter(self, value, *attrs):
|
|
489
|
def _doenter(self, value, *attrs):
|
|
490
|
"""
|
|
490
|
"""
|
|
491
|
"enter" a special item resulting in a new notebook tab
|
|
491
|
"enter" a special item resulting in a new notebook tab
|
|
492
|
"""
|
|
492
|
"""
|
|
493
|
panel = self.GetParent()
|
|
493
|
panel = self.GetParent()
|
|
494
|
nb = panel.GetParent()
|
|
494
|
nb = panel.GetParent()
|
|
495
|
frame = nb.GetParent()
|
|
495
|
frame = nb.GetParent()
|
|
496
|
current = nb.GetSelection()
|
|
496
|
current = nb.GetSelection()
|
|
497
|
count = nb.GetPageCount()
|
|
497
|
count = nb.GetPageCount()
|
|
498
|
try: # if we want to enter something non-iterable, e.g. a function
|
|
498
|
try: # if we want to enter something non-iterable, e.g. a function
|
|
499
|
if current + 1 == count and value is not self.input: # we have an event in the last tab
|
|
499
|
if current + 1 == count and value is not self.input: # we have an event in the last tab
|
|
500
|
frame._add_notebook(value, *attrs)
|
|
500
|
frame._add_notebook(value, *attrs)
|
|
501
|
elif value != self.input: # we have to delete all tabs newer than [panel] first
|
|
501
|
elif value != self.input: # we have to delete all tabs newer than [panel] first
|
|
502
|
for i in xrange(count-1, current, -1): # some tabs don't close if we don't close in *reverse* order
|
|
502
|
for i in xrange(count-1, current, -1): # some tabs don't close if we don't close in *reverse* order
|
|
503
|
nb.DeletePage(i)
|
|
503
|
nb.DeletePage(i)
|
|
504
|
frame._add_notebook(value)
|
|
504
|
frame._add_notebook(value)
|
|
505
|
except TypeError, exc:
|
|
505
|
except TypeError, exc:
|
|
506
|
if exc.__class__.__module__ == "exceptions":
|
|
506
|
if exc.__class__.__module__ == "exceptions":
|
|
507
|
msg = "%s: %s" % (exc.__class__.__name__, exc)
|
|
507
|
msg = "%s: %s" % (exc.__class__.__name__, exc)
|
|
508
|
else:
|
|
508
|
else:
|
|
509
|
msg = "%s.%s: %s" % (exc.__class__.__module__, exc.__class__.__name__, exc)
|
|
509
|
msg = "%s.%s: %s" % (exc.__class__.__module__, exc.__class__.__name__, exc)
|
|
510
|
frame.SetStatusText(msg)
|
|
510
|
frame.SetStatusText(msg)
|
|
511
|
|
|
511
|
|
|
512
|
def enterattr(self, row, col):
|
|
512
|
def enterattr(self, row, col):
|
|
513
|
try:
|
|
513
|
try:
|
|
514
|
attr = self.table.displayattrs[col]
|
|
514
|
attr = self.table.displayattrs[col]
|
|
515
|
value = attr.value(self.table.items[row])
|
|
515
|
value = attr.value(self.table.items[row])
|
|
516
|
except Exception, exc:
|
|
516
|
except Exception, exc:
|
|
517
|
self.error_output(str(exc))
|
|
517
|
self.error_output(str(exc))
|
|
518
|
else:
|
|
518
|
else:
|
|
519
|
self._doenter(value)
|
|
519
|
self._doenter(value)
|
|
520
|
|
|
520
|
|
|
521
|
def enter(self, row):
|
|
521
|
def enter(self, row):
|
|
522
|
try:
|
|
522
|
try:
|
|
523
|
value = self.table.items[row]
|
|
523
|
value = self.table.items[row]
|
|
524
|
except Exception, exc:
|
|
524
|
except Exception, exc:
|
|
525
|
self.error_output(str(exc))
|
|
525
|
self.error_output(str(exc))
|
|
526
|
else:
|
|
526
|
else:
|
|
527
|
self._doenter(value)
|
|
527
|
self._doenter(value)
|
|
528
|
|
|
528
|
|
|
529
|
def detail(self, row, col):
|
|
529
|
def detail(self, row, col):
|
|
530
|
"""
|
|
530
|
"""
|
|
531
|
shows a detail-view of the current cell
|
|
531
|
shows a detail-view of the current cell
|
|
532
|
"""
|
|
532
|
"""
|
|
533
|
try:
|
|
533
|
try:
|
|
534
|
attr = self.table.displayattrs[col]
|
|
534
|
attr = self.table.displayattrs[col]
|
|
535
|
item = self.table.items[row]
|
|
535
|
item = self.table.items[row]
|
|
536
|
except Exception, exc:
|
|
536
|
except Exception, exc:
|
|
537
|
self.error_output(str(exc))
|
|
537
|
self.error_output(str(exc))
|
|
538
|
else:
|
|
538
|
else:
|
|
539
|
attrs = [ipipe.AttributeDetail(item, attr) for attr in ipipe.xattrs(item, "detail")]
|
|
539
|
attrs = [ipipe.AttributeDetail(item, attr) for attr in ipipe.xattrs(item, "detail")]
|
|
540
|
self._doenter(attrs)
|
|
540
|
self._doenter(attrs)
|
|
541
|
|
|
541
|
|
|
542
|
def detail_attr(self, row, col):
|
|
542
|
def detail_attr(self, row, col):
|
|
543
|
try:
|
|
543
|
try:
|
|
544
|
attr = self.table.displayattrs[col]
|
|
544
|
attr = self.table.displayattrs[col]
|
|
545
|
item = attr.value(self.table.items[row])
|
|
545
|
item = attr.value(self.table.items[row])
|
|
546
|
except Exception, exc:
|
|
546
|
except Exception, exc:
|
|
547
|
self.error_output(str(exc))
|
|
547
|
self.error_output(str(exc))
|
|
548
|
else:
|
|
548
|
else:
|
|
549
|
attrs = [ipipe.AttributeDetail(item, attr) for attr in ipipe.xattrs(item, "detail")]
|
|
549
|
attrs = [ipipe.AttributeDetail(item, attr) for attr in ipipe.xattrs(item, "detail")]
|
|
550
|
self._doenter(attrs)
|
|
550
|
self._doenter(attrs)
|
|
551
|
|
|
551
|
|
|
552
|
def quit(self, returnobj=None):
|
|
552
|
def quit(self, returnobj=None):
|
|
553
|
"""
|
|
553
|
"""
|
|
554
|
quit
|
|
554
|
quit
|
|
555
|
"""
|
|
555
|
"""
|
|
556
|
frame = self.GetParent().GetParent().GetParent()
|
|
556
|
frame = self.GetParent().GetParent().GetParent()
|
|
557
|
frame.parent.returnobj = returnobj
|
|
557
|
frame.parent.returnobj = returnobj
|
|
558
|
frame.Close()
|
|
558
|
frame.Close()
|
|
559
|
frame.Destroy()
|
|
559
|
frame.Destroy()
|
|
560
|
|
|
560
|
|
|
561
|
def cell_doubleclicked(self, event):
|
|
561
|
def cell_doubleclicked(self, event):
|
|
|