I want to display an interactive Python session inside a box in BEAMER.
As my presentation has many slides like this I thought it would be convenient to create a new environment, but when I try to compile the following code:
\documentclass{beamer}
\usepackage{pythontex}
\usepackage{tcolorbox}
\newenvironment{boxsession}
{ \begin{tcolorbox}[colframe=blue,colback=blue!5!white,notitle,size=small] \begin{pyconsole} }
{ \end{pyconsole} \end{tcolorbox} }
\begin{document}
\begin{frame}[fragile]
\frametitle{Lists}
\begin{boxsession}
foo = [1, 2, 3]
bar = foo
baz = foo[:]
foo[-1] = -99
foo
bar
baz
\end{boxsession}
\end{frame}
\end{document}
I get:
Runaway argument?
! File ended while scanning use of \FancyVerbGetLine.
<inserted text>
\par
l.32 \end{frame}
?
I also tried to use environ to no avail:
\usepackage{environ}
\NewEnviron{boxsession}
{\begin{tcolorbox}[colframe=blue,colback=blue!5!white,notitle,size=small]
\begin{pyconsole}
\BODY
\end{pyconsole}
\end{tcolorbox}}
Any ideas how to get around this error?


