Skip to content

Commit 1ab8586

Browse files
author
y-p
committed
ENH: add helper for detecting any IPython zmq frontend, make in_qtconsole robuster
1 parent 7ed8271 commit 1ab8586

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

pandas/core/common.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1782,11 +1782,25 @@ def in_qtconsole():
17821782
"""
17831783
try:
17841784
ip = get_ipython()
1785-
if ip.config['KernelApp']['parent_appname'] == 'ipython-qtconsole':
1785+
front_end = (ip.config.get('KernelApp',{}).get('parent_appname',"") or
1786+
ip.config.get('IPKernelApp',{}).get('parent_appname',""))
1787+
if 'qtconsole' in front_end.lower():
17861788
return True
17871789
except:
17881790
return False
17891791

1792+
def in_ipnb_frontend():
1793+
"""
1794+
check if we're inside an an IPython zmq frontend
1795+
"""
1796+
try:
1797+
ip = get_ipython()
1798+
return 'zmq' in str(type(ip)).lower()
1799+
except:
1800+
pass
1801+
1802+
return False
1803+
17901804
# Unicode consolidation
17911805
# ---------------------
17921806
#

pandas/util/terminal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def get_terminal_size():
2222
Detect terminal size and return tuple = (width, height).
2323
2424
Only to be used when running in a terminal. Note that the IPython notebook,
25-
IPython qtconsole, or IDLE do not run in a terminal,
25+
IPython zmq frontends, or IDLE do not run in a terminal,
2626
"""
2727
import platform
2828
current_os = platform.system()

0 commit comments

Comments
 (0)