You need to use QWidget
method activateWindow()
as mentioned in this answer by Avaris.
You can then modify your plugin from this :
def run(self):
"""Run method that performs all the real work"""
# Create the dialog with elements (after translation) and keep reference
# Only create GUI ONCE in callback, so that it will only load when the plugin is started
if self.first_start == True:
self.first_start = False
self.dlg = YourPluginDialog()
# show the dialog
self.dlg.show()
# Run the dialog event loop
result = self.dlg.exec_()
# See if OK was pressed
if result:
# Do something
To this :
def run(self):
"""Run method that performs all the real work"""
# Create the dialog with elements (after translation) and keep reference
# Only create GUI ONCE in callback, so that it will only load when the plugin is started
if self.first_start == True:
self.first_start = False
self.dlg = YourPluginDialog()
# show the dialog
self.dlg.show()
else:
self.dlg.activateWindow()
# Run the dialog event loop
result = self.dlg.exec_()
print(result)
# See if OK was pressed
if result == 1:
# Do something
result
must be equal to 1 because reopening the dialog might give result
the value of -1, so if result
is valid. 1 is the outcome when the user is pressing the OK
button.