FixedTablePanel.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. """
  2. ***************************************************************************
  3. FixedTablePanel.py
  4. ---------------------
  5. Date : August 2012
  6. Copyright : (C) 2012 by Victor Olaya
  7. Email : volayaf at gmail dot com
  8. ***************************************************************************
  9. * *
  10. * This program is free software; you can redistribute it and/or modify *
  11. * it under the terms of the GNU General Public License as published by *
  12. * the Free Software Foundation; either version 2 of the License, or *
  13. * (at your option) any later version. *
  14. * *
  15. ***************************************************************************
  16. """
  17. __author__ = 'Victor Olaya'
  18. __date__ = 'August 2012'
  19. __copyright__ = '(C) 2012, Victor Olaya'
  20. import os
  21. import warnings
  22. from qgis.PyQt import uic
  23. from processing.gui.FixedTableDialog import FixedTableDialog
  24. pluginPath = os.path.split(os.path.dirname(__file__))[0]
  25. with warnings.catch_warnings():
  26. warnings.filterwarnings("ignore", category=DeprecationWarning)
  27. WIDGET, BASE = uic.loadUiType(
  28. os.path.join(pluginPath, 'ui', 'widgetBaseSelector.ui'))
  29. class FixedTablePanel(BASE, WIDGET):
  30. def __init__(self, param, parent=None):
  31. super().__init__(parent)
  32. self.setupUi(self)
  33. self.leText.setEnabled(False)
  34. self.param = param
  35. # NOTE - table IS squashed to 1-dimensional!
  36. self.table = []
  37. for row in range(param.numberRows()):
  38. for col in range(len(param.headers())):
  39. self.table.append('0')
  40. self.leText.setText(
  41. self.tr('Fixed table {0}x{1}').format(param.numberRows(), len(param.headers())))
  42. self.btnSelect.clicked.connect(self.showFixedTableDialog)
  43. def updateSummaryText(self):
  44. self.leText.setText(self.tr('Fixed table {0}x{1}').format(
  45. len(self.table) // len(self.param.headers()), len(self.param.headers())))
  46. def setValue(self, value):
  47. self.table = value
  48. self.updateSummaryText()
  49. def showFixedTableDialog(self):
  50. dlg = FixedTableDialog(self.param, self.table)
  51. dlg.exec_()
  52. if dlg.rettable is not None:
  53. self.setValue(dlg.rettable)
  54. dlg.deleteLater()