Using PyQGIS, I am developing a QGIS plugin that includes a filter function. It should make handling easier for users (internal) who rarely use QGIS.
Now I have created a interface with the QT Designer that contains several checkboxes.
- Each checkbox contains criteria that can be used to filter. Every checkbox is set at the start.
- With uncheck the checkbox, a more precise selection is activated via a combo box. Let's assume every combo box has 3 different attributes.
- At the end, the filter should be started with the appropriate selection via the push button. The visualization looks like this:
The code gets pretty fast, pretty long, and cluttered.
def Filter_starten():
if checkbox1.isCheck():
"take attributes"
else:
"take other attributes"
if checkbox2.isCheck():
"take attributes"
else:
"take other attributes"
if checkbox1.isCheck() and checkbox2.isCheck():
"take attributes"
else:
"take other attributes"
if checkbox2.isCheck() and checkbox3.isCheck():
"take attributes"
else:
"take other attributes"
And so on..
How can I efficiently program the multitude of possible options in the Filter_starten()
function? How do I avoid a confusing number of if-clauses?