My program has several buttons that, when clicked, call functions take a little while to run. The problem I'm having is that occasionally a button will "activate" twice and the function will run a second time for seemingly no reason. Also, because the functions take a while, the user can click on the same button multiple times or click on other buttons while the first is still running, and those buttons' functions will get executed immediately after the first finishes.
What I want to do is be able to throw away any pending or queued events so that these buttons can't double-activate themselves and so that the user can't accidentally queue up a bunch of these functions. I suppose I could also just disable all the buttons immediately after one of them has been called but that seems like a really inelegant solution compared to just dumping the event queue.
I tried looking everywhere and it does look like there are functions that can do what I want, except I can't actually figure out how to call it. Of course, that function may not exist in the version of wxPython that I'm using, not entirely sure if that's likely.
Thanks