Patrick-
You don't happen to have any sample code lying around that illustrates the use of this recipe?
(Or anyone else for that matter)
thanks
matt
···
-----Original Message-----
From: Patrick K. O'Brien [mailto:pobrien@orbtech.com]
Sent: Tuesday, November 06, 2001 2:03 PM
To: wxPython-Users
Subject: [wxPython] MVC and event dispatching and such
In an attempt to come up with a Model-View-Controller style architecture for
some applications I'm developing, I developed a general mechanism for
dispatching signals between senders and receivers that I thought others
might find interesting. The code is not specific to wxPython, but could
certainly be used in a wxPython application. If you have an interest, I've
submitted the code to the Python Cookbook. You can find it here:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/87056
Any feedback would be appreciated. Thanks.
---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users
Hi Matthew,
the excerpts are from an application in which I update
- a wxListCtrl
- a wxGLCanvas
whenever the selection of a wxTreeCtrl changes. I simplified the code
for readability.
import dispatch
class DirectoryTree(wxScrolledWindow):
def __init__(self, parent, id):
self.tree = self.GetTreectrl()
# select is basically invoked after a EVT_TREE_SEL_CHANGED event.
def select(self, item_id):
cur_dir = self.tree.GetPyData(item_id)
# This object (self) sends the event that I named 'UpdateSelection'
# with the named parameter directory (think push-model) to all
# listeners.
dispatch.send("UpdateSelection", self, directory=cur_dir)
class FileSeekerFrame(wxFrame):
def __init__(self, parent, id, title)
self.directory_tree = DirectoryTree(parent, -1)
self.canvas = FSR_Canvas(parent, ID_GLCANVAS)
# connect two listeners (views) to the event 'UpdateSelection'
# that must be fired from the model self.directory_tree
dispatch.connect(self.update_selection, "UpdateSelection", self.directory_tree)
dispatch.connect(self.canvas.update_selection, "UpdateSelection", self.directory_tree)
def update_selection(self, directory):
listctrl = self.GetListctrl()
files = directory.get_files()
# now update the listctrl with 'directory'
class FSR_Canvas(wxGLCanvas):
def update_selection(self, directory):
files = directory.get_files()
# now draw OpenGL stuff with 'directory'
self.Refresh(0)
Good luck,
Michael
···
Patrick-
You don't happen to have any sample code lying around that illustrates the use of this recipe?
(Or anyone else for that matter)
--
- Michael Krause
- Email michael@krause-software.de
I have some really contrived stuff that I used for testing. But the
application I was going to use this with has become a lower priority, so I
don't have any really good examples. If you want, I could work up a few
examples. It really is pretty straightforward to use for most cases.
In what way did you imagine yourself using the dispatcher? What does your
application need?
P.S. I know of a few people who are using dispatcher. Hopefully someone will
chime in.
···
---
Patrick K. O'Brien
Orbtech.com - Your Source For Python Development Services
Phone: 314-963-3206
-----Original Message-----
From: wxpython-users-admin@lists.wxwindows.org
[mailto:wxpython-users-admin@lists.wxwindows.org]On Behalf Of Harrison,
Matthew
Sent: Wednesday, December 12, 2001 5:11 PM
To: wxpython-users@lists.wxwindows.org
Subject: RE: [wxPython] MVC and event dispatching and such
Patrick-
You don't happen to have any sample code lying around that
illustrates the use of this recipe?
(Or anyone else for that matter)
thanks
matt
-----Original Message-----
From: Patrick K. O'Brien [mailto:pobrien@orbtech.com]
Sent: Tuesday, November 06, 2001 2:03 PM
To: wxPython-Users
Subject: [wxPython] MVC and event dispatching and such
In an attempt to come up with a Model-View-Controller style
architecture for
some applications I'm developing, I developed a general mechanism for
dispatching signals between senders and receivers that I thought others
might find interesting. The code is not specific to wxPython, but could
certainly be used in a wxPython application. If you have an interest, I've
submitted the code to the Python Cookbook. You can find it here:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/87056
Any feedback would be appreciated. Thanks.
---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users