tkinter MVC

Eric Brunel eric.brunel at pragmadev.com
Tue Mar 27 08:14:26 EDT 2007


On Tue, 27 Mar 2007 13:29:25 +0200, Gigs_ <gigs at hi.t-com.hr> wrote:

> Can someone give me example how to write text editor in tkintter with  
> model-view-controler?
> What goes to controler and what goes to model?
>
> thanks in advance

Others may have a different opinion, but I think using MVC to do a text  
editor is a bit overkill. Basically, the only operation needed on the  
model are reading and writing of the file, so a basic Python file object  
will be OK. Considering that, and since the Tkinter Text widget is  
basically already a full-featured text editor, the controller part is also  
quite limited. You could do it however, but it would just be a matter of  
moving the methods called by the bindings to a secondary class. If what  
you're doing is just a text editor, it may not be worth the effort.

Having an MVC architecture for a text editor may be a good idea if the  
file objects have to interact with other objects at a "functional" level,  
i.e without any impact on the GUI. If what you're doing is only a text  
editor, i.e only managing text files, the advantages of such an  
architecture won't really show up...

My [$£€¥]0.02...
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"



More information about the Python-list mailing list