# Changing RGBMatrixOptions programmatically does not work in Python

**URL:** <https://rpi-rgb-led-matrix.discourse.group/t/changing-rgbmatrixoptions-programmatically-does-not-work-in-python/832>\
**Category:** Uncategorized\
**Created:** [June 25, 2024, 10:24am UTC](https://rpi-rgb-led-matrix.discourse.group/t/changing-rgbmatrixoptions-programmatically-does-not-work-in-python/832 "2024-06-25T10:24:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ilya](https://yyz2.discourse-cdn.com/free1/user_avatar/rpi-rgb-led-matrix.discourse.group/ilya/32/364_2.png) [@Ilya](https://rpi-rgb-led-matrix.discourse.group/u/Ilya)\
**Post date:** [June 25, 2024, 10:24am UTC](https://rpi-rgb-led-matrix.discourse.group/t/changing-rgbmatrixoptions-programmatically-does-not-work-in-python/832/1 "2024-06-25T10:24:07Z")

</div>

Hello,

I am trying to write a program that should change the rotation programmatically upon some event.

I start the program with default options: the option `led-pixel-mapper` value is set to whatever is given via `--led-pixel-mapper` program argument.

But when in runtime I want to change this value:

```auto
self.matrix.options.pixel_mapper_config = "Rotate:270"

```

I get this error:

```auto
AttributeError: 'rgbmatrix.core.RGBMatrix' object has no attribute 'options'

```

I know this is a noob question but I am new to Python and would appreciate your help very much.

I tried to re-create the whole RGBMatrix object using a workaround, but then I am getting this error:

```auto
Can't set realtime thread priority=99: Operation not permitted.
        You are probably not running as root ?
        This will seriously mess with color stability and flicker
        of the matrix. Please run as `root` (e.g. by invoking this
        program with `sudo`), or setting the capability on this
        binary by calling
        sudo setcap 'cap_sys_nice=eip' /usr/bin/python3.9

```

Yes, I am running as root and I did call the `setcap`, but this has had no effect.

Thanks.

---

<div class="post-metadata">

**Author:** ![ShuraBlack](https://yyz2.discourse-cdn.com/free1/user_avatar/rpi-rgb-led-matrix.discourse.group/shurablack/32/366_2.png) [@ShuraBlack](https://rpi-rgb-led-matrix.discourse.group/u/ShuraBlack)\
**Post date:** [July 14, 2024, 2:32am UTC](https://rpi-rgb-led-matrix.discourse.group/t/changing-rgbmatrixoptions-programmatically-does-not-work-in-python/832/2 "2024-07-14T02:32:10Z")

</div>

Hello mate 🙂

Might be a bit late, but i just started my own project with this api a couple of days ago.

To answer your two questions:

> [@](#):
>
> But when in runtime I want to change this value:
> 
> ```auto
> self.matrix.options.pixel_mapper_config = "Rotate:270"
> 
> ```
> 
> I get this error:
> 
> ```auto
> AttributeError: 'rgbmatrix.core.RGBMatrix' object has no attribute 'options'
> 
> ```

At least the bindinds of python does not have any reference to the options after cython initialized the object. The only things you can change afterwards are “luminanceCorrection”, “pwmBits”, “brightness”, “height” and “width”. You can check out the doc here [core.pyx](https://github.com/hzeller/rpi-rgb-led-matrix/blob/master/bindings/python/rgbmatrix/core.pyx)

> [@](#):
>
> I tried to re-create the whole RGBMatrix object using a workaround, but then I am getting this error:  
> …

As also mention in his endless pages of explanation, the api does drop priviliges after initializing the hardware, so you cant recreate another instance of the RGBMatrix without an error. If you want to prevent that you can  
(A) use the flag **–led-no-drop-privs** or  
(B) change the value from **options.drop\_privileges = False**  
I didnt tested this so far, since i dont know a reason to change the matrix afterwards, but as of my understand this should be a workaround.

_"You need to start programs as root as it needs to access some low-level hardware at initialization time. After that, it is typically not desirable to stay in this role, so the library then drops the privileges._

_This flag allows to switch off this behavior, so that you stay root. Not recommended unless you have a specific reason for it (e.g. you need root to access other hardware or you do the privilege dropping yourself)."_
