dbm_dialogs.py 25 KB

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