##// END OF EJS Templates
ENH: Allow FrontendWidget banner to be changed without subclassing.
epatters -
Show More
@@ -13,7 +13,7 b' from IPython.external.qt import QtCore, QtGui'
13 13 from IPython.core.inputsplitter import InputSplitter, transform_classic_prompt
14 14 from IPython.core.oinspect import call_tip
15 15 from IPython.frontend.qt.base_frontend_mixin import BaseFrontendMixin
16 from IPython.utils.traitlets import Bool, Instance
16 from IPython.utils.traitlets import Bool, Instance, Unicode
17 17 from bracket_matcher import BracketMatcher
18 18 from call_tip_widget import CallTipWidget
19 19 from completion_lexer import CompletionLexer
@@ -75,8 +75,8 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):'
75 75 """ A Qt frontend for a generic Python kernel.
76 76 """
77 77
78 enable_calltips = Bool(True, config=True,
79 help="Whether to draw information calltips on open-parentheses.")
78 # The text to show when the kernel is (re)started.
79 banner = Unicode()
80 80
81 81 # An option and corresponding signal for overriding the default kernel
82 82 # interrupt behavior.
@@ -89,6 +89,10 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):'
89 89 custom_restart_kernel_died = QtCore.Signal(float)
90 90 custom_restart_requested = QtCore.Signal()
91 91
92 # Whether to automatically show calltips on open-parentheses.
93 enable_calltips = Bool(True, config=True,
94 help="Whether to draw information calltips on open-parentheses.")
95
92 96 # Emitted when a user visible 'execute_request' has been submitted to the
93 97 # kernel from the FrontendWidget. Contains the code to be executed.
94 98 executing = QtCore.Signal(object)
@@ -463,7 +467,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):'
463 467 self._highlighter.highlighting_on = False
464 468
465 469 self._control.clear()
466 self._append_plain_text(self._get_banner())
470 self._append_plain_text(self.banner)
467 471 self._show_interpreter_prompt()
468 472
469 473 def restart_kernel(self, message, now=False):
@@ -543,13 +547,6 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):'
543 547 info = self._CompletionRequest(msg_id, pos)
544 548 self._request_info['complete'] = info
545 549
546 def _get_banner(self):
547 """ Gets a banner to display at the beginning of a session.
548 """
549 banner = 'Python %s on %s\nType "help", "copyright", "credits" or ' \
550 '"license" for more information.'
551 return banner % (sys.version, sys.platform)
552
553 550 def _get_context(self, cursor=None):
554 551 """ Gets the context for the specified cursor (or the current cursor
555 552 if none is specified).
@@ -620,3 +617,12 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):'
620 617 document = self._control.document()
621 618 if position == self._get_cursor().position():
622 619 self._call_tip()
620
621 #------ Trait default initializers -----------------------------------------
622
623 def _banner_default(self):
624 """ Returns the standard Python banner.
625 """
626 banner = 'Python %s on %s\nType "help", "copyright", "credits" or ' \
627 '"license" for more information.'
628 return banner % (sys.version, sys.platform)
@@ -20,7 +20,6 b' from IPython.external.qt import QtCore, QtGui'
20 20 # Local imports
21 21 from IPython.core.inputsplitter import IPythonInputSplitter, \
22 22 transform_ipy_prompt
23 from IPython.core.usage import default_gui_banner
24 23 from IPython.utils.traitlets import Bool, Unicode
25 24 from frontend_widget import FrontendWidget
26 25 import styles
@@ -278,11 +277,6 b' class IPythonWidget(FrontendWidget):'
278 277 info = self._CompletionRequest(msg_id, pos)
279 278 self._request_info['complete'] = info
280 279
281 def _get_banner(self):
282 """ Reimplemented to return IPython's default banner.
283 """
284 return default_gui_banner
285
286 280 def _process_execute_error(self, msg):
287 281 """ Reimplemented for IPython-style traceback formatting.
288 282 """
@@ -512,3 +506,8 b' class IPythonWidget(FrontendWidget):'
512 506 else:
513 507 self._highlighter.set_style_sheet(self.style_sheet)
514 508
509 #------ Trait default initializers -----------------------------------------
510
511 def _banner_default(self):
512 from IPython.core.usage import default_gui_banner
513 return default_gui_banner
General Comments 0
You need to be logged in to leave comments. Login now