Using the textwrap micropython module?

  • Has anyone tried this?

    I managed to upload to my device and it seems to import fine. But whenever I attempt to use it I get an error. Here is the code I'm trying to work with:

        req = urequests.request(method='GET', url='', headers={'Accept':'application/json'})
        dad_json = json.loads((req.text))
        DadJoke = dad_json['joke']
        wrapped = textwrap.fill(str(DadJoke),width=30)

    If I simply set_text(str(DadJoke)) it works but it writes right off the edge of the screen.

  • I'd be open to any other methods you have for wrapping text. Or even generic instructions for importing external micropython modules...

    This works fine in my local python interpreter:

    from textwrap import *
    joke = "This is a really long joke. This is a really long joke.This is a really long joke.This is a really long joke.This is a really long joke."
    wrapper = textwrap.TextWrapper(width=30)

    But when I try to run it on the m5stack device I get:

    'module' object has no attribute 'TextWrapper'