从pygtk程序启动默认图像查看器 [英] Launch default image viewer from pygtk program
问题描述
我正在Ubuntu中编写一个PyGTK GUI应用程序以浏览一些图像,并且我希望在双击该图像时(例如在Nautilus中打开它时)在默认图像查看器应用程序中打开一个图像. br> 我该怎么办?
I'm writing a PyGTK GUI application in Ubuntu to browse some images, and I'd like to open an image in the default image viewer application when it is double-clicked (like when it is opened in Nautilus).
How can I do it?
推荐答案
我不知道具体使用PyGTK,但是:xdg-open
打开文件的默认应用程序,因此运行类似的东西应该可以:
I don't know specifically using PyGTK but: xdg-open
opens the default app for a file so running something like this should work:
import os
os.system('xdg-open ./img.jpg')
编辑:我建议像注释中那样使用subprocess
模块.我不确定确切如何使用它,因此在示例中仅使用os.system
来显示xdg-open
.
I'd suggest using the subprocess
module as in the comments. I'm not sure exactly how to use it yet so I just used os.system
in the example to show xdg-open
.
这篇关于从pygtk程序启动默认图像查看器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!