dbm_dialogs.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. """
  2. @package dbm_dialogs.py
  3. @brief DBM-related dialogs
  4. List of classes:
  5. - DisplayAttributesDialog
  6. - ModifyTableRecord
  7. (C) 2007-2009 by the GRASS Development Team
  8. This program is free software under the GNU General Public
  9. License (>=v2). Read the file COPYING that comes with GRASS
  10. for details.
  11. @author Martin Landa <landa.martin gmail.com>
  12. """
  13. import os
  14. import globalvar
  15. if not os.getenv("GRASS_WXBUNDLED"):
  16. globalvar.CheckForWx()
  17. import wx
  18. import wx.lib.scrolledpanel as scrolled
  19. import dbm
  20. import gcmd
  21. from debug import Debug
  22. from preferences import globalSettings as UserSettings
  23. class DisplayAttributesDialog(wx.Dialog):
  24. """
  25. Standard dialog used to add/update/display attributes linked
  26. to the vector map.
  27. Attribute data can be selected based on layer and category number
  28. or coordinates.
  29. @param parent
  30. @param map vector map
  31. @param query query coordinates and distance (used for v.edit)
  32. @param cats {layer: cats}
  33. @param line feature id (requested for cats)
  34. @param style
  35. @param pos
  36. @param action (add, update, display)
  37. """
  38. def __init__(self, parent, map,
  39. query=None, cats=None, line=None,
  40. style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
  41. pos=wx.DefaultPosition,
  42. action="add"):
  43. self.parent = parent # mapdisplay.BufferedWindow
  44. self.map = map
  45. self.action = action
  46. # ids/cats of selected features
  47. # fid : {layer : cats}
  48. self.cats = {}
  49. self.fid = -1 # feature id
  50. # get layer/table/column information
  51. self.mapDBInfo = dbm.VectorDBInfo(self.map)
  52. layers = self.mapDBInfo.layers.keys() # get available layers
  53. # check if db connection / layer exists
  54. if len(layers) <= 0:
  55. label = _("Database connection "
  56. "is not defined in DB file.")
  57. wx.MessageBox(parent=self.parent,
  58. message=_("No attribute table linked to "
  59. "vector map <%(vector)s> found. %(msg)s"
  60. "\nYou can disable this message from digitization settings. Or "
  61. "you can create and link attribute table to the vector map "
  62. "using Attribute Table Manager.") %
  63. {'vector' : self.map, 'msg' : label},
  64. caption=_("Message"), style=wx.OK | wx.ICON_EXCLAMATION | wx.CENTRE)
  65. self.mapDBInfo = None
  66. wx.Dialog.__init__(self, parent=self.parent, id=wx.ID_ANY,
  67. title="", style=style, pos=pos)
  68. # dialog body
  69. mainSizer = wx.BoxSizer(wx.VERTICAL)
  70. # notebook
  71. self.notebook = wx.Notebook(parent=self, id=wx.ID_ANY, style=wx.BK_DEFAULT)
  72. self.closeDialog = wx.CheckBox(parent=self, id=wx.ID_ANY,
  73. label=_("Close dialog on submit"))
  74. self.closeDialog.SetValue(True)
  75. # feature id (text/choice for duplicates)
  76. self.fidMulti = wx.Choice(parent=self, id=wx.ID_ANY,
  77. size=(150, -1))
  78. self.fidMulti.Bind(wx.EVT_CHOICE, self.OnFeature)
  79. self.fidText = wx.StaticText(parent=self, id=wx.ID_ANY)
  80. self.noFoundMsg = wx.StaticText(parent=self, id=wx.ID_ANY,
  81. label=_("No attributes found"))
  82. self.UpdateDialog(query=query, cats=cats)
  83. # set title
  84. if self.action == "update":
  85. self.SetTitle(_("Update attributes"))
  86. elif self.action == "add":
  87. self.SetTitle(_("Add attributes"))
  88. else:
  89. self.SetTitle(_("Display attributes"))
  90. # buttons
  91. btnCancel = wx.Button(self, wx.ID_CANCEL)
  92. btnReset = wx.Button(self, wx.ID_UNDO, _("&Reload"))
  93. btnSubmit = wx.Button(self, wx.ID_OK, _("&Submit"))
  94. btnSizer = wx.StdDialogButtonSizer()
  95. btnSizer.AddButton(btnCancel)
  96. btnSizer.AddButton(btnReset)
  97. btnSizer.SetNegativeButton(btnReset)
  98. btnSubmit.SetDefault()
  99. btnSizer.AddButton(btnSubmit)
  100. btnSizer.Realize()
  101. mainSizer.Add(item=self.noFoundMsg, proportion=0,
  102. flag=wx.EXPAND | wx.ALL, border=5)
  103. mainSizer.Add(item=self.notebook, proportion=1,
  104. flag=wx.EXPAND | wx.ALL, border=5)
  105. fidSizer = wx.BoxSizer(wx.HORIZONTAL)
  106. fidSizer.Add(item=wx.StaticText(parent=self, id=wx.ID_ANY,
  107. label=_("Feature id:")),
  108. proportion=0, border=5,
  109. flag=wx.ALIGN_CENTER_VERTICAL)
  110. fidSizer.Add(item=self.fidMulti, proportion=0,
  111. flag=wx.EXPAND | wx.ALL, border=5)
  112. fidSizer.Add(item=self.fidText, proportion=0,
  113. flag=wx.EXPAND | wx.ALL, border=5)
  114. mainSizer.Add(item=fidSizer, proportion=0,
  115. flag=wx.EXPAND | wx.LEFT | wx.RIGHT, border=5)
  116. mainSizer.Add(item=self.closeDialog, proportion=0, flag=wx.EXPAND | wx.LEFT | wx.RIGHT,
  117. border=5)
  118. mainSizer.Add(item=btnSizer, proportion=0,
  119. flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5)
  120. # bindigs
  121. btnReset.Bind(wx.EVT_BUTTON, self.OnReset)
  122. btnSubmit.Bind(wx.EVT_BUTTON, self.OnSubmit)
  123. btnCancel.Bind(wx.EVT_BUTTON, self.OnCancel)
  124. self.SetSizer(mainSizer)
  125. mainSizer.Fit(self)
  126. # set min size for dialog
  127. w, h = self.GetBestSize()
  128. if h < 200:
  129. self.SetMinSize((w, 200))
  130. else:
  131. self.SetMinSize(self.GetBestSize())
  132. if self.notebook.GetPageCount() == 0:
  133. Debug.msg(2, "DisplayAttributesDialog(): Nothing found!")
  134. ### self.mapDBInfo = None
  135. def __SelectAttributes(self, layer):
  136. """!Select attributes"""
  137. pass
  138. def OnSQLStatement(self, event):
  139. """!Update SQL statement"""
  140. pass
  141. def GetSQLString(self, updateValues=False):
  142. """!Create SQL statement string based on self.sqlStatement
  143. If updateValues is True, update dataFrame according to values
  144. in textfields.
  145. """
  146. sqlCommands = []
  147. # find updated values for each layer/category
  148. for layer in self.mapDBInfo.layers.keys(): # for each layer
  149. table = self.mapDBInfo.layers[layer]["table"]
  150. key = self.mapDBInfo.layers[layer]["key"]
  151. columns = self.mapDBInfo.tables[table]
  152. for idx in range(len(columns[key]['values'])): # for each category
  153. updatedColumns = []
  154. updatedValues = []
  155. for name in columns.keys():
  156. if name == key:
  157. cat = columns[name]['values'][idx]
  158. continue
  159. type = columns[name]['type']
  160. value = columns[name]['values'][idx]
  161. id = columns[name]['ids'][idx]
  162. try:
  163. newvalue = self.FindWindowById(id).GetValue()
  164. except:
  165. newvalue = self.FindWindowById(id).GetLabel()
  166. if newvalue == '':
  167. newvalue = None
  168. if newvalue != value:
  169. updatedColumns.append(name)
  170. if newvalue is None:
  171. updatedValues.append('NULL')
  172. else:
  173. if type != 'character':
  174. updatedValues.append(newvalue)
  175. else:
  176. updatedValues.append("'" + newvalue + "'")
  177. columns[name]['values'][idx] = newvalue
  178. if self.action != "add" and len(updatedValues) == 0:
  179. continue
  180. if self.action == "add":
  181. sqlString = "INSERT INTO %s (%s," % (table, key)
  182. else:
  183. sqlString = "UPDATE %s SET " % table
  184. for idx in range(len(updatedColumns)):
  185. name = updatedColumns[idx]
  186. if self.action == "add":
  187. sqlString += name + ","
  188. else:
  189. sqlString += name + "=" + updatedValues[idx] + ","
  190. sqlString = sqlString[:-1] # remove last comma
  191. if self.action == "add":
  192. sqlString += ") VALUES (%s," % cat
  193. for value in updatedValues:
  194. sqlString += str(value) + ","
  195. sqlString = sqlString[:-1] # remove last comma
  196. sqlString += ")"
  197. else:
  198. sqlString += " WHERE cat=%s" % cat
  199. sqlCommands.append(sqlString)
  200. # for each category
  201. # for each layer END
  202. Debug.msg(3, "DisplayAttributesDialog.GetSQLString(): %s" % sqlCommands)
  203. return sqlCommands
  204. def OnReset(self, event):
  205. """!Reset form"""
  206. for layer in self.mapDBInfo.layers.keys():
  207. table = self.mapDBInfo.layers[layer]["table"]
  208. key = self.mapDBInfo.layers[layer]["key"]
  209. columns = self.mapDBInfo.tables[table]
  210. for idx in range(len(columns[key]['values'])):
  211. for name in columns.keys():
  212. type = columns[name]['type']
  213. value = columns[name]['values'][idx]
  214. try:
  215. id = columns[name]['ids'][idx]
  216. except IndexError:
  217. id = wx.NOT_FOUND
  218. if name != key and id != wx.NOT_FOUND:
  219. self.FindWindowById(id).SetValue(str(value))
  220. def OnCancel(self, event):
  221. """!Cancel button pressed"""
  222. self.parent.parent.dialogs['attributes'] = None
  223. if self.parent.parent.digit:
  224. self.parent.parent.digit.driver.SetSelected([])
  225. self.parent.UpdateMap(render=False)
  226. else:
  227. self.parent.parent.OnRender(None)
  228. self.Close()
  229. def OnSubmit(self, event):
  230. """!Submit records"""
  231. for sql in self.GetSQLString(updateValues=True):
  232. enc = UserSettings.Get(group='atm', key='encoding', subkey='value')
  233. if not enc and \
  234. os.environ.has_key('GRASS_DB_ENCODING'):
  235. enc = os.environ['GRASS_DB_ENCODING']
  236. if enc:
  237. sql = sql.encode(enc)
  238. gcmd.RunCommand('db.execute',
  239. quiet = True,
  240. stdin = sql)
  241. if self.closeDialog.IsChecked():
  242. self.OnCancel(event)
  243. def OnFeature(self, event):
  244. self.fid = int(event.GetString())
  245. self.UpdateDialog(cats=self.cats, fid=self.fid)
  246. def GetCats(self):
  247. """!Get id of selected vector object or 'None' if nothing selected
  248. @param id if true return ids otherwise cats
  249. """
  250. if self.fid < 0:
  251. return None
  252. return self.cats[self.fid]
  253. def GetFid(self):
  254. """!Get selected feature id"""
  255. return self.fid
  256. def UpdateDialog(self, map=None, query=None, cats=None, fid=-1):
  257. """!Update dialog
  258. Return True if updated otherwise False
  259. """
  260. if map:
  261. self.map = map
  262. # get layer/table/column information
  263. self.mapDBInfo = VectorDBInfo(self.map)
  264. if not self.mapDBInfo:
  265. return False
  266. self.mapDBInfo.Reset()
  267. layers = self.mapDBInfo.layers.keys() # get available layers
  268. # id of selected line
  269. if query: # select by position
  270. data = self.mapDBInfo.SelectByPoint(query[0],
  271. query[1])
  272. self.cats = {}
  273. if data and data.has_key('Layer'):
  274. idx = 0
  275. for layer in data['Layer']:
  276. layer = int(layer)
  277. if data.has_key('Id'):
  278. tfid = int(data['Id'][idx])
  279. else:
  280. tfid = 0 # Area / Volume
  281. if not self.cats.has_key(tfid):
  282. self.cats[tfid] = {}
  283. if not self.cats[tfid].has_key(layer):
  284. self.cats[tfid][layer] = []
  285. cat = int(data['Category'][idx])
  286. self.cats[tfid][layer].append(cat)
  287. idx += 1
  288. else:
  289. self.cats = cats
  290. if fid > 0:
  291. self.fid = fid
  292. elif len(self.cats.keys()) > 0:
  293. self.fid = self.cats.keys()[0]
  294. else:
  295. self.fid = -1
  296. if len(self.cats.keys()) == 1:
  297. self.fidMulti.Show(False)
  298. self.fidText.Show(True)
  299. if self.fid > 0:
  300. self.fidText.SetLabel("%d" % self.fid)
  301. else:
  302. self.fidText.SetLabel(_("Unknown"))
  303. else:
  304. self.fidMulti.Show(True)
  305. self.fidText.Show(False)
  306. choices = []
  307. for tfid in self.cats.keys():
  308. choices.append(str(tfid))
  309. self.fidMulti.SetItems(choices)
  310. self.fidMulti.SetStringSelection(str(self.fid))
  311. # reset notebook
  312. self.notebook.DeleteAllPages()
  313. for layer in layers: # for each layer
  314. if not query: # select by layer/cat
  315. if self.fid > 0 and self.cats[self.fid].has_key(layer):
  316. for cat in self.cats[self.fid][layer]:
  317. nselected = self.mapDBInfo.SelectFromTable(layer,
  318. where="%s=%d" % \
  319. (self.mapDBInfo.layers[layer]['key'],
  320. cat))
  321. else:
  322. nselected = 0
  323. # if nselected <= 0 and self.action != "add":
  324. # continue # nothing selected ...
  325. if self.action == "add":
  326. if nselected <= 0:
  327. if self.cats[self.fid].has_key(layer):
  328. table = self.mapDBInfo.layers[layer]["table"]
  329. key = self.mapDBInfo.layers[layer]["key"]
  330. columns = self.mapDBInfo.tables[table]
  331. for name in columns.keys():
  332. if name == key:
  333. for cat in self.cats[self.fid][layer]:
  334. self.mapDBInfo.tables[table][name]['values'].append(cat)
  335. else:
  336. self.mapDBInfo.tables[table][name]['values'].append(None)
  337. else: # change status 'add' -> 'update'
  338. self.action = "update"
  339. table = self.mapDBInfo.layers[layer]["table"]
  340. key = self.mapDBInfo.layers[layer]["key"]
  341. columns = self.mapDBInfo.tables[table]
  342. for idx in range(len(columns[key]['values'])):
  343. for name in columns.keys():
  344. if name == key:
  345. cat = int(columns[name]['values'][idx])
  346. break
  347. # use scrolled panel instead (and fix initial max height of the window to 480px)
  348. panel = scrolled.ScrolledPanel(parent=self.notebook, id=wx.ID_ANY,
  349. size=(-1, 150))
  350. panel.SetupScrolling(scroll_x=False)
  351. self.notebook.AddPage(page=panel, text=" %s %d / %s %d" % (_("Layer"), layer,
  352. _("Category"), cat))
  353. # notebook body
  354. border = wx.BoxSizer(wx.VERTICAL)
  355. flexSizer = wx.FlexGridSizer (cols=4, hgap=3, vgap=3)
  356. flexSizer.AddGrowableCol(3)
  357. # columns (sorted by index)
  358. names = [''] * len(columns.keys())
  359. for name in columns.keys():
  360. names[columns[name]['index']] = name
  361. for name in names:
  362. if name == key: # skip key column (category)
  363. continue
  364. vtype = columns[name]['type']
  365. if columns[name]['values'][idx] is not None:
  366. if columns[name]['ctype'] != type(''):
  367. value = str(columns[name]['values'][idx])
  368. else:
  369. value = columns[name]['values'][idx]
  370. else:
  371. value = ''
  372. colName = wx.StaticText(parent=panel, id=wx.ID_ANY,
  373. label=name)
  374. colType = wx.StaticText(parent=panel, id=wx.ID_ANY,
  375. label="[" + vtype.lower() + "]")
  376. delimiter = wx.StaticText(parent=panel, id=wx.ID_ANY, label=":")
  377. colValue = wx.TextCtrl(parent=panel, id=wx.ID_ANY, value=value)
  378. colValue.SetName(name)
  379. self.Bind(wx.EVT_TEXT, self.OnSQLStatement, colValue)
  380. flexSizer.Add(colName, proportion=0,
  381. flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL)
  382. flexSizer.Add(colType, proportion=0,
  383. flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL)
  384. flexSizer.Add(delimiter, proportion=0,
  385. flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL)
  386. flexSizer.Add(colValue, proportion=1,
  387. flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL)
  388. # add widget reference to self.columns
  389. columns[name]['ids'].append(colValue.GetId()) # name, type, values, id
  390. # for each attribute (including category) END
  391. border.Add(item=flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
  392. panel.SetSizer(border)
  393. # for each category END
  394. # for each layer END
  395. if self.notebook.GetPageCount() == 0:
  396. self.noFoundMsg.Show(True)
  397. else:
  398. self.noFoundMsg.Show(False)
  399. self.Layout()
  400. return True
  401. class ModifyTableRecord(wx.Dialog):
  402. """!Dialog for inserting/updating table record"""
  403. def __init__(self, parent, id, title, data, keyEditable=(-1, True),
  404. style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
  405. """
  406. Notes:
  407. 'Data' is a list: [(column, value)]
  408. 'KeyEditable' (id, editable?) indicates if textarea for key column
  409. is editable(True) or not.
  410. """
  411. wx.Dialog.__init__(self, parent, id, title, style=style)
  412. self.CenterOnParent()
  413. self.keyId = keyEditable[0]
  414. self.panel = wx.Panel(parent=self, id=wx.ID_ANY)
  415. box = wx.StaticBox(parent=self.panel, id=wx.ID_ANY, label='')
  416. self.dataPanel = scrolled.ScrolledPanel(parent=self.panel, id=wx.ID_ANY,
  417. style=wx.TAB_TRAVERSAL)
  418. self.dataPanel.SetupScrolling(scroll_x=False)
  419. #
  420. # buttons
  421. #
  422. self.btnCancel = wx.Button(self.panel, wx.ID_CANCEL)
  423. self.btnSubmit = wx.Button(self.panel, wx.ID_OK, _("Submit"))
  424. self.btnSubmit.SetDefault()
  425. #
  426. # data area
  427. #
  428. self.widgets = []
  429. id = 0
  430. self.usebox = False
  431. self.cat = None
  432. for column, value in data:
  433. if keyEditable[0] == id:
  434. self.cat = int(value)
  435. if keyEditable[1] == False:
  436. self.usebox = True
  437. box.SetLabel =" %s %d " % (_("Category"), self.cat)
  438. self.boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  439. id += 1
  440. continue
  441. else:
  442. valueWin = wx.SpinCtrl(parent=self.dataPanel, id=wx.ID_ANY,
  443. value=value, min=-1e9, max=1e9, size=(250, -1))
  444. else:
  445. valueWin = wx.TextCtrl(parent=self.dataPanel, id=wx.ID_ANY,
  446. value=value, size=(250, -1))
  447. label = wx.StaticText(parent=self.dataPanel, id=wx.ID_ANY,
  448. label=column + ":")
  449. self.widgets.append((label.GetId(),
  450. valueWin.GetId()))
  451. id += 1
  452. self.__Layout()
  453. # winSize = self.GetSize()
  454. # fix height of window frame if needed
  455. # if winSize[1] > 480:
  456. # winSize[1] = 480
  457. # self.SetSize(winSize)
  458. # self.SetMinSize(winSize)
  459. def __Layout(self):
  460. """!Do layout"""
  461. sizer = wx.BoxSizer(wx.VERTICAL)
  462. # data area
  463. dataSizer = wx.FlexGridSizer (cols=2, hgap=3, vgap=3)
  464. dataSizer.AddGrowableCol(1)
  465. for labelId, valueId in self.widgets:
  466. label = self.FindWindowById(labelId)
  467. value = self.FindWindowById(valueId)
  468. dataSizer.Add(label, proportion=0,
  469. flag=wx.ALIGN_CENTER_VERTICAL)
  470. dataSizer.Add(value, proportion=0,
  471. flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL)
  472. self.dataPanel.SetAutoLayout(True)
  473. self.dataPanel.SetSizer(dataSizer)
  474. dataSizer.Fit(self.dataPanel)
  475. if self.usebox:
  476. self.boxSizer.Add(item=self.dataPanel, proportion=1,
  477. flag=wx.EXPAND | wx.ALL, border=5)
  478. # buttons
  479. btnSizer = wx.StdDialogButtonSizer()
  480. btnSizer.AddButton(self.btnCancel)
  481. btnSizer.AddButton(self.btnSubmit)
  482. btnSizer.Realize()
  483. if not self.usebox:
  484. sizer.Add(item=self.dataPanel, proportion=1,
  485. flag=wx.EXPAND | wx.ALL, border=5)
  486. else:
  487. sizer.Add(item=self.boxSizer, proportion=1,
  488. flag=wx.EXPAND | wx.ALL, border=5)
  489. sizer.Add(item=btnSizer, proportion=0,
  490. flag=wx.EXPAND | wx.ALL, border=5)
  491. framewidth = self.GetSize()[0]
  492. self.SetMinSize((framewidth,150))
  493. self.SetMaxSize((framewidth,300))
  494. #sizer.SetSizeHints(self.panel)
  495. self.panel.SetAutoLayout(True)
  496. self.panel.SetSizer(sizer)
  497. sizer.Fit(self.panel)
  498. self.Layout()
  499. # # set window frame size (min & max)
  500. # minFrameHeight = 150
  501. # maxFrameHeight = 2 * minFrameHeight
  502. # if self.GetSize()[1] > minFrameHeight:
  503. # print 'size ='+str(self.GetSize()[1])
  504. # print 'if 1'
  505. # self.SetMinSize((self.GetSize()[0], minFrameHeight))
  506. # else:
  507. # print 'else 1'
  508. # self.SetMinSize(self.GetSize())
  509. # if self.GetSize()[1] > maxFrameHeight:
  510. # print 'if 2'
  511. # self.SetSize((self.GetSize()[0], maxFrameHeight))
  512. # else:
  513. # print 'else 2'
  514. # self.SetSize(self.panel.GetSize())
  515. def GetValues(self, columns=None):
  516. """!Return list of values (casted to string).
  517. If columns is given (list), return only values of given columns.
  518. """
  519. valueList = []
  520. for labelId, valueId in self.widgets:
  521. column = self.FindWindowById(labelId).GetLabel().replace(':', '')
  522. if columns is None or column in columns:
  523. value = str(self.FindWindowById(valueId).GetValue())
  524. valueList.append(value)
  525. # add key value
  526. if self.usebox:
  527. valueList.insert(self.keyId, str(self.cat))
  528. return valueList