Sublime Forum

Detect whether panel is open/closed

#1

How can I detect programmatically, whether a panel is open/visible or closed/hidden?

The following doesn’t work, it never opens a panel

def run(self):
    panels = self.window.panels()

    if "console" in panels:
        self.window.run_command("hide_panel", {"panel": "console"})
    else:
        self.window.run_command("show_panel", {"panel": "console"})
0 Likes

How to detect whether some quick panel is open as the Command Palette is open?
#2

I think what you’re looking for is this:

*window.active_panel*()
  Returns: str or None

    Returns the name of the currently open panel, or `None` if no panel is
    open. Will return built-in panel names (e.g. `"console"`, `"find"`, etc) in
    addition to output panels.
1 Like