def close_tab(self,current_tab):
<EOL>if type(current_tab) is not int :<EOL><INDENT>current_tab = self.tab_widget.indexOf(current_tab)<EOL><DEDENT>closing_widget=self.tab_widget.widget(current_tab)<EOL>if closing_widget==None:<EOL><INDENT>return<EOL><DEDENT>slave_tabs = self.find_slave_widgets(closing_widget)<EOL>keepkernel = None <EOL>if hasattr(closing_widget,'<STR_LIT>'): <EOL><INDENT>keepkernel = closing_widget._keep_kernel_on_exit<EOL>if keepkernel is not None:<EOL><INDENT>for tab in slave_tabs:<EOL><INDENT>tab._hidden = True<EOL><DEDENT>if closing_widget in slave_tabs:<EOL><INDENT>try :<EOL><INDENT>self.find_master_tab(closing_widget).execute('<STR_LIT>')<EOL><DEDENT>except AttributeError:<EOL><INDENT>self.log.info("<STR_LIT>")<EOL>self.tab_widget.removeTab(current_tab)<EOL><DEDENT>self.update_tab_bar_visibility()<EOL>return<EOL><DEDENT><DEDENT><DEDENT>kernel_manager = closing_widget.kernel_manager<EOL>if keepkernel is None and not closing_widget._confirm_exit:<EOL><INDENT>keepkernel = closing_widget._existing<EOL><DEDENT>if keepkernel is None: <EOL><INDENT>if kernel_manager and kernel_manager.channels_running:<EOL><INDENT>title = self.window().windowTitle()<EOL>cancel = QtGui.QMessageBox.Cancel<EOL>okay = QtGui.QMessageBox.Ok<EOL>if closing_widget._may_close:<EOL><INDENT>msg = "<STR_LIT>"+'<STR_LIT:">'+self.tab_widget.tabText(current_tab)+'<STR_LIT:">'<EOL>info = "<STR_LIT>"<EOL>justthis = QtGui.QPushButton("<STR_LIT>", self)<EOL>justthis.setShortcut('<STR_LIT:N>')<EOL>closeall = QtGui.QPushButton("<STR_LIT>", self)<EOL>closeall.setShortcut('<STR_LIT:Y>')<EOL>closeall.setShortcut('<STR_LIT>')<EOL>box = QtGui.QMessageBox(QtGui.QMessageBox.Question,<EOL>title, msg)<EOL>box.setInformativeText(info)<EOL>box.addButton(cancel)<EOL>box.addButton(justthis, QtGui.QMessageBox.NoRole)<EOL>box.addButton(closeall, QtGui.QMessageBox.YesRole)<EOL>box.setDefaultButton(closeall)<EOL>box.setEscapeButton(cancel)<EOL>pixmap = QtGui.QPixmap(self._app.icon.pixmap(QtCore.QSize(<NUM_LIT:64>,<NUM_LIT:64>)))<EOL>box.setIconPixmap(pixmap)<EOL>reply = box.exec_()<EOL>if reply == <NUM_LIT:1>: <EOL><INDENT>for slave in slave_tabs:<EOL><INDENT>background(slave.kernel_manager.stop_channels)<EOL>self.tab_widget.removeTab(self.tab_widget.indexOf(slave))<EOL><DEDENT>closing_widget.execute("<STR_LIT>")<EOL>self.tab_widget.removeTab(current_tab)<EOL>background(kernel_manager.stop_channels)<EOL><DEDENT>elif reply == <NUM_LIT:0>: <EOL><INDENT>if not closing_widget._existing:<EOL><INDENT>closing_widget.execute("<STR_LIT>")<EOL><DEDENT>self.tab_widget.removeTab(current_tab)<EOL>background(kernel_manager.stop_channels)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>reply = QtGui.QMessageBox.question(self, title,<EOL>"<STR_LIT>"+<EOL>"<STR_LIT>",<EOL>okay|cancel,<EOL>defaultButton=okay<EOL>)<EOL>if reply == okay:<EOL><INDENT>self.tab_widget.removeTab(current_tab)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>elif keepkernel: <EOL><INDENT>self.tab_widget.removeTab(current_tab)<EOL>background(kernel_manager.stop_channels)<EOL><DEDENT>else: <EOL><INDENT>self.tab_widget.removeTab(current_tab)<EOL>if kernel_manager and kernel_manager.channels_running:<EOL><INDENT>for slave in slave_tabs:<EOL><INDENT>background(slave.kernel_manager.stop_channels)<EOL>self.tab_widget.removeTab(self.tab_widget.indexOf(slave))<EOL><DEDENT>kernel_manager.shutdown_kernel()<EOL>background(kernel_manager.stop_channels)<EOL><DEDENT><DEDENT>self.update_tab_bar_visibility()<EOL>
Called when you need to try to close a tab.

        It takes the number of the tab to be closed as argument, or a reference
        to the widget inside this tab