Creating a gui around a python script using Tkinter

心已入冬 提交于 2019-12-20 07:36:02

问题


I have an existing python script and I want to wrap it in a GUI. Since I already have tkinter installed I would like to use it if possible. At the moment my script has many places where it asks for user input using raw_input(). I would like to replace these with either a modal pop-up asking for user input or (preferably) an Entry object which responds to the enter key.


回答1:


UI toolkits usually have an event-driven model where the main loop is in the toolkit itself. This is probably different from your current synchronous, interactive model (where the program just pauses while waiting for input)

The best would be to try to refactor your program and factor-out the view part (look up the model-view-control design pattern). After that, it should be easy to replace your console oriented view with an tkInter based one.

(that's as specific as I can get without a concrete question)



来源:https://stackoverflow.com/questions/3589817/creating-a-gui-around-a-python-script-using-tkinter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!