We may be talking apples and oranges, but I am enjoying and learning from this conversation.
My definition of "main-line code" is the stuff between my $app = Wx::SimpleApp->new; and $app->MainLoop;.
Within this segment, the frame is created and the onPaint event handler is defined. onPaint is never called directly, but is called "asynchronously" from within the bowels of Wx. I moved the TakeScreenshot($self, $file); call to various places within the main-line and onPaint segments with various results. Usually only capturing the background window not the sample window.
The sample screen is drawn by a continuous block of code(within the onPaint event handler)immediately followed by TakeScreenshot. On my PC, the screen doesn't paint completely in one motion, but paints the three circles and the first block of text followed by a blink and the next two blocks of text. Given this, it is strange that some of the time a complete screen is captured to the file. Mostly only the three circles and first block of text gets captured. All the drawing code runs before the capture code is called, so the $64,000 question is why is only a partial screen being captured(most of the time)? As Spock would say, "illogical".