From the Burrow

Still no musing - Python Select Window and grab Details (alpha)

2010-06-17 00:00:00 +0000

I have had need of a program that gave me the ability to select any window on the desktop and have it return details for me. Turns out there is a lovely command line program specifically for this called ‘xprop’. To use it in python I have called subprocess and got it to rip the results that contain the information I need into a dictionary.

Its very hacky at the mo and will receive plenty of love before it is ready but as I spent so long trying to find out there was a program for this I pretty much had to post it for prosperity.

You have been warned!

 
import subprocess
import tempfile

class WindowGrabber:
    def __init__(self):
        pass
    
    def window_picker(self):
        out = tempfile.TemporaryFile()
        in_pipe = None
        self.job = subprocess.Popen(["xprop",],
                                    stdin=in_pipe,
                                    stdout=out,
                                    stderr=subprocess.STDOUT)
        while self.job.returncode is None:
            self.job.poll()
        out.seek(0)
        result = out.readlines()
        window_details = {}
        for line in result:
            if line.find(" = ") >= 0:
                key, value = line.split(" = ")
                if value.find(", ") >= 0:
                    value = value.split(", ")
                window_details[key] = value
        print ""
        
if __name__ == "__main__":
    a=WindowGrabber().window_picker()

A Little Parcel Of Awesome

2010-06-06 00:00:00 +0000

Test from mobile

2010-05-17 00:00:00 +0000

Again another nearly pointless post. This time to test the wordpress android apps. Damn nice it is too!

Salutations Terra

2010-05-16 00:00:00 +0000