Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
5c4a4cb2
Commit
5c4a4cb2
authored
7 years ago
by
Martyn Gigg
Browse files
Options
Downloads
Patches
Plain Diff
Allow additional messeages on the IPython banner.
Refs #21251
parent
b00baee7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
qt/python/mantidqt/widgets/ipythonconsole/widget.py
+13
-0
13 additions, 0 deletions
qt/python/mantidqt/widgets/ipythonconsole/widget.py
qt/python/mantidqt/widgets/test/test_ipythonconsole.py
+5
-0
5 additions, 0 deletions
qt/python/mantidqt/widgets/test/test_ipythonconsole.py
with
18 additions
and
0 deletions
qt/python/mantidqt/widgets/ipythonconsole/widget.py
+
13
−
0
View file @
5c4a4cb2
...
...
@@ -39,6 +39,15 @@ from mantidqt.utils.async import blocking_async_task
class
InProcessIPythonConsole
(
RichIPythonWidget
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
"""
A constructor matching that of RichIPythonWidget
:param args: Positional arguments passed directly to RichIPythonWidget
:param kwargs: Keyword arguments. The following are used by this
widget:
- banner_extra: An additinal string to append to the default banner
"""
# remove our arguments
banner_extra
=
kwargs
.
pop
(
"
banner_extra
"
,
""
)
super
(
InProcessIPythonConsole
,
self
).
__init__
(
*
args
,
**
kwargs
)
# create an in-process kernel
...
...
@@ -51,6 +60,10 @@ class InProcessIPythonConsole(RichIPythonWidget):
shell
=
kernel
.
shell
shell
.
run_code
=
async_wrapper
(
shell
.
run_code
,
shell
)
# custom banner
if
banner_extra
:
self
.
banner
+=
"
\n
"
+
banner_extra
# attach channels and start kenel
kernel_client
=
kernel_manager
.
client
()
kernel_client
.
start_channels
()
...
...
This diff is collapsed.
Click to expand it.
qt/python/mantidqt/widgets/test/test_ipythonconsole.py
+
5
−
0
View file @
5c4a4cb2
...
...
@@ -34,6 +34,11 @@ class InProcessIPythonConsoleTest(unittest.TestCase):
self
.
assertTrue
(
hasattr
(
widget
,
"
kernel_manager
"
))
self
.
assertTrue
(
hasattr
(
widget
,
"
kernel_client
"
))
def
test_banner_extra_updates_banner
(
self
):
widget
=
InProcessIPythonConsole
(
banner_extra
=
"
foo
"
)
self
.
assertTrue
(
widget
.
banner
.
endswith
(
"
foo
"
))
self
.
assertTrue
(
widget
.
banner
.
startswith
(
"
Python
"
))
if
__name__
==
'
__main__
'
:
unittest
.
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment