我想在 Gedit 中打开一个文本文件,使用 python tkinter
I want to open a Text file in Gedit, using python tkinter
我正在研究 linux 并使用 python tkinter,我想在 gedit 中打开一个文本文件,而不是在 cli 中打开它。
你可以试试webbrowser
:
import webbrowser
def open_file(file_name):
webbrowser.open(file_name)
这应该会在您的默认文本编辑器中打开上述文件(例如 windows 中的记事本或 linux 中的 gedit)。您可以在 GUI 中添加一个按钮并调用运行上述代码的函数。
我正在研究 linux 并使用 python tkinter,我想在 gedit 中打开一个文本文件,而不是在 cli 中打开它。
你可以试试webbrowser
:
import webbrowser
def open_file(file_name):
webbrowser.open(file_name)
这应该会在您的默认文本编辑器中打开上述文件(例如 windows 中的记事本或 linux 中的 gedit)。您可以在 GUI 中添加一个按钮并调用运行上述代码的函数。