BrowserUk gave you the preferred answer below, but if you wanted to use my Canvas method, without invoking a window, all you need to do is comment out the line #MainLoop. Then if you run it, it will not show a window.
Either way, you are loading Tk. You can either load Tk::Text or a Tk::Canvas.
Tk is relatively light and fast to load.