A hotkey manager that runs in the system tray. Uses PySimpleGUI for the GUI and the system tray.

Overview

Python GUIs for Humans

PySimpleHotkey

PySimpleHotkey

A hotkey manager that runs in the system tray. Uses PySimpleGUI for the GUI and the system tray.

Packages Used

This project uses these pip installable packages:

  • PySimpleGUI
  • psgtray
  • keyboard

Mash-up

This project is a mash-up of some PySimpleGUI demo programs and a program called pingmote. The pingmote project is the origin of the keyboard handler. A big thank you to @dchen327 for the code and inspiration.

The system tray code is from the psgtray demo program.

The 2 utilities that are in the folder DocstringTools are the reason this little project was started. These tools use the clipboard as input and write back onto the clipboard the results.

PySimpleHotkey

Docstring Utilities

The reason that a hotkey was needed in the first place was a conveinent way to launch a couple of simple utilities that operate on the clipboard. They both read the clipboard, look for a doctring, modify the docstring, and save the result back onto the clipboard.

The idea is to have a workflow that follows these steps:

  • Text with docstring is copied onto clipboard
  • Hotkey is pressed to invoke one of the docstring tools
  • The modified clipboard is pasted into the code

AlignDocstrings.py

This program reads a docstring and lines up the description and types. It assumed the format of the docstrings is the one used by the PySimpleGUI project.

An example is the easiest way to show what it does.

Input

This is the input that is on the clipboard:

def execute_py_file(pyfile, parms=None, cwd=None, interpreter_command=None, wait=False, pipe_output=False):
    """
    Executes a Python file.
    The interpreter to use is chosen based on this priority order:
        1. interpreter_command paramter
        2. global setting "-python command-"
        3. the interpreter running running PySimpleGUI

    :param pyfile: the file to run
    :type pyfile: (str)
    :param parms: parameters to pass on the command line
    :type parms: (str)
    :param cwd: the working directory to use
    :type cwd: (str)
    :param interpreter_command: the command used to invoke the Python interpreter
    :type interpreter_command: (str)
    :param wait: the working directory to use
    :type wait: (bool)
    :param pipe_output: If True then output from the subprocess will be piped. You MUST empty the pipe by calling execute_get_results or your subprocess will block until no longer full
    :type pipe_output: (bool)
    :return: Popen object
    :rtype: (subprocess.Popen) | None
    """

Output

This is the result that is left on the clipboard:

def execute_py_file(pyfile, parms=None, cwd=None, interpreter_command=None, wait=False, pipe_output=False):
    """
    Executes a Python file.
    The interpreter to use is chosen based on this priority order:
        1. interpreter_command paramter
        2. global setting "-python command-"
        3. the interpreter running running PySimpleGUI
        
    :param pyfile:              the file to run
    :type pyfile:               (str)
    :param parms:               parameters to pass on the command line
    :type parms:                (str)
    :param cwd:                 the working directory to use
    :type cwd:                  (str)
    :param interpreter_command: the command used to invoke the Python interpreter
    :type interpreter_command:  (str)
    :param wait:                the working directory to use
    :type wait:                 (bool)
    :param pipe_output:         If True then output from the subprocess will be piped. You MUST empty the pipe by calling execute_get_results or your subprocess will block until no longer full
    :type pipe_output:          (bool)
    :return:                    Popen object
    :rtype:                     (subprocess.Popen) | None
    """

AddTypesToDocstring.py

