I always wanted a small widget for my desktop which housed every action used frequently. Yes, there is the Start menu on Windows and the equivalent on Mac, but these ways are limited. I wanted to do a Google search by clicking one button, and open a multi-nested directory by clicking another. With the help of Python’s Tkinter GUI interface, I developed a program that does all of this!
DesktopHub is a desktop application that opens specified directories and websites on the click of a button. It’s a great app if you’re tired of traversing multiple directories or websites to get to where you want to be.
The image on the right is the DesktopHub GUI. The GUI is split into two sections: the main section and the modules section. The main section is everything shown above the dotted line while everything below the line contains the different modules.
The main section has four buttons that correspond to four different directories on your computer. All one has to do is click on a button and the directory shown on the button will open in explorer.
The modules section contains optional “plug-ins” for the app. By default, most of the plug-ins are active. A user can deactivate plug-ins by moving the modules .py file into the inactive_modules folder (in the program’s root directory).
At the time of writing, the app comes with three modules. My long-term goal for this project aims to have many user-made modules as part of the program. So, I encourage other users of the app to create and add their own modules.
If you would like to create your own modules for the app, go to the README.md for the project and scroll down to the section labeled “Creating Your Own Modules” (there are seven steps to follow).
The main piece of code I would like to review is action(), which links the Tkinter button commands with the actual processing of the commands:
def action(self, text, query=None): # Default path (root dir) path = "." # Main GUI if text == "C:": path = self._c_drive_path elif text == "D:": path = self._d_drive_path elif text == "Docs": path = self._docs_path elif text == "DLs": path = self._dls_path # Module 1 elif text == "Python": path = self._load_modules()[0][0] elif text == "Pkgs": path = self._load_modules()[0][1] # Explorer opener Popen(r'explorer "{}"'.format(path))
When a user clicks a button in the app, the button calls the above function. Each button is linked to a specific text parameter which is then checked by this function.
Once the if/elif statement is found True, the path variable is set to the path to be opened. Then, explorer opens the assigned path. One thing to mention is that custom modules may open a browser instead of explorer; depends on the module’s intended use.
DesktopHub was a great project to code and will most likely be the influence for similar apps in the future. I like the idea of having optional “plug-ins” for a program as a user can tailor it to their needs.
I encourage you to try it out and let me know what you think. If you are the programming type, try to create your own optional modules for the program!
—
Could you or someone you know benefit from an app like DesktopHub? Is there a feature you can think of that would be a great addition to the app? Do you have suggestions or improvements for the program? Leave your comments below!