23

I need a basic example where MVC pattern is used with Python TK. I have some code using Tkinter, however I would like to transform it using the MVC pattern.

user618677
  • 4,909
  • 6
  • 23
  • 24

2 Answers2

25

I know this is quite old but I was able to find some decent examples using the MVC pattern with both Tk and wxPython, hopefully they provide some help for anyone stumbling upon this question.

wxPython: http://wiki.wxpython.org/ModelViewController

Tk: http://tkinter.unpythonic.net/wiki/ToyMVC This website no longer exists so I've hosted the code on a Gist here.

ajfigueroa
  • 597
  • 7
  • 16
  • 2
    I'm afraid your second link does't work anymore. Maybe you should delete it or re-write it if you know a new location – madtyn Sep 29 '17 at 08:35
  • 2
    @madtyn I found the archive.org cache version, I've rehosted it on Gist. Let me know if that's ok? Otherwise, I'll just write the whole thing out. – ajfigueroa Sep 29 '17 at 15:32
6

Here's an interesting example: https://sukhbinder.wordpress.com/2014/12/25/an-example-of-model-view-controller-design-pattern-with-tkinter-python/

I would also recommend this book where the author goes through how to structure your Tkinter application in a model-view way: https://www.packtpub.com/application-development/tkinter-gui-application-development-hotshot

Andreas Bergström
  • 13,891
  • 5
  • 59
  • 53