MVC Help

Sbaush sbaush at gmail.com
Tue Jan 17 07:06:10 EST 2006


Hi. I tried to understand the MVC architecture from a simple example: a
button.
The View must be only the clickable button
The Control must be the event listener on the button
The Model must be the action of the button.

this is a simple (working but NON MVC) button

from wxPython.wx import *

class MyApp(wxApp):
    def OnInit(self):
        dlg = wxDialog(None, -1, "")

        ID_BTN = wxNewId()

        btn = wxButton(dlg, ID_BTN, "Click HERE")
        EVT_BUTTON(self, ID_BTN, self.OnClick)

        dlg.ShowModal()
        dlg.Destroy()
        return 1

    def OnClick(self, event):

        wxMessageBox("Hello WORLD!!")

app = MyApp()
app.MainLoop()

I would have Model class, View class and Controller class that implement
this simple button.
The MVC must use Observer pattern. The code of observer.py is Python
translation of GOF Observer code.
I tried to do it, but this doesn't work (I can't use the Observer Pattern in
MVC...) . I attach my work. Could you look at my work and suggest me where
are my errors? Thanks all!

If we can complete this MVC simple implementation we could publish this like
a "MVC SIMPLE TUTORIAL" because with only a button this could explain the
MVC Observer based Architecture.

Thanks all.

--
Sbaush
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060117/064f8c27/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MVC.zip
Type: application/zip
Size: 3068 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20060117/064f8c27/attachment.zip>


More information about the Python-list mailing list