Hi E0x,
On 24/05/10 16:20, E0x wrote:
> i am doing a litle app that i need show some text in the root-window i
> am noob in python programing so i was looking a example but don't find
> any , can somebody point me or give to one ?
Probably the easiest way to demo simple text drawing is to just hack a
line onto the draw.py example. You can find that at:
http://python-xlib.svn.sourceforge.net/viewvc/python-xlib/trunk/examples/draw.py?revision=133&view=markup
Add the following line at line 223-ish, after the poly_line call:
self.win.window.draw_text(self.win.gc, self.x, self.y, "hello")
When you run the example, that should draw "hello" where you click in
the window.
You should be able to modify that to draw to the root window by changing
the target to the root window. A guess at a quick example is:
import Xlib.display
d=Xlib.display.Display()
root=d.screen(0).root
gc=root.create_gc(foreground=d.screen(0).white_pixel,background=d.screen(0).black_pixel)
root.draw_text(gc,10,10,"hello")
d.flush()
Remember that most linux desktops don't actually show the root window
though - they normally cover it up with something pretty instead. For
example, if I run "xwininfo" and click on my visible background, it
appears to be a window owned by "x-nautilus-desktop". If I were to draw
to the real root window, that's probably behind that desktop window and
would be hidden.
Cheers,
Mike.

thanks mike , i will try this and what we talk in irc about make a window
and set it unfocused
On Mon, May 24, 2010 at 4:33 PM, Mike Grant <mgg@...> wrote:
> Hi E0x,
>
> On 24/05/10 16:20, E0x wrote:
> > i am doing a litle app that i need show some text in the root-window i
> > am noob in python programing so i was looking a example but don't find
> > any , can somebody point me or give to one ?
>
> Probably the easiest way to demo simple text drawing is to just hack a
> line onto the draw.py example. You can find that at:
>
> http://python-xlib.svn.sourceforge.net/viewvc/python-xlib/trunk/examples/draw.py?revision=133&view=markup
>
> Add the following line at line 223-ish, after the poly_line call:
> self.win.window.draw_text(self.win.gc, self.x, self.y, "hello")
>
> When you run the example, that should draw "hello" where you click in
> the window.
>
> You should be able to modify that to draw to the root window by changing
> the target to the root window. A guess at a quick example is:
>
> import Xlib.display
> d=Xlib.display.Display()
> root=d.screen(0).root
>
> gc=root.create_gc(foreground=d.screen(0).white_pixel,background=d.screen(0).black_pixel)
> root.draw_text(gc,10,10,"hello")
> d.flush()
>
> Remember that most linux desktops don't actually show the root window
> though - they normally cover it up with something pretty instead. For
> example, if I run "xwininfo" and click on my visible background, it
> appears to be a window owned by "x-nautilus-desktop". If I were to draw
> to the real root window, that's probably behind that desktop window and
> would be hidden.
>
> Cheers,
>
> Mike.
>