Is it possible to run separate python processes through tab widgets of the same QGIS plugin. I have created a QGIS plugin using the plugin builder. From QT designer I added two tab widgets to the plugin. I want to run different processes in both the tabs, one at a time though. Right now I can run the process in the first Tab, but I do not know how to add the script to the second tab and run it when the 'OK' button in second tab is clicked.
Just define separate class methods in your main plugin class and connect them to different buttons in your UI tabs. For example, if you have buttons with object names like
ok_btn_2, in the
initGui method of your main plugin file, connect the clicked signal to the methods which contain the 'processes' you want to run.
def initGui(self): ... self.dlg.ok_btn_1.clicked.connect(self.process_1) self.dlg.ok_btn_2.clicked.connect(self.process_2)
then make sure you have defined those class methods:
def process_1(self): # Do something def process_2(self): # Do something else
I have just created a GitHub repository with an example of a simple plugin with a tabbed UI (created without PluginBuilder or QtDesigner). Hopefully you may find it useful: