# Python binding mode attribute

**URL:** <https://rpi-rgb-led-matrix.discourse.group/t/python-binding-mode-attribute/972>\
**Category:** Uncategorized\
**Created:** [December 26, 2024, 3:31pm UTC](https://rpi-rgb-led-matrix.discourse.group/t/python-binding-mode-attribute/972 "2024-12-26T15:31:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hsamuels](https://yyz2.discourse-cdn.com/free1/user_avatar/rpi-rgb-led-matrix.discourse.group/hsamuels/32/400_2.png) [@hsamuels](https://rpi-rgb-led-matrix.discourse.group/u/hsamuels)\
**Post date:** [December 26, 2024, 3:31pm UTC](https://rpi-rgb-led-matrix.discourse.group/t/python-binding-mode-attribute/972/1 "2024-12-26T15:31:21Z")

</div>

I’m trying to display some text using the Python binding. Here’s the code:

offscreen\_canvas = matrix.CreateFrameCanvas()  
font = graphics.Font()  
font.LoadFont(“…/rpi-rgb-led-matrix/fonts/7x13.bdf”)  
textColor = graphics.Color(255, 255, 0)  
my\_text = “Hello, world!”  
graphics.DrawText(offscreen\_canvas, font, 0, 0, textColor, my\_text)  
matrix.SetImage(offscreen\_canvas)

And here’s the error message:

File “/home/howard/atos/python/build\_sign”, line 175, in   
matrix.SetImage(offscreen\_canvas)  
File “core.pyx”, line 12, in rgbmatrix.core.Canvas.SetImage  
AttributeError: ‘rgbmatrix.core.FrameCanvas’ object has no attribute ‘mode’

I can’t figure out how to set the mode (to ‘RGB’).

One potentially important issue is that my script can’t find samplebase to import SampleBase. But I don’t see anything in samplebase.py about mode.

Any help would be greatly appreciated!

Update: I made a smbolic link to samplebase.py, but the same error message appears.

---

<div class="post-metadata">

**Author:** ![hsamuels](https://yyz2.discourse-cdn.com/free1/user_avatar/rpi-rgb-led-matrix.discourse.group/hsamuels/32/400_2.png) [@hsamuels](https://rpi-rgb-led-matrix.discourse.group/u/hsamuels)\
**Post date:** [December 27, 2024, 1:27pm UTC](https://rpi-rgb-led-matrix.discourse.group/t/python-binding-mode-attribute/972/2 "2024-12-27T13:27:22Z")

</div>

Update: I’m doing all the other graphic stuff in PIL, then using the Python binding matrix.SetImage to push it to the display. Rather than try to use other functions from what appears to be a binding that needs some work, BDFparser can read a bdf font file and create a bitmap image from it.

So while the original question about setting the mode to RGB hasn’t been answered, hopefully this workaround will be useful to others.
