GPS 插件中的上下文

Context in GPS Plugin

我使用

在工具栏中创建了一个按钮
GPS.Toolbar().append(button)

在按钮的 On_Click 功能中,我希望它打印当前文件的名称。

我写了print GPS.Current_Context().file() 但它不起作用并给我错误:Current_Context has no attribute file

有人知道为什么吗?

使用EditorBuffer获取当前视图的名称:

EditorBuffer.get().current_view().title()

这将为您提供当前编辑器选项卡的标题,即已编辑文件的名称。