如何在Tkinter中实现MVC模式

23 投票
2 回答
28904 浏览
提问于 2025-04-17 03:36

我需要一个简单的例子,展示如何在Python的TK中使用MVC模式。我有一些使用Tkinter的代码,但我想把它转换成MVC模式。

2 个回答

6

这里有一个有趣的例子:

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

我还推荐这本书,作者讲解了如何用模型-视图的方式来构建你的Tkinter应用:

https://www.packtpub.com/application-development/tkinter-gui-application-development-hotshot

25

我知道这个问题已经有点老了,但我找到了一些不错的例子,展示了如何在Tk和wxPython中使用MVC模式。希望这些能对遇到这个问题的人有所帮助。

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

Tk: http://tkinter.unpythonic.net/wiki/ToyMVC 这个网站已经不存在了,所以我把代码放在了一个Gist上,链接在这里

撰写回答