156
|
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:
|
184
|
24 # $Id: minilib.py,v Traipse 'Ornery-Orc' prof.ebral Exp $
|
156
|
25 #
|
|
26 # Description: nodehandler for a collection of miniatures.
|
|
27 #
|
|
28
|
184
|
29 __version__ = "$Id: minilib.py,v Traipse 'Ornery-Orc' prof.ebral Exp $"
|
156
|
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: flag = eval( mini.get(ATTRIBUTE_UNIQUE) )
|
|
108 except: pass
|
|
109 show = 'yes'
|
|
110 if flag: show = 'no'
|
|
111 str += """<tr>
|
|
112 <td> %s </td>
|
|
113 <td><img src="%s"></td>
|
|
114 <td> %s </td>
|
|
115 <td> %s </td>
|
|
116 </tr>""" % ( label, url, url, show )
|
|
117 str += "</table>"
|
|
118 return str
|
|
119
|
|
120 def html_view( self ):
|
|
121 """see to_html
|
|
122 """
|
|
123 return self.tohtml()
|
|
124
|
|
125 def on_drop(self, evt):
|
|
126 drag_obj = self.tree.drag_obj
|
|
127 if drag_obj == self or self.tree.is_parent_node( self.mytree_node, drag_obj.mytree_node ): return
|
|
128 elif isinstance( drag_obj, map_miniature_nodehandler.map_miniature_handler ):
|
|
129 drop_xml = self.tree.drag_obj.xml#.delete()
|
|
130 obj = drop_xml[0]
|
|
131 dict = {}
|
|
132 unique = ''
|
|
133 for attrib in obj.keys():
|
|
134 key = TO_MINILIB_MAP.get( attrib, attrib )
|
|
135 if key != None: dict[ key ] = obj.get( attrib )
|
|
136 dict[ ATTRIBUTE_UNIQUE ] = unique
|
|
137 self.new_mini( dict )
|
|
138 else: node_handler.on_drop(self, evt)
|
|
139
|
|
140
|
|
141 def new_mini( self, data={}, add=1 ):
|
|
142 mini = Element( TAG_MINIATURE )
|
|
143 for key in data.keys(): mini.set( key, data[ key ] )
|
|
144 for key in CORE_ATTRIBUTES:
|
216
|
145 if mini.get( key ) == ('' or None): mini.set( key, '0' )
|
156
|
146 if add:
|
|
147 self.add_mini( mini )
|
|
148 self.add_leaf( mini )
|
|
149 return mini
|
|
150
|
|
151 def add_mini( self, mini ):
|
|
152 self.xml.append( mini )
|
|
153
|
|
154 def add_leaf( self, mini, icon='gear' ):
|
|
155 tree = self.tree
|
|
156 icons = tree.icons
|
|
157 key = mini.get( ATTRIBUTE_NAME )
|
|
158 self.mydata.append( mini )
|
|
159
|
|
160 def update_leaves( self ):
|
|
161 self.mydata = []
|
|
162 for n in self.xml.findall(TAG_MINIATURE): self.add_leaf( n )
|
|
163
|
|
164 def on_drag( self, evt ):
|
|
165 print 'drag event caught'
|
|
166
|
|
167 def send_mini_to_map( self, mini, count=1, addName=True ):
|
|
168 if mini == None: return
|
|
169 if mini.get( ATTRIBUTE_URL ) == '' or mini.get( ATTRIBUTE_URL ) == 'http://':
|
|
170 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 ) )) )
|
|
171 return
|
|
172 session = component.get( COMPONENT_SESSION )
|
|
173 if (session.my_role() != session.ROLE_GM) and (session.my_role() != session.ROLE_PLAYER):
|
|
174 component.get("chat").InfoPost("You must be either a player or GM to use the miniature Layer")
|
|
175 return
|
|
176 map = component.get(COMPONENT_MAP)
|
|
177 for loop in range( count ):
|
|
178 msg = self.get_miniature_XML( mini, addName)
|
|
179 msg = str("<map action='update'><miniatures>" + msg + "</miniatures></map>")
|
|
180 map.new_data( msg )
|
|
181 session.send( msg )
|
|
182
|
|
183 def get_miniature_XML( self, mini_xml, addName = True ):
|
|
184 msg = orpg.mapper.map_msg.mini_msg()
|
|
185 map = component.get( COMPONENT_MAP )
|
|
186 session = component.get( COMPONENT_SESSION )
|
|
187 msg.init_prop( ATTRIBUTE_ID, session.get_next_id() )
|
|
188 msg.init_prop('selected', '1')# this will make the mini initially selected
|
|
189 for k in mini_xml.keys():
|
|
190 # translate our attributes to map attributes
|
|
191 key = FROM_MINILIB_MAP.get( k, k )
|
|
192 if key != None:
|
|
193 if not addName and k == 'name': pass
|
|
194 else: msg.init_prop( key, mini_xml.get( k ) )
|
|
195 unique = self.is_unique( mini_xml )
|
|
196 if addName: label = mini_xml.get( ATTRIBUTE_NAME )
|
|
197 else: label = ''
|
|
198 return msg.get_all_xml()
|
|
199
|
|
200 def is_unique( self, mini ):
|
|
201 unique = mini.get( ATTRIBUTE_UNIQUE )
|
|
202 val = 0
|
|
203 try: val = eval( unique )
|
|
204 except: val = len( unique )
|
|
205 return val
|
|
206
|
|
207 def sanity_check_nodes( self ):
|
|
208 for node in self.xml.findall(TAG_MINIATURE):
|
|
209 if node.get( ATTRIBUTE_POSX ) == '': node.set( ATTRIBUTE_POSX, '0' )
|
|
210 if node.get( ATTRIBUTE_POSY ) == '': node.set( ATTRIBUTE_POSY, '0' )
|
|
211
|
|
212 def get_mini( self, index ):
|
|
213 try: return self.xml.findall(TAG_MINIATURE)[index]
|
|
214 except: return None
|
|
215
|
|
216 class mini_handler( node_handler ):
|
|
217 def __init__( self, xml, tree_node, handler ):
|
|
218 node_handler.__init__( self, xml, tree_node)
|
|
219 self.handler = handler
|
|
220
|
|
221 def on_ldclick( self, evt ):
|
|
222 self.handler.send_mini_to_map( self.xml )
|
|
223
|
|
224 def on_drop( self, evt ):
|
|
225 pass
|
|
226
|
|
227 def on_lclick( self, evt ):
|
|
228 print 'hi'
|
|
229 evt.Skip()
|
|
230
|
|
231 class minilib_use_panel(wx.Panel):
|
|
232 """This panel will be displayed when the user double clicks on the
|
|
233 miniature library node. It is a sorted listbox of miniature labels,
|
|
234 a text field for entering a count ( for batch adds ) and 'add'/'done'
|
|
235 buttons.
|
|
236 """
|
|
237 def __init__( self, frame, handler ):
|
|
238 """Constructor.
|
|
239 """
|
|
240 wx.Panel.__init__( self, frame, -1 )
|
|
241 self.handler = handler
|
|
242 self.frame = frame
|
|
243
|
|
244 self.map = component.get('map')
|
|
245 names = self.buildList()
|
|
246
|
|
247 s = self.GetClientSizeTuple()
|
|
248
|
|
249 self.sizer = wx.BoxSizer(wx.VERTICAL)
|
|
250 box = wx.BoxSizer(wx.HORIZONTAL)
|
|
251 self.listbox = wx.ListBox(self, wx.ID_ANY, (10, 10), (s[0] - 10, s[1] - 30 ), names, wx.LB_EXTENDED)
|
|
252 self.count = wx.TextCtrl(self, wx.ID_ANY, '1')
|
|
253
|
|
254 box.Add( wx.StaticText( self, -1, 'Minis to add' ), 0, wx.EXPAND )
|
|
255 box.Add(wx.Size(10,10))
|
|
256 box.Add(self.count, 1, wx.EXPAND)
|
|
257
|
|
258 self.sizer.Add( self.listbox, 1, wx.EXPAND )
|
|
259 self.sizer.Add( box, 0, wx.EXPAND )
|
|
260
|
|
261 box = wx.BoxSizer( wx.HORIZONTAL )
|
|
262 self.okBtn = wx.Button(self, wx.ID_ANY, 'Add')
|
|
263 box.Add(self.okBtn, 0, wx.EXPAND)
|
|
264 self.addBtn = wx.Button(self, wx.ID_ANY, 'Add No Label')
|
|
265 box.Add(self.addBtn, 0, wx.EXPAND)
|
|
266 self.cancleBtn = wx.Button(self, wx.ID_ANY, 'Done')
|
|
267 box.Add(self.cancleBtn, 0, wx.EXPAND)
|
|
268
|
|
269 self.sizer.Add(wx.Size(10,10))
|
|
270 self.sizer.Add(box, 0, wx.EXPAND)
|
|
271 self.Bind(wx.EVT_BUTTON, self.on_ok, self.okBtn)
|
|
272 self.Bind(wx.EVT_BUTTON, self.on_ok, self.addBtn)
|
|
273 self.Bind(wx.EVT_BUTTON, self.on_close, self.cancleBtn)
|
|
274 self.SetSizer(self.sizer)
|
|
275 self.SetAutoLayout(True)
|
|
276 self.Fit()
|
|
277
|
|
278 def buildList( self ):
|
|
279 """Returns a dictionary of label => game tree miniature DOM node mappings.
|
|
280 """
|
|
281 self.list = []
|
|
282 for mini in self.handler.xml.findall(TAG_MINIATURE): self.list.append( mini.get( ATTRIBUTE_NAME ) )
|
|
283 return self.list
|
|
284
|
|
285 def on_close(self, evt):
|
|
286 self.frame.Close()
|
|
287
|
|
288 def on_ok( self, evt ):
|
|
289 """Event handler for the 'add' button.
|
|
290 """
|
|
291 btn = self.FindWindowById(evt.GetId())
|
|
292 sendName = True
|
|
293 try: count = eval( self.count.GetValue() )
|
|
294 except: count = 1
|
|
295 try:
|
|
296 if eval( unique ): count = 1
|
|
297 unique = eval( unique )
|
|
298 except: pass
|
|
299
|
|
300 if btn.GetLabel() == 'Add No Label': sendName = False
|
|
301 for index in self.listbox.GetSelections(): self.handler.send_mini_to_map( self.handler.get_mini( index ), count, sendName )
|
|
302
|
|
303
|
|
304 class minpedit(wx.Panel):
|
|
305 """Panel for editing game tree miniature nodes. Node information
|
|
306 is displayed in a grid, and buttons are provided for adding, deleting
|
|
307 nodes, and for sending minis to the map ( singly and in batches ).
|
|
308 """
|
|
309 def __init__( self, frame, handler ):
|
|
310 """Constructor.
|
|
311 """
|
|
312 wx.Panel.__init__( self, frame, -1 )
|
|
313 self.handler = handler
|
|
314 self.frame = frame
|
|
315
|
|
316 self.sizer = wx.BoxSizer( wx.VERTICAL )
|
216
|
317
|
|
318 self.text = wx.TextCtrl(self, 3, handler.xml.get('name'))
|
|
319 self.sizer.Add(wx.StaticText(self, -1, "Title:"), 0, wx.EXPAND)
|
|
320 self.sizer.Add(self.text, 0, wx.EXPAND)
|
|
321
|
156
|
322 self.grid = minilib_grid( self, handler )
|
|
323
|
|
324 bbox = wx.BoxSizer( wx.HORIZONTAL )
|
|
325 newMiniBtn = wx.Button( self, wx.ID_ANY, "New mini" )
|
|
326 delMiniBtn = wx.Button( self, wx.ID_ANY, "Del mini" )
|
|
327 addMiniBtn = wx.Button( self, wx.ID_ANY, "Add 1" )
|
|
328 addBatchBtn = wx.Button( self, wx.ID_ANY, "Add Batch" )
|
|
329 bbox.Add(newMiniBtn, 0, wx.EXPAND )
|
|
330 bbox.Add(delMiniBtn, 0, wx.EXPAND )
|
|
331 bbox.Add(wx.Size(10,10))
|
|
332 bbox.Add(addMiniBtn, 0, wx.EXPAND )
|
|
333 bbox.Add(addBatchBtn, 0, wx.EXPAND )
|
|
334
|
|
335 self.sizer.Add( self.grid, 1, wx.EXPAND)
|
|
336 self.sizer.Add( bbox, 0)
|
|
337 self.SetSizer(self.sizer)
|
|
338 self.SetAutoLayout(True)
|
|
339 self.Fit()
|
|
340
|
216
|
341 self.Bind(wx.EVT_TEXT, self.on_text, id=3)
|
156
|
342 self.Bind(wx.EVT_BUTTON, self.add_mini, newMiniBtn)
|
|
343 self.Bind(wx.EVT_BUTTON, self.del_mini, delMiniBtn)
|
|
344 self.Bind(wx.EVT_BUTTON, self.send_to_map, addMiniBtn)
|
|
345 self.Bind(wx.EVT_BUTTON, self.send_group_to_map, addBatchBtn)
|
|
346
|
|
347 def add_mini( self, evt=None ):
|
|
348 """Event handler for the 'New mini' button. It calls
|
|
349 minilib_grid.add_row
|
|
350 """
|
|
351 self.grid.add_row()
|
|
352
|
|
353 def del_mini( self, evt=None ):
|
|
354 """Event handler for the 'Del mini' button. It calls
|
|
355 minilib_grid.del_row
|
|
356 """
|
|
357 self.grid.del_row()
|
|
358
|
|
359 def send_to_map( self, evt=None ):
|
|
360 """Event handler for the 'Add 1' button. Sends the
|
|
361 miniature defined by the currently selected row to the map, once.
|
|
362 """
|
216
|
363 index = self.grid.GetSelectedRows()[0] if len(self.grid.GetSelectedRows()) > 0 else 0
|
156
|
364 self.handler.send_mini_to_map( self.handler.get_mini( index ) )
|
|
365
|
|
366 def send_group_to_map( self, evt=None ):
|
|
367 """Event handler for the 'Add batch' button. Querys the user
|
|
368 for a mini count and sends the miniature defined by the currently
|
|
369 selected row to the map, the specified number of times.
|
|
370 """
|
|
371 if self.grid.GetNumberRows() > 0:
|
|
372 dlg = wx.TextEntryDialog( self.frame,
|
|
373 'How many %s\'s do you want to add?' %
|
|
374 ( self.grid.getSelectedLabel() ), 'Batch mini add', '2' )
|
|
375 if dlg.ShowModal() == wx.ID_OK:
|
|
376 try: value = eval( dlg.GetValue() )
|
|
377 except: value = 0
|
|
378 print 'getting selected index for batch send'
|
216
|
379 index = self.grid.GetSelectedRows()[0] if len(self.grid.GetSelectedRows()) > 0 else 0
|
156
|
380 print 'sending batch to map'
|
|
381 self.handler.send_mini_to_map( self.handler.get_mini( index ), value )
|
|
382
|
216
|
383 def on_text(self, evt):
|
|
384 txt = self.text.GetValue()
|
|
385 if txt != "":
|
|
386 self.handler.xml.set('name',txt)
|
|
387 self.handler.rename(txt)
|
|
388
|
156
|
389 class minilib_grid(wx.grid.Grid):
|
|
390 """A wxGrid subclass designed for editing game tree miniature library
|
|
391 nodes.
|
|
392 """
|
|
393 def __init__( self, parent, handler ):
|
|
394 """Constructor.
|
|
395 """
|
|
396 wx.grid.Grid.__init__(self, parent, -1, style=wx.SUNKEN_BORDER | wx.WANTS_CHARS )
|
|
397 self.parent = parent
|
|
398 self.handler = handler
|
|
399 self.keys = CORE_ATTRIBUTES
|
|
400 self.CreateGrid( 1, len( self.keys ) )
|
|
401 for key in self.keys: self.SetColLabelValue( self.keys.index( key ), key )
|
|
402 self.update_all()
|
|
403 self.selectedRow = 0
|
|
404 self.AutoSizeColumns()
|
|
405 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.on_cell_change)
|
|
406 self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.select_cell)
|
216
|
407 self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_CLICK, self.select_cell)
|
156
|
408
|
|
409 def update_cols( self ):
|
|
410 for n in self.handler.xml.findall(TAG_MINIATURE):
|
|
411 for k in n.keys():
|
|
412 if k not in self.keys: self.keys.append( k )
|
|
413
|
|
414 def select_cell( self, evt ):
|
|
415 """Event handler for grid cell selection changes. It stores the
|
|
416 last selected row in a variable for use by the add[*] and del_row
|
|
417 operations.
|
|
418 """
|
|
419 self.BeginBatch()
|
|
420 self.selectedRow = evt.GetRow()
|
|
421 self.SelectRow( self.selectedRow )
|
|
422 self.EndBatch()
|
|
423 evt.Skip()
|
|
424
|
|
425 def getList( self ):
|
|
426 """Returns the list of 'miniature' DOM elements associated with this
|
|
427 miniature library.
|
|
428 """
|
|
429 return self.handler.xml.findall( TAG_MINIATURE )
|
|
430
|
|
431 def add_row( self, count = 1 ):
|
|
432 """creates a new miniature node, and then adds it to the current
|
|
433 miniature library, and to the grid.
|
|
434 """
|
|
435 self.AppendRows( count )
|
|
436 node = self.handler.new_mini( {
|
|
437 ATTRIBUTE_NAME :' ',
|
|
438 ATTRIBUTE_URL :'http://'} )# minidom.Element( TAG_MINIATURE )
|
|
439 self.update_all()
|
|
440 #self.handler.xml.append( node )
|
|
441
|
|
442 def del_row( self ):
|
|
443 """deletes the miniature associated with the currently selected
|
|
444 row. BUG BUG BUG this method should drop a child from the DOM but
|
|
445 does not.
|
|
446 """
|
|
447 if self.selectedRow > -1:
|
|
448 pos = self.selectedRow
|
|
449 list = self.handler.xml.findall(TAG_MINIATURE)
|
|
450 self.handler.xml.remove( list[pos] )
|
|
451 self.DeleteRows( pos, 1 )
|
|
452
|
|
453 def on_cell_change( self, evt ):
|
|
454 """Event handler for cell selection changes. selected row is used
|
|
455 to update data for that row.
|
|
456 """
|
|
457 row = evt.GetRow()
|
|
458 self.update_data_row( row )
|
|
459
|
|
460 def update_all( self ):
|
|
461 """ensures that the grid is displaying the correct number of
|
|
462 rows, and then updates all data displayed by the grid
|
|
463 """
|
|
464 list = self.getList()
|
|
465 count = 0
|
|
466 for n in list:
|
|
467 for k in n.keys():
|
|
468 if k not in self.keys: self.keys.append( k )
|
|
469 count = len( self.keys )
|
|
470 if self.GetNumberCols() < count:
|
|
471 self.AppendCols( count - self.GetNumberCols() )
|
|
472 for k in self.keys: self.SetColLabelValue( self.keys.index( k ), k )
|
|
473 count = len( list )
|
|
474 rowcount = self.GetNumberRows()
|
|
475 if ( count > rowcount ):
|
|
476 total = count - rowcount
|
|
477 self.AppendRows( total )
|
|
478 elif ( count < rowcount ):
|
|
479 total = rowcount - count
|
|
480 self.DeleteRows( 0, total );
|
|
481 for index in range( 0, count ):
|
|
482 self.update_grid_row( index )
|
|
483
|
|
484 def getSelectedLabel( self ):
|
|
485 """Returns the label for the selected row
|
|
486 """
|
|
487 return self.GetTable().GetValue( self.selectedRow, 0 )
|
|
488
|
|
489 def getSelectedURL( self ):
|
|
490 """Returns the URL for the selected row
|
|
491 """
|
|
492 return self.GetTable().GetValue( self.selectedRow, 1 )
|
|
493
|
|
494 def getSelectedSerial( self ):
|
|
495 """Returns the ATTRIBUTE_UNIQUE value for the selected row
|
|
496 """
|
|
497 return self.GetTable().GetValue( self.selectedRow, 2 )
|
|
498
|
|
499 def update_grid_row( self, row ):
|
|
500 """Updates the specified grid row with data from the DOM node
|
|
501 specified by 'row'
|
|
502 """
|
|
503 list = self.getList()
|
|
504 item = list[ row ]
|
|
505 for key in self.keys: self.GetTable().SetValue( row, self.keys.index( key ), item.get( key ) )
|
|
506
|
|
507 def update_data_row( self, row ):
|
|
508 """Updates the DOM nodw 'row' with grid data from 'row'
|
|
509 """
|
|
510 list = self.getList()
|
|
511 item = list[ row ]
|
|
512 for key in self.keys: item.set( key, string.strip( self.GetTable().GetValue( row, self.keys.index( key ) ) ) )
|