Black Lives Matter. Please consider donating to Black Girls Code today.

Python: is it possible to retrieve screen size

Is there a way to retrieve the screen size in python? There are several things that I would like to do in Dash that would benefit greatly if I could get this info.

I saw a similar question about react, but I was hoping there is some python example code somewhere. Thanks much in advance.

You can only access this through JavaScript (you might be able to use a clientside callback here to pass the data back to the Python backend: clientside callback outputs to a store component which outputs to a Python function) or with CSS via media queries (which you can use to re-arrange and hide/show elements on different screensizes and is by far the most performant approach)

Thank-you chriddyp!!<----20th character. (I would have just said “thanks”)

1 Like