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:
Kivy is an open source Python framework for creating cross-platform multi-touch mobile applications with Natural User Interface.

Kivy is an open source Python framework for creating cross-platform multi-touch mobile applications with Natural User Interface.

Grace Ugochi Nneji 3 Feb 15, 2022
Plantasia, all your plants and muchrooms in one place!

Plantasia Project Description Tkinter GUI to be used as a repository for plants and muchrooms. It helps to optimize the search for species that have h

Marco Rodrigues 1 Dec 23, 2021
A Virtual Desktop Assistant Written in Python

DesktopAssitant A Virtual Desktop Assistant Written in Python. It's generally a basic virtual assistant The basic purpose of this is to make work easi

Technerd Brainiac 597 Dec 31, 2022
A cute running cat animation on your Windows/macOS taskbar.

RunCat by PySide6 A cute running cat animation on your Windows/macOS taskbar. Tags PyQt PySide RunCat Demo You only have to run the RunCat.exe. Run pi

見える 10 Sep 19, 2022
Edifice: a declarative GUI library for Python

Edifice is a Python library for building reactive UI, inspired by modern Javascript libraries such as React.

David Ding 193 Dec 11, 2022
PyQt QGraphicsView with selection box. User can move vertical border of the box horizontally.

pyqt-horizontal-selection-square-graphics-view PyQt QGraphicsView with selection box. User can move vertical border of the box horizontally. Requireme

Jung Gyu Yoon 3 Nov 07, 2022
Custom GUI for your Blender add-ons using Dear ImGui

Dear Imgui for Blender Use the infamous Dear ImGui library directly in your Blender scripts! This means custom GUI drawing in your operators: Normally

Elie Michel 83 Dec 25, 2022
A small pomodoro GUI for Windows/Linux created in Python with PyQt5.

Pomodoro A small pomodoro GUI for Windows/Linux created with PyQt5. Features The "Timer" tab allows you to set your desired work and rest times aswell

Burak Martin 81 Dec 28, 2022
A small manager/GUI Frontend for QEMU written in Python

qemu-manager A small manager/GUI Frontend for QEMU written in Python Requirements You'll need to have the following tools installed to run this: QEMU

yeppiidev 15 Dec 21, 2022
A GUI for designing Python GUI's for PySimpleGUI.

SimpleGUIBuilder A GUI for designing Python GUI's for PySimpleGUI. Installation There is none :) just download the file from a release and run it. Don

Miguel Martins 65 Dec 22, 2022
A desktop application for JupyterLab, based on Electron.

A desktop application for JupyterLab, based on Electron.

JupyterLab 2.1k Jan 02, 2023
Write interactive web app in script way.

PyWebIO Write interactive web app in script way. [Document] | [Demos] | [Why PyWebIO?] English | 中文 PyWebIO provides a series of imperative functions

PyWebIO 3.6k Dec 31, 2022
ZFS Administration GUI

ZYGGY ZFS Administration GUI Zyggy is a very simple GUI for basic ZFS administration. The system provides graphical access for most frequently used ZF

51 Dec 18, 2022
Win32mica: a simple module to add the Mica effect on legacy python windows.

Win32mica (aka PyMica): A simple module to add the Mica effect on legacy python windows The aim of this project is to apply the Mica effect on python

Martí Climent 40 Dec 13, 2022
Small Python scripts to take screenshot from a KaiOS/FFOS device and to mirror the screen of your phone.

This version of kaiscr is written by tkinter and can run in windows(use kailive-tk.py). "kailive-tk-speed.py" is speed optimization version. The sourc

openGiraffes Group 2 Mar 02, 2022
A Windows Dock Widget Written In Pure Python

VEПUS A Windows Dock Widget Written In Pure Python What is Venus? Venus is a Dock Widget for your desktops interface. It adds a couple of really cool

Secrets 18 Dec 30, 2022
Web-Broswer simple using PyQt5 tools

Web-Broswer Simple web broswer made using PyQt Completely simple and easy to use How to set it up git clone https://github.com/AsjadOooO/Web-Broswer.g

Asjad 3 Nov 13, 2021
GUIOfTemperatureConverterUsingPython - GUI Of Temperature Converter Using Python

Fahrenheit To Celcius GUI Of Temperature Converter Below Video is the Output Of

SUJITHA RASAMSETTY 0 Mar 06, 2022
PyEditor - A Simple Text Editor for python

PyEditor work in progress Text Editor for python Installation git clone https://github.com/ArmenG888/PyEditor Install the libraries Linux or mac pip

ArmenG 3 Mar 15, 2022
Custom Widgets For PyQt5

pyqtCuWi Custom Widgets Icon Button Documentation Rank Widget Documentation PopUp OuterRadius PopUp Documentation OuterRadius Documentation Producer:

.CODE 0 Apr 04, 2022