Mercurial > traipse_dev
comparison orpg/gametree/nodehandlers/rpg_grid.py @ 76:37a11fea3304 ornery-dev
More clean up. Images now posts a Chat Info post if image doesn't load.
author | sirebral |
---|---|
date | Sat, 22 Aug 2009 04:02:14 -0500 |
parents | 449a8900f9ac |
children | eb1b275699c4 |
comparison
equal
deleted
inserted
replaced
75:f518bc709fd1 | 76:37a11fea3304 |
---|---|
28 | 28 |
29 __version__ = "$Id: rpg_grid.py,v 1.20 2006/11/15 12:11:24 digitalxero Exp $" | 29 __version__ = "$Id: rpg_grid.py,v 1.20 2006/11/15 12:11:24 digitalxero Exp $" |
30 | 30 |
31 from core import * | 31 from core import * |
32 from forms import * | 32 from forms import * |
33 from orpg.minidom import Element, Text | |
33 | 34 |
34 class rpg_grid_handler(node_handler): | 35 class rpg_grid_handler(node_handler): |
35 """ Node handler for rpg grid tool | 36 """ Node handler for rpg grid tool |
36 <nodehandler module='rpg_grid' class='rpg_grid_handler' name='sample'> | 37 <nodehandler module='rpg_grid' class='rpg_grid_handler' name='sample'> |
37 <grid border='' autosize='1' > | 38 <grid border='' autosize='1' > |
194 PaintBackground and do something meaningful there. | 195 PaintBackground and do something meaningful there. |
195 """ | 196 """ |
196 self._tc.SetDimensions(rect.x+1, rect.y+1, rect.width+2, rect.height+2) | 197 self._tc.SetDimensions(rect.x+1, rect.y+1, rect.width+2, rect.height+2) |
197 | 198 |
198 | 199 |
199 def Show(self, show, attr): | 200 #def Show(self, show, attr): #deprecated DeprecationWarning: Please use PyGridCellEditor.Show instead. |
200 """ | 201 # """ |
201 Show or hide the edit control. You can use the attr (if not None) | 202 # Show or hide the edit control. You can use the attr (if not None) |
202 to set colours or fonts for the control. | 203 # to set colours or fonts for the control. |
203 """ | 204 # """ |
204 self.base_Show(show, attr) #deprecated DeprecationWarning: Please use PyGridCellEditor.Show instead. | 205 # self.base_Show(show, attr) # Removed to prevent recursive error type. |
205 | 206 |
206 | 207 |
207 def BeginEdit(self, row, col, grid): | 208 def BeginEdit(self, row, col, grid): |
208 """ | 209 """ |
209 Fetch the value from the table and prepare the edit control | 210 Fetch the value from the table and prepare the edit control |
279 if ch is not None: | 280 if ch is not None: |
280 # For this example, replace the text. Normally we would append it. | 281 # For this example, replace the text. Normally we would append it. |
281 self._tc.AppendText(ch) | 282 self._tc.AppendText(ch) |
282 else: | 283 else: |
283 evt.Skip() | 284 evt.Skip() |
284 | |
285 | 285 |
286 | 286 |
287 def Destroy(self): | 287 def Destroy(self): |
288 """final cleanup""" | 288 """final cleanup""" |
289 self.base_Destroy() | 289 self.base_Destroy() |
339 row = evt.GetRow() | 339 row = evt.GetRow() |
340 col = evt.GetCol() | 340 col = evt.GetCol() |
341 value = self.GetCellValue(row,col) | 341 value = self.GetCellValue(row,col) |
342 cells = self.rows[row].getElementsByTagName('cell') | 342 cells = self.rows[row].getElementsByTagName('cell') |
343 t_node = cells[col]._get_firstChild() | 343 t_node = cells[col]._get_firstChild() |
344 print t_node | |
345 t_node._set_nodeValue(value) | 344 t_node._set_nodeValue(value) |
346 if col == 0: | 345 if col == 0: |
347 self.handler.refresh_rows() | 346 self.handler.refresh_rows() |
348 | 347 |
349 def set_col_widths(self): | 348 def set_col_widths(self): |
360 for i in range(0,len(cells)): | 359 for i in range(0,len(cells)): |
361 t_node = cells[i]._get_firstChild() | 360 t_node = cells[i]._get_firstChild() |
362 if t_node == None: | 361 if t_node == None: |
363 #doc = cells[i].ownerDocument | 362 #doc = cells[i].ownerDocument |
364 #t_node = doc.createTextNode("") | 363 #t_node = doc.createTextNode("") |
365 t_node = minidom.Text("") | 364 t_node = Text("") |
366 t_node = cells[i].appendChild(t_node) | 365 t_node = cells[i].appendChild(t_node) |
367 self.SetCellValue(rowi,i,t_node._get_nodeValue()) | 366 self.SetCellValue(rowi,i,t_node._get_nodeValue()) |
368 | 367 |
369 def add_row(self,evt=None): | 368 def add_row(self,evt=None): |
370 cols = self.GetNumberCols() | 369 cols = self.GetNumberCols() |
371 #doc = self.handler.grid.ownerDocument | 370 #doc = self.handler.grid.ownerDocument |
372 #row = doc.createElement('row') | 371 #row = doc.createElement('row') |
373 row = minidom.Element('row') | 372 row = Element('row') |
374 for i in range(0,cols): | 373 for i in range(0,cols): |
375 #cell = doc.createElement('cell') | 374 #cell = doc.createElement('cell') |
376 cell = minidom.Element('cell') | 375 cell = Element('cell') |
377 #t_node = doc.createTextNode("") | 376 #t_node = doc.createTextNode("") |
378 t_node = minidom.Text("") | 377 t_node = Text("") |
379 t_node = cell.appendChild(t_node) | 378 t_node = cell.appendChild(t_node) |
380 row.appendChild(cell) | 379 row.appendChild(cell) |
381 self.handler.grid.appendChild(row) | 380 self.handler.grid.appendChild(row) |
382 self.AppendRows(1) | 381 self.AppendRows(1) |
383 self.rows = self.handler.grid.getElementsByTagName('row') | 382 self.rows = self.handler.grid.getElementsByTagName('row') |
385 | 384 |
386 def add_col(self,evt=None): | 385 def add_col(self,evt=None): |
387 #doc = self.handler.grid.ownerDocument | 386 #doc = self.handler.grid.ownerDocument |
388 for r in self.rows: | 387 for r in self.rows: |
389 #cell = doc.createElement('cell') | 388 #cell = doc.createElement('cell') |
390 cell = minidom.Element('cell') | 389 cell = Element('cell') |
391 #t_node = doc.createTextNode("") | 390 #t_node = doc.createTextNode("") |
392 t_node = minidom.Text("") | 391 t_node = Text("") |
393 t_node = cell.appendChild(t_node) | 392 t_node = cell.appendChild(t_node) |
394 r.appendChild(cell) | 393 r.appendChild(cell) |
395 self.AppendCols(1) | 394 self.AppendCols(1) |
396 self.fit_cols() | 395 self.fit_cols() |
397 | 396 |