Hi,
At the risk of hijacking this thread, I want to ask a similar question for an app I'm working on. I think the issue is very similar.
I have a working version that currently consists of a back end that accepts observers.
I have a working front end in pygtk that receives events from the backend in an update function. In turn it also implements observable, and the backend observes it to receive input from the UI.
The two are linked through a short program that instantiates both and signs them up as observers to each other.
This works surprisingly well.
Except that it's in pygtk, which is pretty limited. And besides one of the points of keeping things so separate was so that I could slap whatever frontend on there I wanted to.
So I have been trying to do the same thing with wxPython. The UI again has an update method. It receives events from the observable. It functions for a while and then locks up. The update method is fairly simple:
def update (self, observable, **kwargs):
info = observable.get_all_data()
#blah blah blah - deal with kwargs, etc
self. text_ctrl.WriteText(blah)
Currently, the short program that starts both frontend and backend looks like this:
----------------------------------------------------->8
#!/usr/bin/python
# author mwt
# Mar '06
import fahmodel, fah_mainframe, fahdata, time, gtk, os.path
import wxtest, wx
def main():
gtk.gdk.threads_init()
CUR_DIR = os.path.dirname(__file__)
INI_DIR = os.path.join(CUR_DIR, 'fah.ini')
fah = fahmodel.FAHModel(INI_DIR)
app = wx.App()
fah_m = wxtest.Main_Frame(None, title=" Monitor") #this is a test version of the wxPy UI
#fah.addObserver(fah_m)
fah.fahdata.addObserver(fah_m)
#fah_m.addObserver(fah)
#fah_m.main()
fah_m.Show()
app.MainLoop()
if __name__ == "__main__":
main()
----------------------------------------------------->8
I'm sure I'm doing something basically messed up here. I would like to keep the two sections of the program completely separate from each other, however, and only have them communicate to each other through notification. Can anybody help me straighten this out?
Thanks.
M.
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org