Skip to content

Syntactic sugar for property access #274

Description

@redhog

Heyas!

This is a solicitation for comments before I make a PR:

For my window manager, I have made a wrapper for python-xlib that adds a lot of convenience syntax sugar stuff. This does a lot of monkey patching, and I'd like to contribute this back to python-xlib as added methods to the core classes instead. None of this changes existing functionality, it just adds.

In particular, property access to windows is greatly simplified by having windows work as dictionaries of their properties, supporting all the usual operations (keys(), items(), in, win[name] = value etc). The dictionary keys are the python string equivalents of the ATOM:s.

Values are converted to/from python equivalents as needed to be convenient:
WINDOW are returned as
Xlib.xobject.drawable.Window objects, ATOMs, KEYCODEs and XCONSTs as python strings, STRINGs as bytess. Properties with length != 1 are converted to/from lists of the corresponding values.

I forsee some of these changes to be more easily accepted than other ones, so please feel free to browse through the above link and write here what you like and dislike!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions