Show Active Window Name (Python, Tk)

This small Python application shows active window name.


# This program is Public Domain
# Make sure you have installed xdotool before executing this (Debian/Ubuntu package "xdotool")

import os
from Tkinter import *

root = Tk()
# This Tk string holds the message string
message = StringVar()

# Store update ID to this global var

# Show label and get content from variable "message"
w = Label(root, textvariable=message)

# Create Exit button
button_cancel = Button(root, text="Dismiss", command=root.quit)

def update_message():
    message.set(os.popen('/usr/bin/xdotool getwindowfocus getwindowname').read())
    update_id=root.after(1000, update_message)

update_id=root.after(1000, update_message)

Leave a Reply

Your email address will not be published. Required fields are marked *

Please solve this puzzle (we're trying to avoid comment spam): fifty two − forty two =