Find Screen Dimensions

Continuing the discussion from What is the best practice to make anvil app looks good on mobile device?:

I wanted to help future me and other’s who stumbled on this post.

with anvils anvil.js library you can easily find screen dimension parameters using the window variable.

Below is my use case:

from anvil.js import window

def is_portrait():
  if window.innerHeight > window.innerWidth:
    return True
  return False

Hope this saves someone a little bit of time. :slight_smile:

8 Likes

Or simply

from anvil.js import window

def is_portrait():
  return window.innerHeight > window.innerWidth
6 Likes