从 CLI 运行时阻止 python GUI 程序退出
如何在 OS X 上轻松制作阻塞 GUI 应用程序?
我有一个简单的 python 绘图程序。当我从现有的 python 交互式会话内部或从 iPython 中运行它时,会显示 GUI 窗口,我可以看到它并与其交互。当我从 CLI 运行 .py
文件时,GUI 会闪烁并立即关闭。
我想从命令行运行它并保留 GUI。
if __name__ == "__main__":
import matplotlib
from matplotlib import pyplot
data = range(1,10)
fig = pyplot.plot(data)
pyplot.show()
How can easily I make a blocking GUI app on OS X?
I have a simple python plotting program. When I run it from inside an existing python interactive session, or from within iPython, the GUI window is displayed, and I can see it and interact with it. When I run the .py
file from the CLI, the GUI flashes and closes immediately.
I would like to run this from the command line and have the GUI remain.
if __name__ == "__main__":
import matplotlib
from matplotlib import pyplot
data = range(1,10)
fig = pyplot.plot(data)
pyplot.show()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来好像交互模式已以某种方式启用,尽管我不确定在哪里。试试这样:
It sounds as though interactive mode has been enabled somehow, although I'm not sure where. Try it like this: