Python Forum
WindowManager TinyWM in Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
WindowManager TinyWM in Python
#1
Hi Guys,

I am new here and have start with python, hope my english is not to bad ^^. I do not know, who knows the WindowManager TinyWM, but I have a few problems to starting him. I hope to find someone here who knows what needs to be rewritten, or someone who can quickly rewrite the source code for python3. The next question is: if I can run the program with "python ... .py" or with "startx ... .py"? Here is the source code:

from Xlib.display import Display
from Xlib import X, XK

dpy = Display()
root = dpy.screen().root

root.grab_key(XK.string_to_keysym("F1"), X.Mod1Mask, 1,
        X.GrabModeAsync, X.GrabModeAsync)
root.grab_button(1, X.Mod1Mask, 1, X.ButtonPressMask,
        X.GrabModeAsync, X.GrabModeAsync, X.NONE, X.NONE)
root.grab_button(3, X.Mod1Mask, 1, X.ButtonPressMask,
        X.GrabModeAsync, X.GrabModeAsync, X.NONE, X.NONE)

while 1:
    ev = root.display.next_event()

    if ev.type == X.KeyPress and ev.child != X.NONE:
        ev.window.circulate(X.RaiseLowest)
    elif ev.type == X.ButtonPress and ev.child != X.NONE:
        ev.child.grab_pointer(1, X.PointerMotionMask|X.ButtonReleaseMask,
                X.GrabModeAsync, X.GrabModeAsync, X.NONE, X.NONE, X.CurrentTime)
        attr = ev.child.get_geometry()
        start = ev
    elif ev.type == X.MotionNotify:
        #while(XCheckTypedEvent(dpy, MotionNotify, &ev));
        xdiff = ev.root_x - start.root_x
        ydiff = ev.root_y - start.root_y
        ev.window.configure(
            x = attr.x + (start.detail == 1 and xdiff or 0),
            y = attr.y + (start.detail == 1 and ydiff or 0),
            width = max(1, attr.width + (start.detail == 3 and xdiff or 0)),
            height = max(1, attr.height + (start.detail == 3 and ydiff or 0)))
    elif ev.type == X.ButtonRelease:
        dpy.ungrab_pointer(X.CurrentTime)
Error:
Traceback (most recent call last): File "tinywm.py", line 13, in <module> X.GrabModeAsync, X.GrabModeAsync) File "/home/hacking/.local/lib/python2.7/site-packages/Xlib/xobject/drawable.py", line 551, in grab_key keyboard_mode = keyboard_mode) File "/home/hacking/.local/lib/python2.7/site-packages/Xlib/protocol/rq.py", line 1459, in __init__ self._binary = self._request.to_binary(*args, **keys) File "/home/hacking/.local/lib/python2.7/site-packages/Xlib/protocol/rq.py", line 1141, in to_binary return self.to_binary(*varargs, **keys) File "<string>", line 2, in to_binary struct.error: ubyte format requires 0 <= number <= 255
I would be very happy about your help :D
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020