While trying to solve a bigger issue, I reduced my code to two simple commands and I found out that they are not executed in order.
My idea is to give a kind of feedback to the user after clicking on a button(3D Slicer) while running a function. So, what I would expect is to freeze the button immediately after clicking it until the action is finished. So I tried the following to check if the very first command is executed on first position:
def onStartSegmentation(self):
self.segmentButton.setEnabled(False)
sleep(3)
print("2nd step: Starting segmentation")
However, the result is sleeping for 3 seconds and then executing both commands immediately one after the other.
I know this might sound silly, but I can't guess why it's acting like that.