Skip to content

ev3dev-lang-python, rpyc and PIL #240

Closed

Description

@DJuego

Hi again! This is not a issue. I am working with rpyc. I need big fonts for lcd screen!

I got a beautiful example in ev3python (thanks @ndward!)

#!/usr/bin/env python3
from ev3dev.ev3 import *
from PIL import Image, ImageDraw, ImageFont  
from time import sleep

lcd = Screen()

f = ImageFont.truetype('/usr/share/fonts/truetype/msttcorefonts/Arial.ttf', 75)
lcd.draw.text((3,0), 'Hello', font=f)
lcd.draw.text((2,55), 'world', font=f)
lcd.update()

sleep(7)  # if run from Brickman, need time to see displayed image

The problem is ImageFont. How i can import the remote PIL module (and Image, ImageDraw, ImageFont)? is it possible? Any example? Any workaround?

DJuego

P.S: I am considering seriously to use ev3dev and ev3dev lang python for robotic teaching.
Interactive programming is so appealing... I only wish to get things done as simple as I can.

Activity

  1. ddemidov commented on Oct 28, 2016

    @ddemidov
    Member

    If you are using the latest developement version of ev3dev-lang-python (soon to be released as 0.7.1), then you can use bitmap fonts distributed with the library (see #225 and http://python-ev3dev.readthedocs.io/en/latest/other.html#bitmap-fonts for more details). The following works for me:

    import rpyc
    conn = rpyc.classic.connect('ev3dev')
    ev3 = conn.modules['ev3dev.ev3']
    fonts = conn.modules['ev3dev.fonts']
    s = ev3.Screen()
    s.draw.text((10,10), 'Hello World', font = fonts.load('luBS14'))
    s.update()

    If you are working with the latest released version (0.7.0), you may still use @ndward's example you referenced. The only change is that you need to import PIL.ImageFont remotely:

    ImageFont = conn.modules['PIL.ImageFont']
    f = ImageFont.truetype('/usr/share/fonts/truetype/msttcorefonts/Arial.ttf', 75) # EV3 path
    s.draw.text((10,10), 'Hello World', font=f)
    s.update()
  2. DJuego commented on Oct 28, 2016

    @DJuego
    Author

    Well. I am overwhelmed. :-) Easily, I prefer the 0.7.1 option. However i don´t know how upgrade to the last development version the ev3dev and the Spyder editor too. I am a absolutely newbie in Python.
    Anyway i have a alternative. :-P

    Thank you again, ddemidov for your swift and clear answers. I will be on the watch for the 0.7.1 release.

    DJuego

  3. ddemidov commented on Oct 28, 2016

    @ddemidov
    Member

    However i don´t know how upgrade to the last development version the ev3dev

    Here is what I do to get the latest version installed (on EV3):

    sudo apt-get remove python3-ev3dev
    git clone https://github.com/rhempel/ev3dev-lang-python
    cd ev3dev-lang-python
    python3 setup.py bdist
    sudo python3 setup.py install --force
  4. DJuego commented on Oct 28, 2016

    @DJuego
    Author

    O.o Amazing! I will consider to upgrade. In my opinion, this info is worthy of a place in the README.

    DJuego

  5. WasabiFan commented on Oct 28, 2016

    @WasabiFan
    Member

    For beginners, in general I'd recommend sticking to the official releases. This is mainly because it ensures that you can share your code with others and have it work properly. It's also helpful because the standard upgrade instructions will only work on your installation if it's based on the official package.

    @ddemidov Is there anything that you think is blocking a release (#233)?

  6. ddemidov commented on Oct 28, 2016

    @ddemidov
    Member

    @WasabiFan, I'd like to do #230. This looks easy enough, just need to update my kernel 😸
    Also, I am not yet sure about the best way to fix #234. Other than that, 0.7.1 seems ready to be released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions