Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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. This thread got me off to a good start (Adding attribute list to combobox in a python plugin), 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.

share|improve this question
    
Why is zConsoDialog inheriting from VectorLayerCombo? That doesn't make any sense. –  Nathan W Apr 5 at 8: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 8 at 19:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.