This is part 4 of building a GIF viewer with python, wxPython widgets and building the GUI using wxFormBuilder.
In the last tutorial we added main loop code to the wxFormBuilder generated code. But this didn’t work because we have to sanitise or should I say clean thehad problems running the GIF viewer application because we have to sanitise and more code to fix it.
In this tutorial I explain:
- why you had to create three directories: descode, fb and src
- why the wxFormBuider generated python code doesn’t work when you try to run it with a python main loop
- what needs to be done to fix the generated code by creating a frameCleaner.py script
Here is the frameCleaner.py code:
srcFile = os.path.join(prjDir+'\descode',filename+'.py')
codein = f.read()
codein = codein.replace('\t',' ')
codein = codein.replace('m_','')
# ----- Save src code
outFile = os.path.join(prjDir+'\src',filename+'.py')
prjDir = r"C:\Python27\wxFormBuilder\fb-templates\gif-viewer"
filename = "gifviewer"
print 'Cleaning descode file: %s' % (filename+'.py')
outStat = cleanFrame(prjDir,filename)
print 'Clean descode file and save in src folder %s.' % (outStat)
If you have any questions or comments please post them on my YouTube video.
Next Tutorial: [Video] wxFormBuilder: Build a Python Gif Viewer – 5