The demo code is part of the wxPython demo application. Therefore it uses wrapped code to fit into that “framework”.
Look here on how you might adapt a single demo source to run independently from the main demo app.
https://wiki.wxpython.org/Using%20wxPython%20Demo%20Code
You should also be better off when downloading the demo - see topic Demo Application.
Then run:
<YourLocalPythonRootDir>/Lib/site-packages/wxPython-demo/demo.pyw