Hide Desktop for Distraction Free Writing

Distraction free writing is all the rage these days, and I’m a huge proponent of the movement because I am very prone to distraction. Why right now, I should be doing something else, but I got distracted with this!

Anyway, one of my essential tools for a distraction free environment is a totally black desktop with no icons showing. Each operating system has techniques for making this happen, but I have found a solution that works on all operating systems equally. The only requirement is that you have Python installed (tested on 2.7).

This code runs as an app, so you don’t have to change any operating system settings to get it to work, and as soon as you want to see your desktop again, just double-right-click on the black background and it will exit!

Here’s the python code to make it happen (watch out for word wrapping).


from Tkinter import *

class App():
    def __init__(self):
        self.root = Tk()

        screen_width = self.root.winfo_screenwidth()
        screen_height = self.root.winfo_screenheight()

        self.frame = Frame(self.root, width=screen_width, height=screen_height,
                           borderwidth=0, relief=RAISED, background="#000000")
        self.frame.bind("<FocusIn>", self.unfocus)
        self.frame.bind("<Button-1>", self.unfocus)
        self.frame.bind("<Double-Button-1>", self.unfocus)
        self.frame.bind("<Double-Button-2>", self.quit)

        self.root.geometry('%dx%d+%d+%d' % (screen_width, screen_height, 0, 0))

        # self.root.call('wm', 'attributes', '.', '-topmost', True)
        # self.root.after_idle(self.root.call, 'wm', 'attributes', '.', '-topmost', False)

    def quit(self, event):

    def unfocus(self, event):

app = App()

About the Author

Leave a Reply

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

You may also like these