Saturday, 4 January 2020

How do I write text to the root window using Python's Xlib?

I'm running a Debian 10 stable x64 system with the dwm window manager, and I'm using Python 3.7.3. From what I can tell from some example code and the draw_text method itself, I should be able to draw text on the root window with code like this:

#!/usr/bin/env python3

import Xlib
import Xlib.display

display = Xlib.display.Display()
screen = display.screen()
root = screen.root

gc = root.create_gc(foreground = screen.white_pixel, background = screen.black_pixel)
root.draw_text(gc, 1, 1, b"Hello, world!")

This code runs without error, but no text is displayed. I've also experimented with different coordinates without any luck. My root window background is just the default black, so I don't think the text is failing to show up, since I set the foreground pixel color to white.



from How do I write text to the root window using Python's Xlib?

No comments:

Post a Comment