You can use
\surroundwithmdframed[<options>]{<environment>}
A complete example:
\documentclass{article}
\usepackage{listings}
\usepackage{xcolor} %custom colours
\usepackage[framemethod=tikz]{mdframed} %nice frames
\definecolor{light-gray}{gray}{0.95} %the shade of grey that stack
\surroundwithmdframed[backgroundcolor=light-gray, roundcorner=10pt,leftmargin=1, rightmargin=1, innerleftmargin=15, innertopmargin=15,innerbottommargin=15, outerlinewidth=1, linecolor=light-gray]{lstlisting}
\begin{document}
\begin{lstlisting}[language=Python,caption={A test listing}]
Program here
\end{lstlisting}
\end{document}
The result:
By the way, you should use
\usepackage[framemethod=tikz]{mdframed} %nice frames
as I did in my example; otherwise, some options (such as roundcorner
) will be ignored.
However, I'd like to suggest you an alternative using the powerful tcolorbox
package and its nice interaction with listings
:
\documentclass{article}
\usepackage{listings}
\usepackage{xcolor} %custom colours
\usepackage[most]{tcolorbox} %nice frames
\definecolor{light-gray}{gray}{0.95} %the shade of grey that stack
\newtcblisting{mytcbox}[1][]{
breakable,
enhanced,
colback=light-gray,
colframe=light-gray,
boxrule=0pt,
arc=10pt,
auto outer arc,
listing only,
listing options={#1}
}
\begin{document}
\begin{mytcbox}[language=Python]
Program here
\end{mytcbox}
\end{document}
The result: