如何制作可选的 tkinter GUI?
我有一个 tkinter GUI 代码,它执行映射到不同按钮/小部件的不同功能,我想为用户提供选择打开 GUI 窗口或直接从命令行执行的选项。
我尝试将 mainloop() 保留在可选开关内,例如:
if gui == "1":
root.mainloop()
else:
#command mode
# call required functions here using user switches.
这是执行此操作的正确方法吗?当我在linux系统中尝试时,这是有效的。
I have a tkinter GUI code that executes different functions which are mapped to different buttons/widgets, I want to give users the option of choosing to open the GUI window or directly execute from the command line.
I tried keeping mainloop() inside an optional switch like:
if gui == "1":
root.mainloop()
else:
#command mode
# call required functions here using user switches.
Is this the correct way of doing this? this is working when i tried in linux system.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我的示例,请注意我如何将
root.mainloop()
放在最后缩进,因为它在 if 语句中
that was my example notice how I put
root.mainloop()
at the endwas indented because it was in a if statement