Data access from multiple code modules



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? 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? 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.


Best regards,

Simon Hibbs
(who strugles to get his head round this OOP stuff sometimes).

.



Relevant Pages

  • Re: Data access from multiple code modules
    ... How do I write code in gui.py that can access DataObject? ... GUI form, and panels defined as seperate objects in seperate files. ... or wherever data storage end up. ... and have the GUI part call on the controler. ...
    (comp.lang.python)
  • Re: Data access from multiple code modules
    ... database, and main.py creates an instance of this object. ... How do I write code in gui.py that can access DataObject? ... Actualy the problem is more complex because the GUI consists of a main ... or wherever data storage end up. ...
    (comp.lang.python)
  • Re: Affordable "file database"?
    ... it's only that Apple "forgot" to actually implement: ... a GUI for it, probably consisting of: ... a system-wide control panel to define the attributes ...
    (comp.sys.mac.apps)
  • GUIand callback in same .m file
    ... I have defined a GUI with consisting of a couple of radio buttons. ... I am trying to define the callback to the a Radio Buttons in the ...
    (comp.soft-sys.matlab)
  • GUI
    ... It would be great if anyone of you provide me the GUI example ... consisting of tank equation. ... It's urgent. ...
    (comp.soft-sys.matlab)