[Video] wxFormBuilder: Build a Python Gif Viewer – 4
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# frameCleaner.py import os def cleanFrame(prjDir,filename): srcFile = os.path.join(prjDir+'\descode',filename+'.py') f=open(srcFile,'r') codein = f.read() codein = codein.replace('\t',' ') codein = codein.replace('m_','') f.close() # ----- Save src code outFile = os.path.join(prjDir+'\src',filename+'.py') f=open(outFile,'w') f.write(codein) f.close() return 'complete' 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