Beispiel #1
0
    def destroy(self):
        """Destroy panel.  """

        self.removeCallback()
        if self.is_dialog:
            nuke.thisPane().destroy()
        super(PythonPanel, self).destroy()
Beispiel #2
0
 def addToPane(self, pane=None):
     self.create()
     if pane != None:
         pane.add(self)
     elif nuke.thisPane() != None:
         nuke.thisPane().add(self)
     self.addCallback()
     return self
Beispiel #3
0
def add_to_pane():
    """Add or move PythonEditor to the current or default pane. Only
    one instance of the PythonEditor widget is allowed at a time.

    BUG: This now seems to disagree greatly with the "Reload Package"
    feature, causing many a segfault.
    """
    # nuke-specific imports in here so that PythonEditor works outside of nuke.
    import nuke
    from nukescripts.panels import __panels

    # is the active pane one of the ones we want to add Python Editor to?
    candidates = ['Viewer.1', 'Properties.1', 'DAG.1']

    for tab_name in candidates:
        dock = nuke.getPaneFor(tab_name)
        if dock is None:
            continue
        break
    else:
        # no "break"? use thisPane
        dock = nuke.thisPane()

    import PythonEditor
    try:
        # if the panel exists already, it's
        # likely the user is trying to move it.
        ide = PythonEditor.__dock
        ide.addToPane(dock)
    except AttributeError:
        nuke_panel = __panels.get(PANEL_NAME).__call__(pane=dock)
Beispiel #4
0
def add_to_pane():
    """
    Locates a panel and adds it to one
    of the main dock windows in order
    of preference.

    BUG: This now seems to disagree greatly with the "Reload Package"
    feature, causing many segfault.
    """
    ui_state = capture_ui_state()
    if focus_on_panel(ui_state):
        # the Python Editor tab exists, switch to it. (this should ideally be in focus_on_panel)
        for tabbar in QtWidgets.QApplication.instance().allWidgets():
            if isinstance(tabbar, QtWidgets.QTabBar):
                for i in range(tabbar.count()):
                    if tabbar.tabText(i) == 'Python Editor':
                        if tabbar.currentIndex() != i:
                            tabbar.setCurrentIndex(i)
                        break
        return

    import nuke
    from nukescripts import panels
    found = False

    # is the active pane one of the ones we want to add Python Editor to?
    dock = nuke.thisPane()
    candidates = ['Properties.1', 'Viewer.1', 'DAG.1']

    for tab_name in candidates:
        pane = nuke.getPaneFor(tab_name)
        if pane is not None:
            dock = pane  # to set order of preference
            break  # the current pane was a candidate. done!

    # this will create the PythonEditor panel and add it to the active pane
    nuke_panel = panels.__panels.get(PANEL_NAME).__call__(pane=dock)
 def addToPane(self):
     nukescripts.PythonPanel.addToPane(self, pane=nuke.thisPane())