The problem is how you are trying to interact with the signal. Instead of checking for a signal with a conditional 'if:' statement, you should listen for it and connect it to a slot. the basic idea (in pseudocode) is:
The slot can be a Public slot belonging to an available class, or you can simply define a new class method and connect a signal to it.
Also, I would strongly recommend removing most of your logic from the
run() method especially signal/slot connections. Unless you include logic to disconnect them when you close the plugin dialog, having signal/slot connections in the
run() method is a bad idea because another connection is created every time you open your plugin dialog. You won't notice the first time you run your plugin, but the second time, whatever slot you have connected to the signal will be called twice when the signal is emitted, then 3 times on the 3rd run etc. until you re-load your plugin or restart QGIS.
There are a few effective ways to deal with this issue; my personal preference is usually to set up signal/slot connections in the
initGui() method so that they are only established once when the plugin is loaded at the start of the current QGIS session.
Another problem which can arise from inadvertently creating multiple duplicate connections is empty Python wrappers for deleted C++ objects, causing frustrating runtime errors. I think for your case, all you really need to do in the
run() method is show the dialog, and (a small addition which might be useful)- set the slider to the current canvas scale as a starting point for adjustment.
If I was you I would do something like this:
Create a new method in your main plugin.py file. This will be your slot function which you connect to the signal emitted when the slider is released. This would look like the following (I have also included the
run() method for reference):
result = self.dlg.exec_()
scale = self.dlg.horizontalSlider.value()
Then, add these lines at the end of the
# other stuff