Sometimes, applications require some time to process a command, and while doing so, the user has to be given some feedback so that he/she doesn't think that the application is frozen. This can be accomplished in several ways, but one common way is to provide animated feedback in the form of a progress bar or gauge. In this recipe, you will see how to animate a gauge to give feedback while a long-running task is completed on a background thread.
Here are the steps to be performed:
First, we need to import some extra modules for this recipe, so let's take a quick look at the needed imports:
import threading import wx
Next, we will use a background thread to do the calculations. For this, see the following:
class FibonacciCalc(threading.Thread): def __init__(self, n, completeFunc): super(FibonacciCalc, self).__init__() assert callable(completeFunc) self.n = n self.complete = completeFunc def run(self): def fib(n)...