# How do I get screen size locally?

**URL:** <https://discourse.psychopy.org/t/how-do-i-get-screen-size-locally/42803>\
**Category:** Builder\
**Tags:** screen\
**Created:** [November 4, 2024, 1:42am UTC](https://discourse.psychopy.org/t/how-do-i-get-screen-size-locally/42803 "2024-11-04T01:42:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhezziw](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/zhezziw/32/43169_2.png) [@zhezziw](https://discourse.psychopy.org/u/zhezziw)\
**Post date:** [November 4, 2024, 1:42am UTC](https://discourse.psychopy.org/t/how-do-i-get-screen-size-locally/42803/1 "2024-11-04T01:42:54Z")

</div>

**OS** (e.g. Win10): Win11  
**PsychoPy version** (e.g. 1.84.x): v2024.2.4  
**Standard Standalone? (y/n)** If not then what?: y  
**What are you trying to achieve?:**  
I’m hoping to get the window sizes in pixels at the beginning of the experiments and store them for later use.

**What did you try to make it work?:**  
I looked at the Window documentation and tried what other people suggested in some previous discussions. For example:  
`screenWidth=psychopy.visual.window.size[0]`  
or

```auto
win = psychopy.visual.Window
screenWidth=win.size[0]

```

But nothing seems to work.

**What specifically went wrong when you tried that?:**  
I get  
`AttributeError: module 'psychopy.visual.window' has no attribute 'size'`  
when I run this  
`screenWidth=psychopy.visual.window.size[0]`

and I get  
`TypeError: 'property' object is not subscriptable`  
when I run

```auto
win = psychopy.visual.Window
screenWidth=win.size[0]

```

Thank you!!

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [November 4, 2024, 9:53am UTC](https://discourse.psychopy.org/t/how-do-i-get-screen-size-locally/42803/2 "2024-11-04T09:53:12Z")

</div>

Which tab is your code in? My guess is that it will fail in Before Experiment and potentially be wrong in Begin Experiment. I normally put it in End Routine of the first routine, unless I just want to know whether the screen is in portrait or landscape mode in which case Begin Experiment is fine.

---

<div class="post-metadata">

**Author:** ![zhezziw](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/zhezziw/32/43169_2.png) [@zhezziw](https://discourse.psychopy.org/u/zhezziw)\
**Post date:** [November 4, 2024, 7:49pm UTC](https://discourse.psychopy.org/t/how-do-i-get-screen-size-locally/42803/3 "2024-11-04T19:49:13Z")

</div>

Thank you for the reply! I tried Before Experiment, Begin Experiment and End Routine but none of them worked. I get the same error no matter which tab the code goes. Are there other ways to get the window sizes?

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [November 4, 2024, 7:51pm UTC](https://discourse.psychopy.org/t/how-do-i-get-screen-size-locally/42803/4 "2024-11-04T19:51:54Z")

</div>

Delete this line

win = psychopy.visual.Window

---

<div class="post-metadata">

**Author:** ![zhezziw](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/zhezziw/32/43169_2.png) [@zhezziw](https://discourse.psychopy.org/u/zhezziw)\
**Post date:** [November 4, 2024, 8:32pm UTC](https://discourse.psychopy.org/t/how-do-i-get-screen-size-locally/42803/5 "2024-11-04T20:32:05Z")

</div>

That worked perfectly! Thank you!!
