[EMAIL PROTECTED] wrote: > Lets say that I have an application consisting of 3 files. A main.py > file, gui.py and a data.py which handles persistent data storage. > Suppose data.py defines a class 'MyDB' which reads in data from a > database, and main.py creates an instance of this object. How does code > in gui.py access this object?
Obviously, you need to pass whatever relevant to this code... > Here's simplified pseudocode: > > MAIN.PY > import gui, data > DataObject = data.MyDB(blah) > > How do I write code in gui.py that can access DataObject? Passing DataObject to code in guy.py seems like a very straightforward solution... > Is this > entirely the wrong way to approach this sort of problem? > Actualy the problem is more complex because the GUI consists of a main > GUI form, and panels defined as seperate objects in seperate files. > Various panels will contain controlls for manipulating data in the > DataObject, or wherever data storage end up. Hmmm... Hard to tell without seeing the code (and I've not done GUI programmer for a long time), but putting application logic in the GUI is usually a bad idea IME. Better to put the application logic in a separate controler (that has a reference to the model -> here your DataObject), and have the GUI part call on the controler. > > Best regards, > > Simon Hibbs > (who strugles to get his head round this OOP stuff sometimes). Well, actually one can do MVC without OO. It's more a matter of separating concerns. Now I agree that it's not always obvious to know for sure which part should be responsible for what... -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list