diff --git a/IPython/frontend/qt/console/mainwindow.py b/IPython/frontend/qt/console/mainwindow.py index f8073cb4685..8a8cbf48de9 100644 --- a/IPython/frontend/qt/console/mainwindow.py +++ b/IPython/frontend/qt/console/mainwindow.py @@ -63,6 +63,7 @@ def __init__(self, app, """ super(MainWindow, self).__init__() + self._kernel_counter = 0 self._app = app self.confirm_exit = confirm_exit self.new_frontend_factory = new_frontend_factory @@ -96,6 +97,13 @@ def update_tab_bar_visibility(self): if self.tab_widget.count()==0 : self.close() + @property + def next_kernel_id(self): + """constantly increasing counter for kernel IDs""" + c = self._kernel_counter + self._kernel_counter += 1 + return c + @property def active_frontend(self): return self.tab_widget.currentWidget() @@ -115,7 +123,7 @@ def create_tab_with_current_kernel(self): # don't keep stacking slaves name = current_widget_name else: - name = str('('+current_widget_name+') slave') + name = '(%s) slave' % current_widget_name self.add_tab_with_frontend(widget,name=name) def close_tab(self,current_tab): @@ -231,7 +239,7 @@ def add_tab_with_frontend(self,frontend,name=None): """ if not name: - name=str('kernel '+str(self.tab_widget.count())) + name = 'kernel %i' % self.next_kernel_id self.tab_widget.addTab(frontend,name) self.update_tab_bar_visibility() self.make_frontend_visible(frontend)