HOME/Articles/

pil example ev3imports (snippet)

Article Outline

Python pil example 'ev3imports'

Modules used in program:

  • import socket

python ev3imports

Python pil example: ev3imports

import socket
hostname = socket.gethostname()

if hostname == 'ev3dev':
    # We are on the EV3, import required modules directly
    import ev3dev.ev3   as ev3
    import ev3dev.fonts as fonts
    import PIL
else:
    # We are somewhere else. Assume we are using RPyC:
    import rpyc
    conn = rpyc.classic.connect('ev3dev')

    ev3   = conn.modules['ev3dev.ev3']
    fonts = conn.modules['ev3dev.fonts']
    PIL   = conn.modules['PIL']