Advice on this code
sjmaster at gmail.com
Thu Oct 13 01:10:59 CEST 2005
First of all, this program is very hard to understand to somebody who
hasn't written it. ALthough I've never heard of Quote Vista so maybe
that's the problem.
Anyway, if you want to integrate the first program with the second GUI
program, you should convert the first program into a set of functions
that can be called to do everything the first program does.
So basically, take the first program and put everything that's not
already in a function into one. That is, all the code that is at zero
indentation, starting with creating the oConn connection, should be
moved into functions. You can also write a big-mama function that calls
those functions in such a way that it would have the exact same overall
effect as the original script before you moved the code into functions.
You can call this big-mama function 'main'.
Now you can integrate it with the GUI program by importing the first
module from the GUI program and binding the functions to the
appropriate buttons. For example you could bind main to the Start
button you described.
Also, in the first file, you can put the following lines at the bottom,
and it will allow you to run the original script directly to achieve
the same result, while still being able to import it into a second
program and re-use just the functions.
if __name__ == '__main__':
More information about the Python-list