Showing multiple HTML contens in Jupyter Notebook (IFrame in loop)

Viewed 122

I'm using Jupyther notebook and I have a problem for "loop" in IFrame.

The code below works(it means The html content is shown in jupyter notbook)

from IPython.display import IFrame
subfile_name = '2021W17_CQI-KPI_2/'
kpi = "3G DATA VOLUME TB (DT)"
IFrame(src='./'+subfile_name+kpi+'.html', width=980, height=600)

However, this code doesn't show the html contents, I want to see the html contents in order

from IPython.display import IFrame
kpis=["3G DATA VOLUME TB (DT)","LTE DATA VOLUME TB (DT)"]
for i in kpis:
    IFrame(src='./'+subfile_name+i+'.html', width=980, height=600)

How can I see the multiple html contents in order in Jupyter notebook?

1 Answers

As far as I know Jupyter notebooks display the latest variable of the executed cell, that's why a single HTML works.

However for multiple HTMLs you can display them on after the other by using:

for i in kpis:
     display(IFrame(src='./'+subfile_name+i+'.html', width=980, height=600))

Instead of:

for i in kpis:
     IFrame(src='./'+subfile_name+i+'.html', width=980, height=600)
Related