155
|
1 # Copyright (C) 2000-2001 The OpenRPG Project
|
|
2 #
|
|
3 # openrpg-dev@lists.sourceforge.net
|
|
4 #
|
|
5 # This program is free software; you can redistribute it and/or modify
|
|
6 # it under the terms of the GNU General Public License as published by
|
|
7 # the Free Software Foundation; either version 2 of the License, or
|
|
8 # (at your option) any later version.
|
|
9 #
|
|
10 # This program is distributed in the hope that it will be useful,
|
|
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 # GNU General Public License for more details.
|
|
14 #
|
|
15 # You should have received a copy of the GNU General Public License
|
|
16 # along with this program; if not, write to the Free Software
|
|
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
18 # --
|
|
19 #
|
|
20 # File: minilib.py
|
|
21 # Author: Ted Berg
|
|
22 # Maintainer:
|
|
23 # Version:
|
|
24 # $Id: minilib.py,v 1.28 2007/04/22 22:00:18 digitalxero Exp $
|
|
25 #
|
|
26 # Description: nodehandler for a collection of miniatures.
|
|
27 #
|
|
28
|
|
29 __version__ = "$Id: minilib.py,v 1.28 2007/04/22 22:00:18 digitalxero Exp $"
|
|
30
|
|
31 """Nodehandler for collections of miniatures. User can add, delete, edit
|
|
32 miniatures as sending them to the map singly or in batches.
|
|
33 """
|
|
34 from core import *
|
|
35 from orpg.dirpath import dir_struct
|
|
36 import string
|
|
37 import map_miniature_nodehandler
|
|
38 import orpg.mapper.map_msg
|
|
39 import orpg.minidom as minidom
|
|
40 # import scriptkit
|
|
41
|
|
42 # Constants
|
|
43 TO_MINILIB_MAP = {'path':'url', 'label':'name', 'id':None, 'action':None}
|
|
44 FROM_MINILIB_MAP = {'url':'path', 'name':'label', 'unique':None}
|
|
45 CORE_ATTRIBUTES = ['name', 'url', 'unique', 'posy', 'posx', 'hide', 'face', 'heading', 'align', 'locked', 'width', 'height']
|
|
46
|
|
47 ATTRIBUTE_NAME = 'name'
|
|
48 ATTRIBUTE_URL = 'url'
|
|
49 ATTRIBUTE_UNIQUE = 'unique'
|
|
50 ATTRIBUTE_ID = 'id'
|
|
51 ATTRIBUTE_POSX = 'posx'
|
|
52 ATTRIBUTE_POSY = 'posy'
|
|
53
|
|
54 TAG_MINIATURE = 'miniature'
|
|
55
|
|
56 COMPONENT_MAP = 'map'
|
|
57 COMPONENT_SESSION = 'session'
|
|
58 # <nodehandler name='?' module='minilib' class='minilib_handler'>
|
|
59 # <miniature name='?' url='?' unique='?'></miniature>
|
|
60 # </nodehandler>
|
|
61
|
|
62 class minilib_handler( node_handler ):
|
|
63 """A nodehandler that manages a collection of miniatures for the
|
|
64 map.
|
|
65 <pre>
|
|
66 <nodehandler name='?' module='minilib' class='minilib_handler'>
|
|
67 <miniature name='?' url='?' unique='?'></miniature>
|
|
68 </nodehandler>
|
|
69 </pre>
|
|
70 """
|
|
71 def __init__(self, xml, tree_node):
|
|
72 """Instantiates the class, and sets all vars to their default state
|
|
73 """
|
|
74 node_handler.__init__(self, xml, tree_node)
|
|
75 self.myeditor = None
|
|
76 self.mywindow = None
|
|
77 self.tree_node = tree_node
|
|
78 self.update_leaves()
|
|
79 self.sanity_check_nodes()
|
|
80
|
|
81 def get_design_panel( self, parent ):
|
|
82 """returns an instance of the miniature library edit control ( see
|
|
83 on_design ). This is for use with the the 'edit multiple nodes in a
|
|
84 single frame' code.
|
|
85 """
|
|
86 return minpedit( parent, self )
|
|
87
|
|
88 def get_use_panel( self, parent ):
|
|
89 """returns an instance of the miniature library view control ( see
|
|
90 on_use ). This is for use with the the 'view multiple nodes in a
|
|
91 single frame' code.
|
|
92 """
|
|
93 return minilib_use_panel( parent, self )
|
|
94
|
|
95 def tohtml( self ):
|
|
96 """Returns an HTML representation of this node in string format.
|
|
97 The table columnwidths are currently being forced, as the wxHTML
|
|
98 widgets being used don't handle cells wider than the widgets are
|
|
99 expecting for a given column.
|
|
100 """
|
|
101 str = '<table border="2" >'
|
|
102 str += "<tr><th width='20%'>Label</th><th>Image</th><th width='65%'>URL</th><th>Unique</th></tr>"
|
|
103 for mini in self.xml.findall(TAG_MINIATURE):
|
|
104 url = mini.get(ATTRIBUTE_URL)
|
|
105 label = mini.get(ATTRIBUTE_NAME)
|
|
106 flag = 0
|
|
107 try:
|
|
108 flag = eval( mini.get(ATTRIBUTE_UNIQUE) )
|
|
109 except:
|
|
110 pass
|
|
111 show = 'yes'
|
|
112 if flag:
|
|
113 show = 'no'
|
|
114
|
|
115 str += """<tr>
|
|
116 <td> %s </td>
|
|
117 <td><img src="%s"></td>
|
|
118 <td> %s </td>
|
|
119 <td> %s </td>
|
|
120 </tr>""" % ( label, url, url, show )
|
|
121
|
|
122 str += "</table>"
|
|
123 return str
|
|
124
|
|
125 def html_view( self ):
|
|
126 """see to_html
|
|
127 """
|
|
128 return self.tohtml()
|
|
129
|
|
130 def on_drop(self, evt):
|
|
131 drag_obj = self.tree.drag_obj
|
|
132 if drag_obj == self or self.tree.is_parent_node( self.mytree_node, drag_obj.mytree_node ):
|
|
133 return
|
|
134 elif isinstance( drag_obj, map_miniature_nodehandler.map_miniature_handler ):
|
|
135 drop_xml = self.tree.drag_obj.xml#.delete()
|
|
136 obj = drop_xml[0]
|
|
137 dict = {}
|
|
138 unique = ''
|
|
139 for attrib in obj.keys():
|
|
140 key = TO_MINILIB_MAP.get( attrib, attrib )
|
|
141 if key != None:
|
|
142 dict[ key ] = obj.get( attrib )
|
|
143 dict[ ATTRIBUTE_UNIQUE ] = unique
|
|
144 self.new_mini( dict )
|
|
145 else:
|
|
146 node_handler.on_drop(self, evt)
|
|
147
|
|
148
|
|
149 def new_mini( self, data={}, add=1 ):
|
|
150 mini = Element( TAG_MINIATURE )
|
|
151 for key in data.keys():
|
|
152 mini.set( key, data[ key ] )
|
|
153 for key in CORE_ATTRIBUTES:
|
|
154 if mini.get( key ) == '':
|
|
155 mini.set( key, '0' )
|
|
156 if add:
|
|
157 self.add_mini( mini )
|
|
158 self.add_leaf( mini )
|
|
159 return mini
|
|
160
|
|
161 def add_mini( self, mini ):
|
|
162 self.xml.append( mini )
|
|
163
|
|
164 def add_leaf( self, mini, icon='gear' ):
|
|
165 tree = self.tree
|
|
166 icons = tree.icons
|
|
167 key = mini.get( ATTRIBUTE_NAME )
|
|
168 self.mydata.append( mini )
|
|
169
|
|
170 def update_leaves( self ):
|
|
171 self.mydata = []
|
|
172 for n in self.xml.findall(TAG_MINIATURE):
|
|
173 self.add_leaf( n )
|
|
174
|
|
175 def on_drag( self, evt ):
|
|
176 print 'drag event caught'
|
|
177
|
|
178 def send_mini_to_map( self, mini, count=1, addName=True ):
|
|
179 if mini == None:
|
|
180 return
|
|
181 if mini.get( ATTRIBUTE_URL ) == '' or mini.get( ATTRIBUTE_URL ) == 'http://':
|
|
182 self.chat.ParsePost( self.chat.colorize(self.chat.syscolor, '"%s" is not a valid URL, the mini "%s" will not be added to the map' % ( mini.get( ATTRIBUTE_URL ), mini.get( ATTRIBUTE_NAME ) )) )
|
|
183 return
|
|
184 session = component.get( COMPONENT_SESSION )
|
|
185 if (session.my_role() != session.ROLE_GM) and (session.my_role() != session.ROLE_PLAYER):
|
|
186 component.get("chat").InfoPost("You must be either a player or GM to use the miniature Layer")
|
|
187 return
|
|
188 map = component.get(COMPONENT_MAP)
|
|
189 for loop in range( count ):
|
|
190 msg = self.get_miniature_XML( mini, addName)
|
|
191 msg = str("<map action='update'><miniatures>" + msg + "</miniatures></map>")
|
|
192 map.new_data( msg )
|
|
193 session.send( msg )
|
|
194
|
|
195 def get_miniature_XML( self, mini_xml, addName = True ):
|
|
196 msg = orpg.mapper.map_msg.mini_msg()
|
|
197 map = component.get( COMPONENT_MAP )
|
|
198 session = component.get( COMPONENT_SESSION )
|
|
199 msg.init_prop( ATTRIBUTE_ID, session.get_next_id() )
|
|
200 msg.init_prop('selected', '1')# this will make the mini initially selected
|
|
201 for k in mini_xml.keys():
|
|
202 # translate our attributes to map attributes
|
|
203 key = FROM_MINILIB_MAP.get( k, k )
|
|
204 if key != None:
|
|
205 if not addName and k == 'name':
|
|
206 pass
|
|
207 else:
|
|
208 msg.init_prop( key, mini_xml.get( k ) )
|
|
209 unique = self.is_unique( mini_xml )
|
|
210 if addName:
|
|
211 label = mini_xml.get( ATTRIBUTE_NAME )
|
|
212 else:
|
|
213 label = ''
|
|
214 return msg.get_all_xml()
|
|
215
|
|
216 def is_unique( self, mini ):
|
|
217 unique = mini.get( ATTRIBUTE_UNIQUE )
|
|
218 val = 0
|
|
219 try: val = eval( unique )
|
|
220 except: val = len( unique )
|
|
221 return val
|
|
222
|
|
223 def sanity_check_nodes( self ):
|
|
224 for node in self.xml.findall(TAG_MINIATURE):
|
|
225 if node.get( ATTRIBUTE_POSX ) == '': node.set( ATTRIBUTE_POSX, '0' )
|
|
226 if node.get( ATTRIBUTE_POSY ) == '': node.set( ATTRIBUTE_POSY, '0' )
|
|
227
|
|
228 def get_mini( self, index ):
|
|
229 try: return self.xml.findall(TAG_MINIATURE)[index]
|
|
230 except: return None
|
|
231
|
|
232 class mini_handler( node_handler ):
|
|
233 def __init__( self, xml, tree_node, handler ):
|
|
234 node_handler.__init__( self, xml, tree_node)
|
|
235 self.handler = handler
|
|
236
|
|
237 def on_ldclick( self, evt ):
|
|
238 self.handler.send_mini_to_map( self.xml )
|
|
239
|
|
240 def on_drop( self, evt ):
|
|
241 pass
|
|
242
|
|
243 def on_lclick( self, evt ):
|
|
244 print 'hi'
|
|
245 evt.Skip()
|
|
246
|
|
247 class minilib_use_panel(wx.Panel):
|
|
248 """This panel will be displayed when the user double clicks on the
|
|
249 miniature library node. It is a sorted listbox of miniature labels,
|
|
250 a text field for entering a count ( for batch adds ) and 'add'/'done'
|
|
251 buttons.
|
|
252 """
|
|
253 def __init__( self, frame, handler ):
|
|
254 """Constructor.
|
|
255 """
|
|
256 wx.Panel.__init__( self, frame, -1 )
|
|
257 self.handler = handler
|
|
258 self.frame = frame
|
|
259
|
|
260 self.map = component.get('map')
|
|
261 names = self.buildList()
|
|
262 # self.keys = self.list.keys()
|
|
263 # self.keys.sort()
|
|
264
|
|
265
|
|
266 s = self.GetClientSizeTuple()
|
|
267
|
|
268 self.sizer = wx.BoxSizer(wx.VERTICAL)
|
|
269 box = wx.BoxSizer(wx.HORIZONTAL)
|
|
270 self.listbox = wx.ListBox(self, wx.ID_ANY, (10, 10), (s[0] - 10, s[1] - 30 ), names, wx.LB_EXTENDED)
|
|
271 self.count = wx.TextCtrl(self, wx.ID_ANY, '1')
|
|
272
|
|
273 box.Add( wx.StaticText( self, -1, 'Minis to add' ), 0, wx.EXPAND )
|
|
274 box.Add(wx.Size(10,10))
|
|
275 box.Add(self.count, 1, wx.EXPAND)
|
|
276
|
|
277 self.sizer.Add( self.listbox, 1, wx.EXPAND )
|
|
278 self.sizer.Add( box, 0, wx.EXPAND )
|
|
279
|
|
280 box = wx.BoxSizer( wx.HORIZONTAL )
|
|
281 self.okBtn = wx.Button(self, wx.ID_ANY, 'Add')
|
|
282 box.Add(self.okBtn, 0, wx.EXPAND)
|
|
283 self.addBtn = wx.Button(self, wx.ID_ANY, 'Add No Label')
|
|
284 box.Add(self.addBtn, 0, wx.EXPAND)
|
|
285 self.cancleBtn = wx.Button(self, wx.ID_ANY, 'Done')
|
|
286 box.Add(self.cancleBtn, 0, wx.EXPAND)
|
|
287
|
|
288 self.sizer.Add(wx.Size(10,10))
|
|
289 self.sizer.Add(box, 0, wx.EXPAND)
|
|
290 self.Bind(wx.EVT_BUTTON, self.on_ok, self.okBtn)
|
|
291 self.Bind(wx.EVT_BUTTON, self.on_ok, self.addBtn)
|
|
292 self.Bind(wx.EVT_BUTTON, self.on_close, self.cancleBtn)
|
|
293 self.SetSizer(self.sizer)
|
|
294 self.SetAutoLayout(True)
|
|
295 self.Fit()
|
|
296
|
|
297 def buildList( self ):
|
|
298 """Returns a dictionary of label => game tree miniature DOM node mappings.
|
|
299 """
|
|
300 self.list = []
|
|
301 for mini in self.handler.xml.findall(TAG_MINIATURE):
|
|
302 self.list.append( mini.get( ATTRIBUTE_NAME ) )
|
|
303 return self.list
|
|
304
|
|
305 def on_close(self, evt):
|
|
306 self.frame.Close()
|
|
307
|
|
308 def on_ok( self, evt ):
|
|
309 """Event handler for the 'add' button.
|
|
310 """
|
|
311 btn = self.FindWindowById(evt.GetId())
|
|
312 sendName = True
|
|
313 try:
|
|
314 count = eval( self.count.GetValue() )
|
|
315 except:
|
|
316 count = 1
|
|
317
|
|
318 try:
|
|
319 if eval( unique ):
|
|
320 count = 1
|
|
321 unique = eval( unique )
|
|
322 except:
|
|
323 pass
|
|
324
|
|
325 if btn.GetLabel() == 'Add No Label':
|
|
326 sendName = False
|
|
327 for index in self.listbox.GetSelections():
|
|
328 self.handler.send_mini_to_map( self.handler.get_mini( index ), count, sendName )
|
|
329
|
|
330
|
|
331 class minpedit(wx.Panel):
|
|
332 """Panel for editing game tree miniature nodes. Node information
|
|
333 is displayed in a grid, and buttons are provided for adding, deleting
|
|
334 nodes, and for sending minis to the map ( singly and in batches ).
|
|
335 """
|
|
336 def __init__( self, frame, handler ):
|
|
337 """Constructor.
|
|
338 """
|
|
339 wx.Panel.__init__( self, frame, -1 )
|
|
340 self.handler = handler
|
|
341 self.frame = frame
|
|
342
|
|
343 self.sizer = wx.BoxSizer( wx.VERTICAL )
|
|
344 self.grid = minilib_grid( self, handler )
|
|
345
|
|
346 bbox = wx.BoxSizer( wx.HORIZONTAL )
|
|
347 newMiniBtn = wx.Button( self, wx.ID_ANY, "New mini" )
|
|
348 delMiniBtn = wx.Button( self, wx.ID_ANY, "Del mini" )
|
|
349 addMiniBtn = wx.Button( self, wx.ID_ANY, "Add 1" )
|
|
350 addBatchBtn = wx.Button( self, wx.ID_ANY, "Add Batch" )
|
|
351 bbox.Add(newMiniBtn, 0, wx.EXPAND )
|
|
352 bbox.Add(delMiniBtn, 0, wx.EXPAND )
|
|
353 bbox.Add(wx.Size(10,10))
|
|
354 bbox.Add(addMiniBtn, 0, wx.EXPAND )
|
|
355 bbox.Add(addBatchBtn, 0, wx.EXPAND )
|
|
356
|
|
357 self.sizer.Add( self.grid, 1, wx.EXPAND)
|
|
358 self.sizer.Add( bbox, 0)
|
|
359 self.SetSizer(self.sizer)
|
|
360 self.SetAutoLayout(True)
|
|
361 self.Fit()
|
|
362
|
|
363 self.Bind(wx.EVT_BUTTON, self.add_mini, newMiniBtn)
|
|
364 self.Bind(wx.EVT_BUTTON, self.del_mini, delMiniBtn)
|
|
365 self.Bind(wx.EVT_BUTTON, self.send_to_map, addMiniBtn)
|
|
366 self.Bind(wx.EVT_BUTTON, self.send_group_to_map, addBatchBtn)
|
|
367
|
|
368 def add_mini( self, evt=None ):
|
|
369 """Event handler for the 'New mini' button. It calls
|
|
370 minilib_grid.add_row
|
|
371 """
|
|
372 self.grid.add_row()
|
|
373
|
|
374 def del_mini( self, evt=None ):
|
|
375 """Event handler for the 'Del mini' button. It calls
|
|
376 minilib_grid.del_row
|
|
377 """
|
|
378 self.grid.del_row()
|
|
379
|
|
380 def send_to_map( self, evt=None ):
|
|
381 """Event handler for the 'Add 1' button. Sends the
|
|
382 miniature defined by the currently selected row to the map, once.
|
|
383 """
|
|
384 index = self.grid.GetGridCursorRow()
|
|
385 self.handler.send_mini_to_map( self.handler.get_mini( index ) )
|
|
386
|
|
387 def send_group_to_map( self, evt=None ):
|
|
388 """Event handler for the 'Add batch' button. Querys the user
|
|
389 for a mini count and sends the miniature defined by the currently
|
|
390 selected row to the map, the specified number of times.
|
|
391 """
|
|
392 if self.grid.GetNumberRows() > 0:
|
|
393 dlg = wx.TextEntryDialog( self.frame,
|
|
394 'How many %s\'s do you want to add?' %
|
|
395 ( self.grid.getSelectedLabel() ), 'Batch mini add', '2' )
|
|
396 if dlg.ShowModal() == wx.ID_OK:
|
|
397 try:
|
|
398 value = eval( dlg.GetValue() )
|
|
399 except:
|
|
400 value = 0
|
|
401 # for loop in range( 0, value ):
|
|
402 # self.send_to_map()
|
|
403 print 'getting selected index for batch send'
|
|
404 index = self.grid.GetGridCursorRow()
|
|
405 print 'sending batch to map'
|
|
406 self.handler.send_mini_to_map( self.handler.get_mini( index ), value )
|
|
407
|
|
408 class minilib_grid(wx.grid.Grid):
|
|
409 """A wxGrid subclass designed for editing game tree miniature library
|
|
410 nodes.
|
|
411 """
|
|
412 def __init__( self, parent, handler ):
|
|
413 """Constructor.
|
|
414 """
|
|
415 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS )
|
|
416 self.parent = parent
|
|
417 self.handler = handler
|
|
418 #self.keys = [ ATTRIBUTE_NAME, ATTRIBUTE_URL, ATTRIBUTE_UNIQUE ]
|
|
419 self.keys = CORE_ATTRIBUTES
|
|
420 self.CreateGrid( 1, len( self.keys ) )
|
|
421 # self.SetColLabelValue( 0, 'Name' )
|
|
422 # self.SetColLabelValue( 1, 'URL' )
|
|
423 # self.SetColSize( 1, 250 )
|
|
424 # self.SetColLabelValue( 2, 'Unique' )
|
|
425 for key in self.keys:
|
|
426 self.SetColLabelValue( self.keys.index( key ), key )
|
|
427 self.update_all()
|
|
428 self.selectedRow = 0
|
|
429 self.AutoSizeColumns()
|
|
430 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
|
|
431 self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.select_cell)
|
|
432
|
|
433 def update_cols( self ):
|
|
434 for n in self.handler.xml.findall(TAG_MINIATURE):
|
|
435 for k in n.keys():
|
|
436 if k not in self.keys:
|
|
437 self.keys.append( k )
|
|
438
|
|
439 def select_cell( self, evt ):
|
|
440 """Event handler for grid cell selection changes. It stores the
|
|
441 last selected row in a variable for use by the add[*] and del_row
|
|
442 operations.
|
|
443 """
|
|
444 self.BeginBatch()
|
|
445 self.selectedRow = evt.GetRow()
|
|
446 self.SelectRow( self.selectedRow )
|
|
447 self.EndBatch()
|
|
448 evt.Skip()
|
|
449
|
|
450 def getList( self ):
|
|
451 """Returns the list of 'miniature' DOM elements associated with this
|
|
452 miniature library.
|
|
453 """
|
|
454 return self.handler.xml.findall( TAG_MINIATURE )
|
|
455
|
|
456 def add_row( self, count = 1 ):
|
|
457 """creates a new miniature node, and then adds it to the current
|
|
458 miniature library, and to the grid.
|
|
459 """
|
|
460 self.AppendRows( count )
|
|
461 node = self.handler.new_mini( {
|
|
462 ATTRIBUTE_NAME :' ',
|
|
463 ATTRIBUTE_URL :'http://'} )# minidom.Element( TAG_MINIATURE )
|
|
464 self.update_all()
|
|
465 #self.handler.xml.append( node )
|
|
466
|
|
467 def del_row( self ):
|
|
468 """deletes the miniature associated with the currently selected
|
|
469 row. BUG BUG BUG this method should drop a child from the DOM but
|
|
470 does not.
|
|
471 """
|
|
472 if self.selectedRow > -1:
|
|
473 pos = self.selectedRow
|
|
474 list = self.handler.xml.findall(TAG_MINIATURE)
|
|
475 self.handler.xml.remove( list[pos] )
|
|
476 self.DeleteRows( pos, 1 )
|
|
477 list = self.getList()
|
|
478 del list[ pos ]
|
|
479
|
|
480 def on_cell_change( self, evt ):
|
|
481 """Event handler for cell selection changes. selected row is used
|
|
482 to update data for that row.
|
|
483 """
|
|
484 row = evt.GetRow()
|
|
485 self.update_data_row( row )
|
|
486
|
|
487 def update_all( self ):
|
|
488 """ensures that the grid is displaying the correct number of
|
|
489 rows, and then updates all data displayed by the grid
|
|
490 """
|
|
491 list = self.getList()
|
|
492 count = 0
|
|
493 for n in list:
|
|
494 for k in n.keys():
|
|
495 if k not in self.keys:
|
|
496 self.keys.append( k )
|
|
497 count = len( self.keys )
|
|
498 if self.GetNumberCols() < count:
|
|
499 self.AppendCols( count - self.GetNumberCols() )
|
|
500 for k in self.keys:
|
|
501 self.SetColLabelValue( self.keys.index( k ), k )
|
|
502 count = len( list )
|
|
503 rowcount = self.GetNumberRows()
|
|
504 if ( count > rowcount ):
|
|
505 total = count - rowcount
|
|
506 self.AppendRows( total )
|
|
507 elif ( count < rowcount ):
|
|
508 total = rowcount - count
|
|
509 self.DeleteRows( 0, total );
|
|
510 for index in range( 0, count ):
|
|
511 self.update_grid_row( index )
|
|
512
|
|
513 def getSelectedLabel( self ):
|
|
514 """Returns the label for the selected row
|
|
515 """
|
|
516 return self.GetTable().GetValue( self.selectedRow, 0 )
|
|
517
|
|
518 def getSelectedURL( self ):
|
|
519 """Returns the URL for the selected row
|
|
520 """
|
|
521 return self.GetTable().GetValue( self.selectedRow, 1 )
|
|
522
|
|
523 def getSelectedSerial( self ):
|
|
524 """Returns the ATTRIBUTE_UNIQUE value for the selected row
|
|
525 """
|
|
526 return self.GetTable().GetValue( self.selectedRow, 2 )
|
|
527
|
|
528 def update_grid_row( self, row ):
|
|
529 """Updates the specified grid row with data from the DOM node
|
|
530 specified by 'row'
|
|
531 """
|
|
532 list = self.getList()
|
|
533 item = list[ row ]
|
|
534 for key in self.keys:
|
|
535 self.GetTable().SetValue( row, self.keys.index( key ), item.get( key ) )
|
|
536
|
|
537 def update_data_row( self, row ):
|
|
538 """Updates the DOM nodw 'row' with grid data from 'row'
|
|
539 """
|
|
540 list = self.getList()
|
|
541 item = list[ row ]
|
|
542 for key in self.keys:
|
|
543 item.set( key, string.strip( self.GetTable().GetValue( row, self.keys.index( key ) ) ) )
|