Ipython notebook: generate log output in one cell; move to specific line in that cells output based on actions of function call in subsequent cell?

StackOverflow https://stackoverflow.com/questions/23131511

Question

I want to be able to display a log of a few thousand lines in a scrolling window/cell/frame; execute a python function and as a consequence have the log window scroll to a particular line of the log. I thought the ipython notebook environment would help in the further processing of the logged data that must be done, but if it is easiest done with some other GUI ...

it is for exploration of the logged data. We don't as yet know how best to separate the seed from the chaff.

Since posting, I have found this solution of:

<html>
<body>
<script>
function jump2iframe(ifrname, ifrlabel)
{
    document.getElementById(ifrname).contentWindow.location.hash = ifrlabel;
};
</script>
...
<iframe src="rad_1_file_5.html" width="100%" id="ifr">
  <p>Your browser does not support iframes.</p>
</iframe>
...
<a href="javascript:jump2iframe('ifr', 'line0200')">Jump to Anchor line0200 in iframe?</a>
...

Problem is that although it works in Firefox I want to continue using chrome, where it fails due to problems with the "Same Origin Policy".

My attempts at trying to use Cross-document messaging with the iframe that successfully loads the file from the same directory as the parent document all fail.

Was it helpful?

Solution

Possible solution found. Instead of including a generated file I will try using:

In first ipython cell

Create html with embedded links for every line:

from Ipython.display import display HTML

for n, line in enumerate(logdata, 1):
    display(HTML('<a id="line%06i">%s</b>' % (n, line)))

Click to scroll the cells output. This will create a scrolling html "div" section when there are many lines.

In another cell

I can create a link to scroll to line 22 for example by calling display again:

display(HTML('<a href="#line000022">go to line000022</a>'

I would prefer to get the cross document messaging for an embedded iframe working, but that solution eludes me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top