##// END OF EJS Templates
decamelcasify: a few more
Matthias BUSSONNIER -
Show More
@@ -120,7 +120,7 b' class MainWindow(QtGui.QMainWindow):'
120 def active_frontend(self):
120 def active_frontend(self):
121 return self.tab_widget.currentWidget()
121 return self.tab_widget.currentWidget()
122
122
123 def close_tab(self,currentTab):
123 def close_tab(self,current_tab):
124 """ Called when you need to try to close a tab.
124 """ Called when you need to try to close a tab.
125
125
126 It takes the number of the tab to be closed as argument, or a referece
126 It takes the number of the tab to be closed as argument, or a referece
@@ -129,9 +129,9 b' class MainWindow(QtGui.QMainWindow):'
129
129
130 # let's be sure "tab" and "closing widget are respectivey the index of the tab to close
130 # let's be sure "tab" and "closing widget are respectivey the index of the tab to close
131 # and a reference to the trontend to close
131 # and a reference to the trontend to close
132 if type(currentTab) is not int :
132 if type(current_tab) is not int :
133 currentTab = self.tab_widget.indexOf(currentTab)
133 current_tab = self.tab_widget.indexOf(current_tab)
134 closing_widget=self.tab_widget.widget(currentTab)
134 closing_widget=self.tab_widget.widget(current_tab)
135
135
136
136
137 # when trying to be closed, widget might re-send a request to be closed again, but will
137 # when trying to be closed, widget might re-send a request to be closed again, but will
@@ -142,7 +142,7 b' class MainWindow(QtGui.QMainWindow):'
142 return
142 return
143
143
144 #get a list of all wwidget not owning the kernel.
144 #get a list of all wwidget not owning the kernel.
145 slaveTabs=self.findSlavesTabs(closing_widget)
145 slave_tabs=self.findSlavesTabs(closing_widget)
146
146
147 keepkernel = None #Use the prompt by default
147 keepkernel = None #Use the prompt by default
148 if hasattr(closing_widget,'_keep_kernel_on_exit'): #set by exit magic
148 if hasattr(closing_widget,'_keep_kernel_on_exit'): #set by exit magic
@@ -152,14 +152,14 b' class MainWindow(QtGui.QMainWindow):'
152 # restart when they litt get the signal. and the "forward" the 'exit'
152 # restart when they litt get the signal. and the "forward" the 'exit'
153 # to the main win
153 # to the main win
154 if keepkernel is not None:
154 if keepkernel is not None:
155 for tab in slaveTabs:
155 for tab in slave_tabs:
156 tab._hidden = True
156 tab._hidden = True
157 if closing_widget in slaveTabs :
157 if closing_widget in slave_tabs :
158 try :
158 try :
159 self.findMasterTab(closing_widget).execute('exit')
159 self.find_master_tab(closing_widget).execute('exit')
160 except AttributeError:
160 except AttributeError:
161 self.log.info("Master already closed or not local, closing only current tab")
161 self.log.info("Master already closed or not local, closing only current tab")
162 self.tab_widget.removeTab(currentTab)
162 self.tab_widget.removeTab(current_tab)
163 return
163 return
164
164
165 kernel_manager = closing_widget.kernel_manager
165 kernel_manager = closing_widget.kernel_manager
@@ -175,7 +175,7 b' class MainWindow(QtGui.QMainWindow):'
175 cancel = QtGui.QMessageBox.Cancel
175 cancel = QtGui.QMessageBox.Cancel
176 okay = QtGui.QMessageBox.Ok
176 okay = QtGui.QMessageBox.Ok
177 if closing_widget._may_close:
177 if closing_widget._may_close:
178 msg = "You are closing the tab : "+'"'+self.tab_widget.tabText(currentTab)+'"'
178 msg = "You are closing the tab : "+'"'+self.tab_widget.tabText(current_tab)+'"'
179 info = "Would you like to quit the Kernel and all attached Consoles as well?"
179 info = "Would you like to quit the Kernel and all attached Consoles as well?"
180 justthis = QtGui.QPushButton("&No, just this Console", self)
180 justthis = QtGui.QPushButton("&No, just this Console", self)
181 justthis.setShortcut('N')
181 justthis.setShortcut('N')
@@ -194,10 +194,10 b' class MainWindow(QtGui.QMainWindow):'
194 box.setIconPixmap(scaledpixmap)
194 box.setIconPixmap(scaledpixmap)
195 reply = box.exec_()
195 reply = box.exec_()
196 if reply == 1: # close All
196 if reply == 1: # close All
197 for slave in slaveTabs:
197 for slave in slave_tabs:
198 self.tab_widget.removeTab(self.tab_widget.indexOf(slave))
198 self.tab_widget.removeTab(self.tab_widget.indexOf(slave))
199 closing_widget.execute("exit")
199 closing_widget.execute("exit")
200 self.tab_widget.removeTab(currentTab)
200 self.tab_widget.removeTab(current_tab)
201 elif reply == 0: # close Console
201 elif reply == 0: # close Console
202 if not closing_widget._existing:
202 if not closing_widget._existing:
203 # Have kernel: don't quit, just close the window
203 # Have kernel: don't quit, just close the window
@@ -211,21 +211,21 b' class MainWindow(QtGui.QMainWindow):'
211 defaultButton=okay
211 defaultButton=okay
212 )
212 )
213 if reply == okay:
213 if reply == okay:
214 self.tab_widget.removeTab(currentTab)
214 self.tab_widget.removeTab(current_tab)
215 elif keepkernel: #close console but leave kernel running (no prompt)
215 elif keepkernel: #close console but leave kernel running (no prompt)
216 if kernel_manager and kernel_manager.channels_running:
216 if kernel_manager and kernel_manager.channels_running:
217 if not closing_widget._existing:
217 if not closing_widget._existing:
218 # I have the kernel: don't quit, just close the window
218 # I have the kernel: don't quit, just close the window
219 self.tab_widget.removeTab(currentTab)
219 self.tab_widget.removeTab(current_tab)
220 else: #close console and kernel (no prompt)
220 else: #close console and kernel (no prompt)
221 if kernel_manager and kernel_manager.channels_running:
221 if kernel_manager and kernel_manager.channels_running:
222 for slave in slaveTabs:
222 for slave in slave_tabs:
223 self.tab_widget.removeTab(self.tab_widget.indexOf(slave))
223 self.tab_widget.removeTab(self.tab_widget.indexOf(slave))
224 self.tab_widget.removeTab(currentTab)
224 self.tab_widget.removeTab(current_tab)
225 kernel_manager.shutdown_kernel()
225 kernel_manager.shutdown_kernel()
226 self.update_tab_bar_visibility()
226 self.update_tab_bar_visibility()
227
227
228 def addTabWithFrontend(self,frontend,name=None):
228 def add_tab_with_frontend(self,frontend,name=None):
229 """ insert a tab with a given frontend in the tab bar, and give it a name
229 """ insert a tab with a given frontend in the tab bar, and give it a name
230
230
231 """
231 """
@@ -233,7 +233,7 b' class MainWindow(QtGui.QMainWindow):'
233 name=str('kernel '+str(self.tab_widget.count()))
233 name=str('kernel '+str(self.tab_widget.count()))
234 self.tab_widget.addTab(frontend,name)
234 self.tab_widget.addTab(frontend,name)
235 self.update_tab_bar_visibility()
235 self.update_tab_bar_visibility()
236 self.makeFrontendVisible(frontend)
236 self.make_frontend_visible(frontend)
237 frontend.exit_requested.connect(self.close_tab)
237 frontend.exit_requested.connect(self.close_tab)
238
238
239 def next_tab(self):
239 def next_tab(self):
@@ -242,12 +242,12 b' class MainWindow(QtGui.QMainWindow):'
242 def prev_tab(self):
242 def prev_tab(self):
243 self.tab_widget.setCurrentIndex((self.tab_widget.currentIndex()-1))
243 self.tab_widget.setCurrentIndex((self.tab_widget.currentIndex()-1))
244
244
245 def makeFrontendVisible(self,frontend):
245 def make_frontend_visible(self,frontend):
246 widgetIndex=self.tab_widget.indexOf(frontend)
246 widgetIndex=self.tab_widget.indexOf(frontend)
247 if widgetIndex > 0 :
247 if widgetIndex > 0 :
248 self.tab_widget.setCurrentIndex(widgetIndex)
248 self.tab_widget.setCurrentIndex(widgetIndex)
249
249
250 def findMasterTab(self,tab,asList=False):
250 def find_master_tab(self,tab,asList=False):
251 """
251 """
252 Try to return the frontend that own the kernel attached to the given widget/tab.
252 Try to return the frontend that own the kernel attached to the given widget/tab.
253
253
@@ -315,7 +315,7 b' class MainWindow(QtGui.QMainWindow):'
315 widget.kernel_manager.hb_address == km.hb_address)
315 widget.kernel_manager.hb_address == km.hb_address)
316 # Get a list of all widget owning the same kernel and removed it from
316 # Get a list of all widget owning the same kernel and removed it from
317 # the previous cadidate. (better using sets ?)
317 # the previous cadidate. (better using sets ?)
318 masterWidgetlist = self.findMasterTab(tab,asList=True)
318 masterWidgetlist = self.find_master_tab(tab,asList=True)
319 slaveList = [widget for widget in filtredWidgetList if widget not in masterWidgetlist]
319 slaveList = [widget for widget in filtredWidgetList if widget not in masterWidgetlist]
320
320
321 return slaveList
321 return slaveList
@@ -833,7 +833,7 b' class IPythonQtConsoleApp(BaseIPythonApplication):'
833 self.kernel_manager.write_connection_file()
833 self.kernel_manager.write_connection_file()
834 self.kernel_manager.start_channels()
834 self.kernel_manager.start_channels()
835
835
836 def createTabWithNewFrontend(self):
836 def create_tab_with_new_frontend(self):
837 """ Create new tab attached to new kernel, launched on localhost.
837 """ Create new tab attached to new kernel, launched on localhost.
838 """
838 """
839 kernel_manager = QtKernelManager(
839 kernel_manager = QtKernelManager(
@@ -855,9 +855,9 b' class IPythonQtConsoleApp(BaseIPythonApplication):'
855 widget._existing=False;
855 widget._existing=False;
856 widget._confirm_exit=True;
856 widget._confirm_exit=True;
857 widget._may_close=True;
857 widget._may_close=True;
858 self.window.addTabWithFrontend(widget)
858 self.window.add_tab_with_frontend(widget)
859
859
860 def createTabAttachedToCurrentTabKernel(self):
860 def create_tab_attached_to_current_tab_kernel(self):
861 currentWidget = self.window.tab_widget.currentWidget()
861 currentWidget = self.window.tab_widget.currentWidget()
862 currentWidgetIndex = self.window.tab_widget.indexOf(currentWidget)
862 currentWidgetIndex = self.window.tab_widget.indexOf(currentWidget)
863 currentWidget.kernel_manager = currentWidget.kernel_manager;
863 currentWidget.kernel_manager = currentWidget.kernel_manager;
@@ -876,7 +876,7 b' class IPythonQtConsoleApp(BaseIPythonApplication):'
876 widget._confirm_exit=True;
876 widget._confirm_exit=True;
877 widget._may_close=False;
877 widget._may_close=False;
878 widget.kernel_manager = kernel_manager
878 widget.kernel_manager = kernel_manager
879 self.window.addTabWithFrontend(widget,name=str('('+currentWidgetName+') slave'))
879 self.window.add_tab_with_frontend(widget,name=str('('+currentWidgetName+') slave'))
880
880
881 def init_qt_elements(self):
881 def init_qt_elements(self):
882 # Create the widget.
882 # Create the widget.
@@ -897,7 +897,7 b' class IPythonQtConsoleApp(BaseIPythonApplication):'
897 may_close=local_kernel,
897 may_close=local_kernel,
898 confirm_exit=self.confirm_exit)
898 confirm_exit=self.confirm_exit)
899 self.window.log = self.log
899 self.window.log = self.log
900 self.window.addTabWithFrontend(self.widget)
900 self.window.add_tab_with_frontend(self.widget)
901 self.window.initMenuBar()
901 self.window.initMenuBar()
902 self.window.setWindowTitle('Python' if self.pure else 'IPython')
902 self.window.setWindowTitle('Python' if self.pure else 'IPython')
903
903
@@ -997,12 +997,12 b' class IPythonQtConsoleApp(BaseIPythonApplication):'
997 self.tabAndNewKernelAct =QtGui.QAction("Tab with &New kernel",
997 self.tabAndNewKernelAct =QtGui.QAction("Tab with &New kernel",
998 self.window,
998 self.window,
999 shortcut="Ctrl+T",
999 shortcut="Ctrl+T",
1000 triggered=self.createTabWithNewFrontend)
1000 triggered=self.create_tab_with_new_frontend)
1001 self.window.windowMenu.addAction(self.tabAndNewKernelAct)
1001 self.window.windowMenu.addAction(self.tabAndNewKernelAct)
1002 self.tabSameKernalAct =QtGui.QAction("Tab with Sa&me kernel",
1002 self.tabSameKernalAct =QtGui.QAction("Tab with Sa&me kernel",
1003 self.window,
1003 self.window,
1004 shortcut="Ctrl+Shift+T",
1004 shortcut="Ctrl+Shift+T",
1005 triggered=self.createTabAttachedToCurrentTabKernel)
1005 triggered=self.create_tab_attached_to_current_tab_kernel)
1006 self.window.windowMenu.addAction(self.tabSameKernalAct)
1006 self.window.windowMenu.addAction(self.tabSameKernalAct)
1007 self.window.windowMenu.addSeparator()
1007 self.window.windowMenu.addSeparator()
1008
1008
General Comments 0
You need to be logged in to leave comments. Login now