PyCharm will automatically create a docstring for you. After a function definition, if you enter """ then it will populate the docstring using the parameters found in the function definition. It's a nice feature.

But.... the format of these docstrings is not the 2-line format used by the PySimpleGUI documentation creation tools (call reference in particular). This utility simply adds the type and rtype lines in the docstring. Like the other docstring tool, it takes the clipboard as input and places the result onto the clipboard.

Input

def execute_py_file(pyfile, parms=None, cwd=None, interpreter_command=None, wait=False, pipe_output=False):
    """
    
    :param pyfile: 
    :param parms: 
    :param cwd: 
    :param interpreter_command: 
    :param wait: 
    :param pipe_output: 
    :return: 
    """

Output

This utility only leaves the docstring on the clipboard. Any other text before or after is stripped off. As you can see, the difference is that each param line has a mataching type line and the return has a matching rtype.

    """
    
    :param pyfile: 
    :type pyfile:
    :param parms: 
    :type parms:
    :param cwd: 
    :type cwd:
    :param interpreter_command: 
    :type interpreter_command:
    :param wait: 
    :type wait:
    :param pipe_output: 
    :type pipe_output:
    :return: 
    :rtype:
    """

Windows Only (most likely)

psgtray runs the best on Windows and is used in this project. It's not been tried on Linux nor the Mac.

Opportunities for Improvement

Not a lot of time was spent on the entire project. It was some personal utilities that I wrote for myself and then reaslized that maybe others would want to extend their IDEs as well or do other hotkey kind of operations.

In this project, they keyboard handler hooks in at a low level such that all keystrokes will be passed to the program. The keyboard package likely has a more efficient and higher level interface that's not being used.

"Satisfice" is a word I recently discovered and realized it matches the prototype code that I write. It's pretty hacky kind of code as it's meant to do a specific job, on my system, and not designed in a high general purpose way. It's the "first pass" code... raw, simple, working stuff but not much more than that. It should at least work on your system though, assuming you're able to run psgtray and PySimpleGUI.

I hope you are able to find something here that helps you create your own tools that makes you more efficient.

Designed and written by

mike from PySimpleGUI.org

Contributing

Like the PySimpleGUI project, the PySimpleHotkey project is currently licensed under an open-source license, the project itself is structured like a proprietary product. Pull Requests are not accepted.

License

GNU Lesser General Public License (LGPL 3)

Copyright

Copyright 2021 PySimpleGUI

Owner
PySimpleGUI
Now Python programmers of all skill levels can make GUI programs. Commercial interests can contact:
GUI implementation of a Transformer chatbot. Suggests amicable responses to messages from friends.

conversation-helper GUI implementation of a Transformer chatbot. Suggests amicable responses to messages from friends. Screenshots Upcoming Release Im

Mark Musil 6 Nov 05, 2021
UI to save and load gnome-shell extension templates.

Gnome Extensions Loader GUI to save and load gnome shell extensions and extension settings. This app makes it easier to share your gnome extensions se

EMRECAN ALTINSOY 2 Nov 25, 2022
Use CSS styling in Tkinter apps

cssTk To-Do Support Upto CSS 4.15 Set Up Docs Features * Corner Radius Gradient BG Blur Animations Usage Scenarios Allows easy import of GTK 3 and GTK

RUG 5 Oct 18, 2022
GlobalProtectGUI is a simple tray app to connect, disconnect and monitor globalprotect VPN connection.

Simple GlobalProtectGUI GlobalProtectGUI is simple tray app to connect, disconnect and monitor globalprotect VPN connection. Installation Required bef

Aleksandar Dostic 11 Oct 07, 2022
Basic browser based on PyQt5

goneDev-browser "basic browser based on PyQt5" This application is primarily built on macOS with more adaptibility for MacOS than Windows. v1.0 will s

Harsh ADV) 1 Jan 19, 2022
A simple todo GUI applicaiton

simple_todo_gui A simple todo GUI applicaiton To create an .exe file, run 'Python setup.py build' after installing PyQt5 and cx_Freeze with pip. Then

Dhammike Piyumal 2 Nov 11, 2021
PyCG: Practical Python Call Graphs

PyCG - Practical Python Call Graphs PyCG generates call graphs for Python code using static analysis. It efficiently supports Higher order functions T

Vitalis Salis 185 Dec 29, 2022
Basic Alarm Clock using Python.

Basic Alarm Clock using Python.

Samyak Jain 2 Feb 10, 2022
A GUI panel to manage multi monitor on i3wm.

Monitor manager Only for I3wm (Just for now) It's about two years that I'm using i3 as my window manager and in my experience this window manager allo

Wire.Nemo 3 Nov 06, 2021
Projeto de mini-games de azar com interface gráfica utilizando Python e PySimpleGui.

Gambling Mini jogos de azar unidos em uma mesma interface gráfica, utilizando a linguagem de programação Python em conjunto com a biblioteca de interf

Clayton Garcia da Silva 3 Nov 19, 2021
Chatterpatter - A simple GUI complex backend Chat Application made using python

Chatterpatter - A simple GUI complex backend Chat Application made using python

Gurneet Singh 2 Jan 08, 2022
Mini is a web browser application based on the Python PyQt web engine, made in 290 lines of code.

Mini Mini is a web browser application based on the Python PyQt web engine, made in 290 lines of code. The code is written and published as is, so the

Dmitry Karpenko 6 Nov 07, 2022
A simple Python Module for sending cross-platform desktop notifications on Windows, macOS and Linux

notify.py Cross platform desktop notifications for Python scripts and applications. Docs You can read the docs on this Git's Wiki, or here Supported P

Mustafa 178 Dec 26, 2022
A python Script For Taking Screenshot Of Windows

PyShot A Python Script For Taking Screenshot Of Windows Disclaimer This tool is for educational purposes only ! Don't use this to take revenge I will

Nazim Cp 2 Jun 22, 2022
AutoCalypsoBTS - A simple GUI CalypsoBTS for DragonOS by CrTh

AutoCalypsoBTS 📱 📞 A simple GUI CalypsoBTS for DragonOS by CrTh Download Drago

CrTx0 18 Dec 15, 2022
This is the new and improved Plex Automatic Pre-roll script with a GUI

Rollarr This is the new and improved Automatic Pre-roll script with a GUI for Plex now called Rollarr! It should be stable but if you find a bug pleas

164 Nov 04, 2022
A graphical user interface calendar with python

GUI-Calendar A graphical user interface calendar with python In this project I used tkinter module If you dont have tkinter module you can install it

Arone Sadegh 1 Dec 18, 2021
PyQt Custom Frameless Main Window (Enable to move and resize)

pyqt-custom-frameless-mainwindow PyQt Custom Frameless Main Window (Enable to move and resize) Requirements PyQt5 = 5.8 Setup pip3 install git+https:

Jung Gyu Yoon 1 Jan 13, 2022
A Python native, OS native GUI toolkit.

Toga A Python native, OS native GUI toolkit. Prerequisites Minimum requirements Toga requires Python 3. Python 2 is not supported. If you're on macOS,

BeeWare 3.3k Dec 31, 2022
Use any of the 1k+ free FontAwesome icons in your tkinter application.

TkFontAwesome A library that enables you to use FontAwesome icons in your tkinter application. You may use any of the 1k+ free FontAwesome 5.0 icons.

Israel Dryer 33 Dec 20, 2022