hzeller / rpi-rgb-led-matrix

Controlling up to three chains of 64x64, 32x32, 16x32 or similar RGB LED displays using Raspberry Pi GPIO
GNU General Public License v2.0
3.67k stars 1.17k forks source link

Run the runText outside of sample folder not working #188

Closed AlirezaAlgo closed 8 years ago

AlirezaAlgo commented 8 years ago

First of all , thank you for great work .

When i'm running the runtext.py everything work , but when write this code , i get error say i need pass the canvas , it is same code but outside the sample folder

from .core import RGBMatrix, FrameCanvas
import graphics
import time

def RunText():
    matrix = RGBMatrix(32, 6, 1)
    matrix.pwmBits = 11
    matrix.brightness = 100

    offscreenCanvas = matrix.CreateFrameCanvas()

    font = graphics.Font()

    font.LoadFont("../matrix/fonts/7x13.bdf")

    textColor = graphics.Color(255, 255, 0)

    pos = offscreenCanvas.width
    myText = "Hello World!"

    while True:
        offscreenCanvas.Clear()
        len = graphics.DrawText(offscreenCanvas, font, pos, 10, textColor, myText)
        pos -= 1
        if (pos + len < 0):
            pos = offscreenCanvas.width
        time.sleep(0.05)
        offscreenCanvas = matrix.SwapOnVSync(offscreenCanvas)

i get this error :

Argument 'c' has incorrect type (expected rgbmatrix.core.Canvas, got rgbmatrix.core.FrameCanvas)
hzeller commented 8 years ago

Paging @Saij as I don't know how the Python bridge works.

Saij commented 8 years ago

Well normaly FrameCanvas should inherit Canvas. Have to take a look into it.

hzeller commented 8 years ago

Could it be something like shared object files not properly resolved ?

AlirezaAlgo commented 8 years ago

other example of problem ,

When go to sample folder and do this :

python runtext.py

It work , but when you go to parent folder

cd ..
python sample/runtext.py 

won't work , same problem as my code

AlirezaAlgo commented 8 years ago

only runtext not working other code that are using only the core , they work

hzeller commented 8 years ago

Did you check if the font is properly loaded ? Maybe the Python impl changes the working directory, so maybe an absolute path to the font might be something to try.

(but sounds unlikey, as the error indicates something with the frame canvas)

AlirezaAlgo commented 8 years ago

@hzeller problem of not working from upper folder fixed with font path , thank you