in a python plugin for qgis I want the user to be able to select one or more of several options via tick boxes.

I imagine it to look like e.g. Qgis 2.2 tool "Vector" -> "Data Management Tools" -> "Join attributes by location". In the "Attribute Summary" section of this tool the user is able to tick several functions on and off:

enter image description here

At the moment I use a string input (##options=string "option1,option2,option3"). The user has to enter all options separated by a comma. This works but it does not look very pretty.

Is this possible with Pyhton? Any suggestions? Thanks in advance.


Yes this is possible. I think you are looking for a checkbox.

self.yourCheckbox = QtGui.QCheckBox(self.layoutWidget)

Then to see if its checked:

isitchecked = self.dlg.ui.yourCheckbox.isChecked() # returns True if checked

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.