# Size() not working with variables arguments

**URL:** <https://discourse.processing.org/t/size-not-working-with-variables-arguments/6665>\
**Category:** Processing.py\
**Created:** [December 16, 2018, 8:48pm UTC](https://discourse.processing.org/t/size-not-working-with-variables-arguments/6665 "2018-12-16T20:48:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Laurent](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Laurent](https://discourse.processing.org/u/Laurent)\
**Post date:** [December 16, 2018, 8:48pm UTC](https://discourse.processing.org/t/size-not-working-with-variables-arguments/6665/1 "2018-12-16T20:48:19Z")

</div>

Hi everyone,

The below code is not working with Processing.py (instead of the passed arguments the default values for width and height applies, that are 100x100 pixels: same results as size() statement, with no arguments):

```auto
square_size = 10
square_x_nb = 50
square_y_nb = 100

size(square_x_nb * square_size, square_y_nb * square_size)

```

It works fine with absolute values arguments but not with variables arguments, that is:

```auto
size(1000, 500)

```

Any idea?

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [December 16, 2018, 9:09pm UTC](https://discourse.processing.org/t/size-not-working-with-variables-arguments/6665/2 "2018-12-16T21:09:55Z")

</div>

[Processing.org/reference/settings\_.html](http://Processing.org/reference/settings_.html)

---

<div class="post-metadata">

**Author:** ![hesron](https://avatars.discourse-cdn.com/v4/letter/h/47e85d/32.png) [@hesron](https://discourse.processing.org/u/hesron)\
**Post date:** [December 16, 2018, 9:24pm UTC](https://discourse.processing.org/t/size-not-working-with-variables-arguments/6665/3 "2018-12-16T21:24:33Z")

</div>

When you need to define the parameters of the size of the display window with a variable, you must use the settings() function and define size() in it. 🙂

---

<div class="post-metadata">

**Author:** ![Laurent](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Laurent](https://discourse.processing.org/u/Laurent)\
**Post date:** [December 16, 2018, 9:29pm UTC](https://discourse.processing.org/t/size-not-working-with-variables-arguments/6665/4 "2018-12-16T21:29:41Z")

</div>

Thanks GoToLoop and hsron for your quick and clear answer!

For the above code, the solution would be:

```auto
square_size = 10
square_x_nb = 50
square_y_nb = 100

def settings():

  size(square_x_nb * square_size, square_y_nb * square_size)

```

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [December 18, 2018, 11:25pm UTC](https://discourse.processing.org/t/size-not-working-with-variables-arguments/6665/5 "2018-12-18T23:25:02Z")

</div>

Just noting that the Python Mode reference has an entry for `setup()`, but no equivalent documentation for `settings()`.

[https://py.processing.org/reference/setup.html](https://py.processing.org/reference/setup.html)

This might be worth opening as an issue for documentation on the python mode docs site:

> **[kazimuth/processing-py-site](https://github.com/kazimuth/processing-py-site/issues)**
>
> Site for processing.py. . Contribute to kazimuth/processing-py-site development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [December 29, 2018, 5:46am UTC](https://discourse.processing.org/t/size-not-working-with-variables-arguments/6665/6 "2018-12-29T05:46:57Z")

</div>

> [@jeremydouglass](#):
>
> … but no equivalent documentation for **settings()**.

That **settings()** issue strikes again: 🎳

> <https://github.com/jdf/Processing.py-Bugs/issues/256#issuecomment-450437376>
>
> I'm new to programing. I wrote a program and I'm getting the error "NameError: g…lobal name 'taman' is not defined" even though I have already defined taman.
> Here's the code:
> \`\`\`
> def setup():
> global taman
> global linhas
> global colunas
> global start
> try:
> file = open("settings.txt","r")
> except FileNotFoundError:
> file = open("settings.txt","w")
> file.write("Número de colunas:\\n3\\nNúmero de linhas:\\n3\\nRaio:\\n30\\nEspaço (~distância entre as figuras):\\n10\\nVelocidade (em rad/s):\\n0.01\\nFase do x (fração do pi):\\n0\\nFase do y (fração do pi):\\n0\\nEspessura do traçado:\\n3")
> file.close()
> file = open("settings.txt","r")
> taman = file.read().split('\\n')
> file.close()
> file.close()
> for x in \[1,3,5,7,15\]:
> taman\[x\] = int(taman\[x\])
> print(taman\[x\])
> taman\[9\] = float(taman\[9\])
> for x in \[11,13\]:
> print(taman\[x\])
> taman\[x\] = PI\*float(taman\[x\])
> start = True
> size((taman\[7\]+2\*taman\[5\])\*(taman\[1\]+1),(taman\[7\]+2\*taman\[5\])\*(taman\[3\]+1))
> colunas = \[bolinha((x + (1/2))\*(taman\[7\] + 2\*taman\[5\]) + taman\[5\],taman\[5\]+(taman\[7\])/2,x\*taman\[9\],taman\[5\],taman\[11\]) for x in range(1,taman\[1\]+1)\]
> linhas = \[bolinha(taman\[5\]+(taman\[7\])/2,taman\[5\]+(x + (1/2))\*(taman\[7\] + 2\*taman\[5\]),x\*taman\[9\],taman\[5\],taman\[13\]) for x in range(1,taman\[3\]+1)\]
> background(0)
> \`\`\`
> While it does print the elements of taman when I convert the strings to integers or floats, it raises the error in this line:
> \`\`\`
> size((taman\[7\]+2\*taman\[5\])\*(taman\[1\]+1),(taman\[7\]+2\*taman\[5\])\*(taman\[3\]+1))
> \`\`\`
> Did I do something wrong or is this a bug?
