Skip to content

Syntactic sugar for property access #274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
redhog opened this issue Jul 10, 2024 · 0 comments
Open

Syntactic sugar for property access #274

redhog opened this issue Jul 10, 2024 · 0 comments

Comments

@redhog
Copy link

redhog commented Jul 10, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant