Standard way to open a folder window in linux?

前端 未结 3 1271
心在旅途
心在旅途 2021-02-20 14:19

I want to open a folder window, in the appropriate file manager, from within a cross-platform (windows/mac/linux) Python application.

On OSX, I can open a window in the

相关标签:
3条回答
  • 2021-02-20 14:56

    this would probably have to be done manually, or have as a config item since there are many file managers that users may want to use. Providing a way for command options as well.

    There might be an function that launches the defaults for kde or gnome in their respective toolkits but I haven't had reason to look for them.

    0 讨论(0)
  • 2021-02-20 15:11

    You're going to have to do this based on the running window manager. OSX and Windows have a (defacto) standard way because there is only one choice.

    You shouldn't need to specify the exact filemanager application, though, this should be possible to do through the wm. I know Gnome does, and it's important to do this in KDE since there are two possible file managers (Konqueror/Dolphin) that may be in use.

    I agree that this would be a good thing for freedesktop.org to standardize, although I doubt it will happen unless someone steps up and volunteers to do it.


    EDIT: I wasn't aware of xdg-open. Good to know!

    0 讨论(0)
  • 2021-02-20 15:21
    os.system('xdg-open "%s"' % foldername)
    

    xdg-open can be used for files/urls also

    0 讨论(0)
提交回复
热议问题