Ejemplo n.º 1
0
        # We should check if this object is in the exposed
        # area, but I can't be bothered right now, so just
        # redraw on the last Expose in every batch

        if ev.count == 0:
            self.first.draw()
            if self.last:
                # Redraw all the lines
                PolyLine(self.win.d, None, X.CoordModeOrigin, self.win.window,
                         self.win.gc, self.lines)
                self.last.draw()


# A romboid, drawed around the Movement endpoints
class Romboid:
    def __init__(self, win, ev):
        self.win = win
        self.x = ev.event_x
        self.y = ev.event_y
        self.draw()

    def draw(self):
        # Draw the segments of the romboid
        PolyLine(self.win.d, None, X.CoordModePrevious, self.win.window,
                 self.win.gc, [(self.x, self.y - 5), (5, 5), (-5, 5), (-5, -5),
                               (5, -5)])


if __name__ == '__main__':
    Window(display.Display()).loop()
Ejemplo n.º 2
0
# Very simple Xlib-based client in Python.
# Copyright (c) 2008 Thomas Thurman <*****@*****.**>; GPL 2.0 or later.
# Originally based around example code in python-xlib
# by Peter Liljenberg <*****@*****.**>.

import sys

from Xlib import X
from Xlib.protocol import display
from Xlib.protocol.request import *

display = display.Display()
screen = display.info.roots[display.default_screen]
window = display.allocate_resource_id()
gc = display.allocate_resource_id()

CreateWindow(
    display,
    None,
    depth=screen.root_depth,
    wid=window,
    parent=screen.root,
    x=100,
    y=100,
    width=250,
    height=250,
    border_width=2,
    window_class=X.InputOutput,
    visual=X.CopyFromParent,
    background_pixel=screen.white_pixel,
    event_mask=(X.ExposureMask | X.StructureNotifyMask | X.ButtonPressMask