I have a project right now and I'm using WNCK to find the location of open windows, as well as focus them. I recently added features that require Python 3.5, but WNCK is only working with Python 2.7 or whatever I have installed. When running python3 stuff.py, I'm getting
ImportError: No module named 'wnck'
Does anyone know how I can get the wnck library for Python 3? I previously got it for python2 with sudo apt-get install python-wnck
I'm using Ubuntu, so if the answer is anything like "Can't get WNCK working, switch to X", please make sure it's not a windows only solution
From python3 onwards wnck is part of the GObject Introspection API. You can presently get access to wnck3 in python3 on Debian (and therefore I presume identically on Ubuntu) with:
apt-get install python3-gi gir1.2-wnck-3.0
Obviously the gir- and wnck- versions will vary over time (or you may need e.g. an older version of wnck), but:
apt-cache search 'gir.*wnck'
should be enough for finding what you want. I personally prefer to leverage the power of aptitude-search with
aptitude search '?depends(libgirepository) wnck'
Due to the flexibility of the Introspection API, importing is slightly more complex, for example:
>>> import gi
>>> gi.require_version('Wnck', '3.0')
>>> from gi.repository import Wnck
Documentation for python3/wnck3 can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With