##// END OF EJS Templates
Remove kernel alias from Qt console...
Thomas Kluyver -
Show More
@@ -1,379 +1,377 b''
1 """ A minimal application using the Qt console-style IPython frontend.
1 """ A minimal application using the Qt console-style IPython frontend.
2
2
3 This is not a complete console app, as subprocess will not be able to receive
3 This is not a complete console app, as subprocess will not be able to receive
4 input, there is no real readline support, among other limitations.
4 input, there is no real readline support, among other limitations.
5 """
5 """
6
6
7 # Copyright (c) IPython Development Team.
7 # Copyright (c) IPython Development Team.
8 # Distributed under the terms of the Modified BSD License.
8 # Distributed under the terms of the Modified BSD License.
9
9
10 import os
10 import os
11 import signal
11 import signal
12 import sys
12 import sys
13
13
14 # If run on Windows, install an exception hook which pops up a
14 # If run on Windows, install an exception hook which pops up a
15 # message box. Pythonw.exe hides the console, so without this
15 # message box. Pythonw.exe hides the console, so without this
16 # the application silently fails to load.
16 # the application silently fails to load.
17 #
17 #
18 # We always install this handler, because the expectation is for
18 # We always install this handler, because the expectation is for
19 # qtconsole to bring up a GUI even if called from the console.
19 # qtconsole to bring up a GUI even if called from the console.
20 # The old handler is called, so the exception is printed as well.
20 # The old handler is called, so the exception is printed as well.
21 # If desired, check for pythonw with an additional condition
21 # If desired, check for pythonw with an additional condition
22 # (sys.executable.lower().find('pythonw.exe') >= 0).
22 # (sys.executable.lower().find('pythonw.exe') >= 0).
23 if os.name == 'nt':
23 if os.name == 'nt':
24 old_excepthook = sys.excepthook
24 old_excepthook = sys.excepthook
25
25
26 # Exclude this from our autogenerated API docs.
26 # Exclude this from our autogenerated API docs.
27 undoc = lambda func: func
27 undoc = lambda func: func
28
28
29 @undoc
29 @undoc
30 def gui_excepthook(exctype, value, tb):
30 def gui_excepthook(exctype, value, tb):
31 try:
31 try:
32 import ctypes, traceback
32 import ctypes, traceback
33 MB_ICONERROR = 0x00000010
33 MB_ICONERROR = 0x00000010
34 title = u'Error starting IPython QtConsole'
34 title = u'Error starting IPython QtConsole'
35 msg = u''.join(traceback.format_exception(exctype, value, tb))
35 msg = u''.join(traceback.format_exception(exctype, value, tb))
36 ctypes.windll.user32.MessageBoxW(0, msg, title, MB_ICONERROR)
36 ctypes.windll.user32.MessageBoxW(0, msg, title, MB_ICONERROR)
37 finally:
37 finally:
38 # Also call the old exception hook to let it do
38 # Also call the old exception hook to let it do
39 # its thing too.
39 # its thing too.
40 old_excepthook(exctype, value, tb)
40 old_excepthook(exctype, value, tb)
41
41
42 sys.excepthook = gui_excepthook
42 sys.excepthook = gui_excepthook
43
43
44 from IPython.external.qt import QtCore, QtGui
44 from IPython.external.qt import QtCore, QtGui
45
45
46 from IPython.config.application import boolean_flag
46 from IPython.config.application import boolean_flag
47 from IPython.config.application import catch_config_error
47 from IPython.config.application import catch_config_error
48 from IPython.core.application import BaseIPythonApplication
48 from IPython.core.application import BaseIPythonApplication
49 from IPython.qt.console.ipython_widget import IPythonWidget
49 from IPython.qt.console.ipython_widget import IPythonWidget
50 from IPython.qt.console.rich_ipython_widget import RichIPythonWidget
50 from IPython.qt.console.rich_ipython_widget import RichIPythonWidget
51 from IPython.qt.console import styles
51 from IPython.qt.console import styles
52 from IPython.qt.console.mainwindow import MainWindow
52 from IPython.qt.console.mainwindow import MainWindow
53 from IPython.qt.client import QtKernelClient
53 from IPython.qt.client import QtKernelClient
54 from IPython.qt.manager import QtKernelManager
54 from IPython.qt.manager import QtKernelManager
55 from IPython.utils.traitlets import (
55 from IPython.utils.traitlets import (
56 Dict, Unicode, CBool, Any
56 Dict, Unicode, CBool, Any
57 )
57 )
58
58
59 from IPython.consoleapp import (
59 from IPython.consoleapp import (
60 IPythonConsoleApp, app_aliases, app_flags, flags, aliases
60 IPythonConsoleApp, app_aliases, app_flags, flags, aliases
61 )
61 )
62
62
63 #-----------------------------------------------------------------------------
63 #-----------------------------------------------------------------------------
64 # Network Constants
64 # Network Constants
65 #-----------------------------------------------------------------------------
65 #-----------------------------------------------------------------------------
66
66
67 from IPython.utils.localinterfaces import is_local_ip
67 from IPython.utils.localinterfaces import is_local_ip
68
68
69 #-----------------------------------------------------------------------------
69 #-----------------------------------------------------------------------------
70 # Globals
70 # Globals
71 #-----------------------------------------------------------------------------
71 #-----------------------------------------------------------------------------
72
72
73 _examples = """
73 _examples = """
74 ipython qtconsole # start the qtconsole
74 ipython qtconsole # start the qtconsole
75 ipython qtconsole --matplotlib=inline # start with matplotlib inline plotting mode
75 ipython qtconsole --matplotlib=inline # start with matplotlib inline plotting mode
76 """
76 """
77
77
78 #-----------------------------------------------------------------------------
78 #-----------------------------------------------------------------------------
79 # Aliases and Flags
79 # Aliases and Flags
80 #-----------------------------------------------------------------------------
80 #-----------------------------------------------------------------------------
81
81
82 # start with copy of flags
82 # start with copy of flags
83 flags = dict(flags)
83 flags = dict(flags)
84 qt_flags = {
84 qt_flags = {
85 'plain' : ({'IPythonQtConsoleApp' : {'plain' : True}},
85 'plain' : ({'IPythonQtConsoleApp' : {'plain' : True}},
86 "Disable rich text support."),
86 "Disable rich text support."),
87 }
87 }
88 qt_flags.update(boolean_flag(
88 qt_flags.update(boolean_flag(
89 'banner', 'IPythonQtConsoleApp.display_banner',
89 'banner', 'IPythonQtConsoleApp.display_banner',
90 "Display a banner upon starting the QtConsole.",
90 "Display a banner upon starting the QtConsole.",
91 "Don't display a banner upon starting the QtConsole."
91 "Don't display a banner upon starting the QtConsole."
92 ))
92 ))
93
93
94 # and app_flags from the Console Mixin
94 # and app_flags from the Console Mixin
95 qt_flags.update(app_flags)
95 qt_flags.update(app_flags)
96 # add frontend flags to the full set
96 # add frontend flags to the full set
97 flags.update(qt_flags)
97 flags.update(qt_flags)
98
98
99 # start with copy of front&backend aliases list
99 # start with copy of front&backend aliases list
100 aliases = dict(aliases)
100 aliases = dict(aliases)
101 qt_aliases = dict(
101 qt_aliases = dict(
102 style = 'IPythonWidget.syntax_style',
102 style = 'IPythonWidget.syntax_style',
103 stylesheet = 'IPythonQtConsoleApp.stylesheet',
103 stylesheet = 'IPythonQtConsoleApp.stylesheet',
104 colors = 'ZMQInteractiveShell.colors',
105
104
106 editor = 'IPythonWidget.editor',
105 editor = 'IPythonWidget.editor',
107 paging = 'ConsoleWidget.paging',
106 paging = 'ConsoleWidget.paging',
108 )
107 )
109 # and app_aliases from the Console Mixin
108 # and app_aliases from the Console Mixin
110 qt_aliases.update(app_aliases)
109 qt_aliases.update(app_aliases)
111 qt_aliases.update({'gui-completion':'ConsoleWidget.gui_completion'})
110 qt_aliases.update({'gui-completion':'ConsoleWidget.gui_completion'})
112 # add frontend aliases to the full set
111 # add frontend aliases to the full set
113 aliases.update(qt_aliases)
112 aliases.update(qt_aliases)
114
113
115 # get flags&aliases into sets, and remove a couple that
114 # get flags&aliases into sets, and remove a couple that
116 # shouldn't be scrubbed from backend flags:
115 # shouldn't be scrubbed from backend flags:
117 qt_aliases = set(qt_aliases.keys())
116 qt_aliases = set(qt_aliases.keys())
118 qt_aliases.remove('colors')
119 qt_flags = set(qt_flags.keys())
117 qt_flags = set(qt_flags.keys())
120
118
121 #-----------------------------------------------------------------------------
119 #-----------------------------------------------------------------------------
122 # Classes
120 # Classes
123 #-----------------------------------------------------------------------------
121 #-----------------------------------------------------------------------------
124
122
125 #-----------------------------------------------------------------------------
123 #-----------------------------------------------------------------------------
126 # IPythonQtConsole
124 # IPythonQtConsole
127 #-----------------------------------------------------------------------------
125 #-----------------------------------------------------------------------------
128
126
129
127
130 class IPythonQtConsoleApp(BaseIPythonApplication, IPythonConsoleApp):
128 class IPythonQtConsoleApp(BaseIPythonApplication, IPythonConsoleApp):
131 name = 'ipython-qtconsole'
129 name = 'ipython-qtconsole'
132
130
133 description = """
131 description = """
134 The IPython QtConsole.
132 The IPython QtConsole.
135
133
136 This launches a Console-style application using Qt. It is not a full
134 This launches a Console-style application using Qt. It is not a full
137 console, in that launched terminal subprocesses will not be able to accept
135 console, in that launched terminal subprocesses will not be able to accept
138 input.
136 input.
139
137
140 The QtConsole supports various extra features beyond the Terminal IPython
138 The QtConsole supports various extra features beyond the Terminal IPython
141 shell, such as inline plotting with matplotlib, via:
139 shell, such as inline plotting with matplotlib, via:
142
140
143 ipython qtconsole --matplotlib=inline
141 ipython qtconsole --matplotlib=inline
144
142
145 as well as saving your session as HTML, and printing the output.
143 as well as saving your session as HTML, and printing the output.
146
144
147 """
145 """
148 examples = _examples
146 examples = _examples
149
147
150 classes = [IPythonWidget] + IPythonConsoleApp.classes
148 classes = [IPythonWidget] + IPythonConsoleApp.classes
151 flags = Dict(flags)
149 flags = Dict(flags)
152 aliases = Dict(aliases)
150 aliases = Dict(aliases)
153 frontend_flags = Any(qt_flags)
151 frontend_flags = Any(qt_flags)
154 frontend_aliases = Any(qt_aliases)
152 frontend_aliases = Any(qt_aliases)
155 kernel_client_class = QtKernelClient
153 kernel_client_class = QtKernelClient
156 kernel_manager_class = QtKernelManager
154 kernel_manager_class = QtKernelManager
157
155
158 stylesheet = Unicode('', config=True,
156 stylesheet = Unicode('', config=True,
159 help="path to a custom CSS stylesheet")
157 help="path to a custom CSS stylesheet")
160
158
161 hide_menubar = CBool(False, config=True,
159 hide_menubar = CBool(False, config=True,
162 help="Start the console window with the menu bar hidden.")
160 help="Start the console window with the menu bar hidden.")
163
161
164 maximize = CBool(False, config=True,
162 maximize = CBool(False, config=True,
165 help="Start the console window maximized.")
163 help="Start the console window maximized.")
166
164
167 plain = CBool(False, config=True,
165 plain = CBool(False, config=True,
168 help="Use a plaintext widget instead of rich text (plain can't print/save).")
166 help="Use a plaintext widget instead of rich text (plain can't print/save).")
169
167
170 display_banner = CBool(True, config=True,
168 display_banner = CBool(True, config=True,
171 help="Whether to display a banner upon starting the QtConsole."
169 help="Whether to display a banner upon starting the QtConsole."
172 )
170 )
173
171
174 def _plain_changed(self, name, old, new):
172 def _plain_changed(self, name, old, new):
175 kind = 'plain' if new else 'rich'
173 kind = 'plain' if new else 'rich'
176 self.config.ConsoleWidget.kind = kind
174 self.config.ConsoleWidget.kind = kind
177 if new:
175 if new:
178 self.widget_factory = IPythonWidget
176 self.widget_factory = IPythonWidget
179 else:
177 else:
180 self.widget_factory = RichIPythonWidget
178 self.widget_factory = RichIPythonWidget
181
179
182 # the factory for creating a widget
180 # the factory for creating a widget
183 widget_factory = Any(RichIPythonWidget)
181 widget_factory = Any(RichIPythonWidget)
184
182
185 def parse_command_line(self, argv=None):
183 def parse_command_line(self, argv=None):
186 super(IPythonQtConsoleApp, self).parse_command_line(argv)
184 super(IPythonQtConsoleApp, self).parse_command_line(argv)
187 self.build_kernel_argv(self.extra_args)
185 self.build_kernel_argv(self.extra_args)
188
186
189
187
190 def new_frontend_master(self):
188 def new_frontend_master(self):
191 """ Create and return new frontend attached to new kernel, launched on localhost.
189 """ Create and return new frontend attached to new kernel, launched on localhost.
192 """
190 """
193 kernel_manager = self.kernel_manager_class(
191 kernel_manager = self.kernel_manager_class(
194 connection_file=self._new_connection_file(),
192 connection_file=self._new_connection_file(),
195 parent=self,
193 parent=self,
196 autorestart=True,
194 autorestart=True,
197 )
195 )
198 # start the kernel
196 # start the kernel
199 kwargs = {}
197 kwargs = {}
200 # FIXME: remove special treatment of IPython kernels
198 # FIXME: remove special treatment of IPython kernels
201 if self.kernel_manager.ipython_kernel:
199 if self.kernel_manager.ipython_kernel:
202 kwargs['extra_arguments'] = self.kernel_argv
200 kwargs['extra_arguments'] = self.kernel_argv
203 kernel_manager.start_kernel(**kwargs)
201 kernel_manager.start_kernel(**kwargs)
204 kernel_manager.client_factory = self.kernel_client_class
202 kernel_manager.client_factory = self.kernel_client_class
205 kernel_client = kernel_manager.client()
203 kernel_client = kernel_manager.client()
206 kernel_client.start_channels(shell=True, iopub=True)
204 kernel_client.start_channels(shell=True, iopub=True)
207 widget = self.widget_factory(config=self.config,
205 widget = self.widget_factory(config=self.config,
208 local_kernel=True)
206 local_kernel=True)
209 self.init_colors(widget)
207 self.init_colors(widget)
210 widget.kernel_manager = kernel_manager
208 widget.kernel_manager = kernel_manager
211 widget.kernel_client = kernel_client
209 widget.kernel_client = kernel_client
212 widget._existing = False
210 widget._existing = False
213 widget._may_close = True
211 widget._may_close = True
214 widget._confirm_exit = self.confirm_exit
212 widget._confirm_exit = self.confirm_exit
215 widget._display_banner = self.display_banner
213 widget._display_banner = self.display_banner
216 return widget
214 return widget
217
215
218 def new_frontend_slave(self, current_widget):
216 def new_frontend_slave(self, current_widget):
219 """Create and return a new frontend attached to an existing kernel.
217 """Create and return a new frontend attached to an existing kernel.
220
218
221 Parameters
219 Parameters
222 ----------
220 ----------
223 current_widget : IPythonWidget
221 current_widget : IPythonWidget
224 The IPythonWidget whose kernel this frontend is to share
222 The IPythonWidget whose kernel this frontend is to share
225 """
223 """
226 kernel_client = self.kernel_client_class(
224 kernel_client = self.kernel_client_class(
227 connection_file=current_widget.kernel_client.connection_file,
225 connection_file=current_widget.kernel_client.connection_file,
228 config = self.config,
226 config = self.config,
229 )
227 )
230 kernel_client.load_connection_file()
228 kernel_client.load_connection_file()
231 kernel_client.start_channels()
229 kernel_client.start_channels()
232 widget = self.widget_factory(config=self.config,
230 widget = self.widget_factory(config=self.config,
233 local_kernel=False)
231 local_kernel=False)
234 self.init_colors(widget)
232 self.init_colors(widget)
235 widget._existing = True
233 widget._existing = True
236 widget._may_close = False
234 widget._may_close = False
237 widget._confirm_exit = False
235 widget._confirm_exit = False
238 widget._display_banner = self.display_banner
236 widget._display_banner = self.display_banner
239 widget.kernel_client = kernel_client
237 widget.kernel_client = kernel_client
240 widget.kernel_manager = current_widget.kernel_manager
238 widget.kernel_manager = current_widget.kernel_manager
241 return widget
239 return widget
242
240
243 def init_qt_app(self):
241 def init_qt_app(self):
244 # separate from qt_elements, because it must run first
242 # separate from qt_elements, because it must run first
245 self.app = QtGui.QApplication([])
243 self.app = QtGui.QApplication([])
246
244
247 def init_qt_elements(self):
245 def init_qt_elements(self):
248 # Create the widget.
246 # Create the widget.
249
247
250 base_path = os.path.abspath(os.path.dirname(__file__))
248 base_path = os.path.abspath(os.path.dirname(__file__))
251 icon_path = os.path.join(base_path, 'resources', 'icon', 'IPythonConsole.svg')
249 icon_path = os.path.join(base_path, 'resources', 'icon', 'IPythonConsole.svg')
252 self.app.icon = QtGui.QIcon(icon_path)
250 self.app.icon = QtGui.QIcon(icon_path)
253 QtGui.QApplication.setWindowIcon(self.app.icon)
251 QtGui.QApplication.setWindowIcon(self.app.icon)
254
252
255 ip = self.ip
253 ip = self.ip
256 local_kernel = (not self.existing) or is_local_ip(ip)
254 local_kernel = (not self.existing) or is_local_ip(ip)
257 self.widget = self.widget_factory(config=self.config,
255 self.widget = self.widget_factory(config=self.config,
258 local_kernel=local_kernel)
256 local_kernel=local_kernel)
259 self.init_colors(self.widget)
257 self.init_colors(self.widget)
260 self.widget._existing = self.existing
258 self.widget._existing = self.existing
261 self.widget._may_close = not self.existing
259 self.widget._may_close = not self.existing
262 self.widget._confirm_exit = self.confirm_exit
260 self.widget._confirm_exit = self.confirm_exit
263 self.widget._display_banner = self.display_banner
261 self.widget._display_banner = self.display_banner
264
262
265 self.widget.kernel_manager = self.kernel_manager
263 self.widget.kernel_manager = self.kernel_manager
266 self.widget.kernel_client = self.kernel_client
264 self.widget.kernel_client = self.kernel_client
267 self.window = MainWindow(self.app,
265 self.window = MainWindow(self.app,
268 confirm_exit=self.confirm_exit,
266 confirm_exit=self.confirm_exit,
269 new_frontend_factory=self.new_frontend_master,
267 new_frontend_factory=self.new_frontend_master,
270 slave_frontend_factory=self.new_frontend_slave,
268 slave_frontend_factory=self.new_frontend_slave,
271 )
269 )
272 self.window.log = self.log
270 self.window.log = self.log
273 self.window.add_tab_with_frontend(self.widget)
271 self.window.add_tab_with_frontend(self.widget)
274 self.window.init_magic_helper()
272 self.window.init_magic_helper()
275 self.window.init_menu_bar()
273 self.window.init_menu_bar()
276
274
277 # Ignore on OSX, where there is always a menu bar
275 # Ignore on OSX, where there is always a menu bar
278 if sys.platform != 'darwin' and self.hide_menubar:
276 if sys.platform != 'darwin' and self.hide_menubar:
279 self.window.menuBar().setVisible(False)
277 self.window.menuBar().setVisible(False)
280
278
281 self.window.setWindowTitle('IPython')
279 self.window.setWindowTitle('IPython')
282
280
283 def init_colors(self, widget):
281 def init_colors(self, widget):
284 """Configure the coloring of the widget"""
282 """Configure the coloring of the widget"""
285 # Note: This will be dramatically simplified when colors
283 # Note: This will be dramatically simplified when colors
286 # are removed from the backend.
284 # are removed from the backend.
287
285
288 # parse the colors arg down to current known labels
286 # parse the colors arg down to current known labels
289 cfg = self.config
287 cfg = self.config
290 colors = cfg.ZMQInteractiveShell.colors if 'ZMQInteractiveShell.colors' in cfg else None
288 colors = cfg.ZMQInteractiveShell.colors if 'ZMQInteractiveShell.colors' in cfg else None
291 style = cfg.IPythonWidget.syntax_style if 'IPythonWidget.syntax_style' in cfg else None
289 style = cfg.IPythonWidget.syntax_style if 'IPythonWidget.syntax_style' in cfg else None
292 sheet = cfg.IPythonWidget.style_sheet if 'IPythonWidget.style_sheet' in cfg else None
290 sheet = cfg.IPythonWidget.style_sheet if 'IPythonWidget.style_sheet' in cfg else None
293
291
294 # find the value for colors:
292 # find the value for colors:
295 if colors:
293 if colors:
296 colors=colors.lower()
294 colors=colors.lower()
297 if colors in ('lightbg', 'light'):
295 if colors in ('lightbg', 'light'):
298 colors='lightbg'
296 colors='lightbg'
299 elif colors in ('dark', 'linux'):
297 elif colors in ('dark', 'linux'):
300 colors='linux'
298 colors='linux'
301 else:
299 else:
302 colors='nocolor'
300 colors='nocolor'
303 elif style:
301 elif style:
304 if style=='bw':
302 if style=='bw':
305 colors='nocolor'
303 colors='nocolor'
306 elif styles.dark_style(style):
304 elif styles.dark_style(style):
307 colors='linux'
305 colors='linux'
308 else:
306 else:
309 colors='lightbg'
307 colors='lightbg'
310 else:
308 else:
311 colors=None
309 colors=None
312
310
313 # Configure the style
311 # Configure the style
314 if style:
312 if style:
315 widget.style_sheet = styles.sheet_from_template(style, colors)
313 widget.style_sheet = styles.sheet_from_template(style, colors)
316 widget.syntax_style = style
314 widget.syntax_style = style
317 widget._syntax_style_changed()
315 widget._syntax_style_changed()
318 widget._style_sheet_changed()
316 widget._style_sheet_changed()
319 elif colors:
317 elif colors:
320 # use a default dark/light/bw style
318 # use a default dark/light/bw style
321 widget.set_default_style(colors=colors)
319 widget.set_default_style(colors=colors)
322
320
323 if self.stylesheet:
321 if self.stylesheet:
324 # we got an explicit stylesheet
322 # we got an explicit stylesheet
325 if os.path.isfile(self.stylesheet):
323 if os.path.isfile(self.stylesheet):
326 with open(self.stylesheet) as f:
324 with open(self.stylesheet) as f:
327 sheet = f.read()
325 sheet = f.read()
328 else:
326 else:
329 raise IOError("Stylesheet %r not found." % self.stylesheet)
327 raise IOError("Stylesheet %r not found." % self.stylesheet)
330 if sheet:
328 if sheet:
331 widget.style_sheet = sheet
329 widget.style_sheet = sheet
332 widget._style_sheet_changed()
330 widget._style_sheet_changed()
333
331
334
332
335 def init_signal(self):
333 def init_signal(self):
336 """allow clean shutdown on sigint"""
334 """allow clean shutdown on sigint"""
337 signal.signal(signal.SIGINT, lambda sig, frame: self.exit(-2))
335 signal.signal(signal.SIGINT, lambda sig, frame: self.exit(-2))
338 # need a timer, so that QApplication doesn't block until a real
336 # need a timer, so that QApplication doesn't block until a real
339 # Qt event fires (can require mouse movement)
337 # Qt event fires (can require mouse movement)
340 # timer trick from http://stackoverflow.com/q/4938723/938949
338 # timer trick from http://stackoverflow.com/q/4938723/938949
341 timer = QtCore.QTimer()
339 timer = QtCore.QTimer()
342 # Let the interpreter run each 200 ms:
340 # Let the interpreter run each 200 ms:
343 timer.timeout.connect(lambda: None)
341 timer.timeout.connect(lambda: None)
344 timer.start(200)
342 timer.start(200)
345 # hold onto ref, so the timer doesn't get cleaned up
343 # hold onto ref, so the timer doesn't get cleaned up
346 self._sigint_timer = timer
344 self._sigint_timer = timer
347
345
348 @catch_config_error
346 @catch_config_error
349 def initialize(self, argv=None):
347 def initialize(self, argv=None):
350 self.init_qt_app()
348 self.init_qt_app()
351 super(IPythonQtConsoleApp, self).initialize(argv)
349 super(IPythonQtConsoleApp, self).initialize(argv)
352 IPythonConsoleApp.initialize(self,argv)
350 IPythonConsoleApp.initialize(self,argv)
353 self.init_qt_elements()
351 self.init_qt_elements()
354 self.init_signal()
352 self.init_signal()
355
353
356 def start(self):
354 def start(self):
357
355
358 # draw the window
356 # draw the window
359 if self.maximize:
357 if self.maximize:
360 self.window.showMaximized()
358 self.window.showMaximized()
361 else:
359 else:
362 self.window.show()
360 self.window.show()
363 self.window.raise_()
361 self.window.raise_()
364
362
365 # Start the application main loop.
363 # Start the application main loop.
366 self.app.exec_()
364 self.app.exec_()
367
365
368 #-----------------------------------------------------------------------------
366 #-----------------------------------------------------------------------------
369 # Main entry point
367 # Main entry point
370 #-----------------------------------------------------------------------------
368 #-----------------------------------------------------------------------------
371
369
372 def main():
370 def main():
373 app = IPythonQtConsoleApp()
371 app = IPythonQtConsoleApp()
374 app.initialize()
372 app.initialize()
375 app.start()
373 app.start()
376
374
377
375
378 if __name__ == '__main__':
376 if __name__ == '__main__':
379 main()
377 main()
General Comments 0
You need to be logged in to leave comments. Login now