Merge code into one file

Asked by Megaqwerty

I was wondering if once I've finished writing all of the callbacks, if it is possible to merge them back into the main file; so I only have to deal with one .py file?
If so, how?

Thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
Gladex Edit question
Assignee:
No assignee Edit question
Solved by:
Christopher Pax
Solved:
Last query:
Last reply:
Revision history for this message
Best Christopher Pax (paxmanchris) said :
#1

sorry for taking so long to respond to your question. I have been away from my email for the past day.

I programed it to be separated because if the main py file ever had to be rewritten you can do it with out touching the callbacks file.

I would recommend to keep them separated.

but, you can do the fallowing to do what u want to do:
note: this was using python on a minimal style

1) look for the line in the main py (in my case example.py) file that would look like this if the glade file was example.glade

import example_callbacks as callbacks

2) replace with this:
import example as callbacks

3) now copy all the callbacks function into the main py file (example.py) and place at the bottom (including the init function).

this should work. if you have trouble doing this let me know and i will email the solution.

Revision history for this message
Megaqwerty (matthewb) said :
#2

Thanks, it works now. However, in addition to changing "import example_callbacks as callbacks", I also had to delete/comment out:
compile(os.path.split(__file__)[0]+"/"+"example_callbacks.py")

Thanks again.

Revision history for this message
Megaqwerty (matthewb) said :
#3

Thanks Christopher Pax, that solved my question.