Thus far I have been able to keep my Python projects contained within one source file. I am working on a project now that has a fairly lengthy user interface and I am considering taking the interface out of the main project file and placing it in a separate file to be imported into with the main project (to keep the file manageable, and because now its largely complete).
the structure of the project file at present is as follows:
[ include statements ]
[ subroutines ]
[ root window ]
[ main function() ]
[ user interface with global variables ]
[ root.mainloop() ]
I found out the hard way that I cannot declare global variables prior to calling the root window constructor.
Are there any other considerations I need to be aware of?
1. import statements are typically located at the top of the source code. Would I import my interface code with an import statement or via some other mechanism?
2. if yes, would I locate it at the top or where it is presently defined?
3. Can it be imported it as raw python source or do I need to compile it?
4. do I need to add the import statements at the top of the interface file or just import it after the import statements in the main file?
I know I'm asking a lot, I apologise in advance for the multi part question. The books and online resources I have found are either highly specific and technical or rudimentary "hello world" projects that discuss specific commands. This is somewhere in between.
the structure of the project file at present is as follows:
[ include statements ]
[ subroutines ]
[ root window ]
[ main function() ]
[ user interface with global variables ]
[ root.mainloop() ]
I found out the hard way that I cannot declare global variables prior to calling the root window constructor.
Are there any other considerations I need to be aware of?
1. import statements are typically located at the top of the source code. Would I import my interface code with an import statement or via some other mechanism?
2. if yes, would I locate it at the top or where it is presently defined?
3. Can it be imported it as raw python source or do I need to compile it?
4. do I need to add the import statements at the top of the interface file or just import it after the import statements in the main file?
I know I'm asking a lot, I apologise in advance for the multi part question. The books and online resources I have found are either highly specific and technical or rudimentary "hello world" projects that discuss specific commands. This is somewhere in between.
Statistics: Posted by ras_oscar — Mon Dec 11, 2023 8:54 pm