- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我为 sublime text 3
开发插件。并想获取当前打开的文件路径...
absolute1 = self.window.view.file_name()
... self
是 sublime_plugin.WindowCommand
但失败了:
AttributeError: 'Window' object has no attribute 'view'
插件完整代码:
import sublime, sublime_plugin
import re, os, os.path
class OpenrelCommand(sublime_plugin.WindowCommand):
def run(self):
relative = sublime.get_clipboard()
absolute1 = self.window.view.file_name()
absolute2 = os.path.normpath(os.path.join(os.path.dirname(absolute1), relative))
self.window.open_file(absolute2)
def is_enabled(self):
return bool(sublime.get_clipboard().strip())
如果 self
是 sublime_plugin.TextCommand
我可以毫无问题地获取当前文件路径:
fileName = self.view.file_name()
... 但是 self
必须是 sublime_plugin.WindowCommand
因为我想使用方法 open_file
:
self.window.open_file(absolute2)
最佳答案
对于 Sublime Text 3,对我有用的命令是:
self.view.window().active_view().file_name()
关于python - 从 sublime_plugin.WindowCommand 获取当前文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19524926/
我为 sublime text 3 开发插件。并想获取当前打开的文件路径... absolute1 = self.window.view.file_name() ... self 是 sublime_
我为sublime text 3创建了一个插件,设计的Command Palette.sublime-commands如下: [ { "caption": "Function 1",
我使用 3 个命令为 sublime text 3 创建了插件:其中 2 个是 TextCommand 类型,其中一个是 WindowCommand import sublime, sublime_p
手动添加按钮作为窗口命令时,分隔符正常显示: 尝试使用 ItemsControl 在 XAML 中动态创建按钮作为窗口命令时,我无法正确显示
我是一名优秀的程序员,十分优秀!