1

I'm looking for more guidance using the QGIS ComboBoxManager module (http://3nids.github.io/qgiscombomanager/). After finally getting the imports correct, I'm trudging my way through learning how to use it. I'm creating a simple plugin that utilizes three separate combo boxes to choose layers. Accepting the initial dialog runs a series of calculations based on data associated. Adding attribute list to combobox in a python plugin got me off to a good start, but I'm new to this, and having some issues adapting the example.

Some code from my plugin's main .py:

class zConso(Ui_zConso, VectorLayerCombo):

def __init__(self, iface, QComboBox, initLayer="", options={}):
    # Save reference to the QGIS interface
    self.iface = iface
    VectorLayerCombo.__init__(self, QComboBox, initLayer, options)

    self.layerChanged()
    self.indivComboManager = VectorLayerCombo(self.indivCombo)
    self.grosComboManager = VectorLayerCombo(self.grosCombo)
    self.resComboManager = VectorLayerCombo(self.resCombo)

    # Create the GUI dialog (after translation) and keep reference
    self.dlg = zConsoDialog()

    # current layer ref (set in handleLayerChange)
    self.indivLayer = None
    self.grosLayer = None
    self.resLayer = None


def initGui(self):
    # connect the action to the run method
    QObject.connect(self.action, SIGNAL("triggered()"), self.run)
    #self.action.triggered.connect(self.run)

    # Add toolbar button and menu item
    self.iface.addToolBarIcon(self.action)
    self.iface.addPluginToMenu(u"&zConso", self.action)

    QObject.connect(self.dlg.ui.indivCombo,SIGNAL("currentIndexChanged(int)"),self.layerChanged)
    QObject.connect(self.dlg.ui.grosCombo,SIGNAL("currentIndexChanged(int)"),self.layerChanged)
    QObject.connect(self.dlg.ui.resCombo,SIGNAL("currentIndexChanged(int)"),self.layerChanged)

def layerChanged(self):
    self.indivLayer = self.indivComboManager.getLayer()
    self.grosLayer = self.grosComboManager.getLayer()
    self.resLayer = self.resComboManager.getLayer()
    if self.layer is None:
        QMessageBox.warning(
            None,
            'Statistic AEP',
            'Choissisez des couche pour calculer des statistics de consommation AEP')

My plugin imports as broken:

__init__() takes at least 3 arguments (2 given)

I'm not sure I'm going about this the right way. Do let me know if you can make a suggestion.

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
user25976
  • 2,115
  • 1
  • 22
  • 39
  • Why is zConsoDialog inheriting from VectorLayerCombo? That doesn't make any sense. – Nathan W Apr 05 '14 at 08:41
  • now i feel sure it doesn't. I went about it this way, as this class inherited from the compiled PyQt designer ui files. i've switched some things around now, but still far from my goal. – user25976 Apr 08 '14 at 19:53

0 Answers0