<p align="center">
<p align="center"><img width="238" height="135" src="https://pysimplegui.net/images/logos/psglogofull.svg"><p>
<h2 align="center">psghotkey</h2>
<h2 align="center">A PySimpleGUI Application</h2>
</p>
Windows Hotkeys Tool
TBD
<p align="center"><img width="583" height="415" src="screenshot.gif"><p>
## Features
* A complete hotkey manager
* Demonstrates integrating the system tray into your application
* Example sophisticated docstring formatting application of a hotkey
## Installation
### Using PIP with PyPI
The latest official release of PySimpleGUI products can be found on PyPI. To pip install the demo applications from PyPI, use this command
#### If you use the command `python` on your computer to invoke Python (Windows):
`python -m pip install --upgrade psghotkey`
#### If you use the command `python3` on your computer to invoke Python (Linux, Mac):
`python3 -m pip install --upgrade psghotkey`
### Using PIP with GitHub
You can also pip install the PySimpleGUI Applications that are in the PySimpleGUI GitHub account. The GitHub versions have bug fixes and new programs/features that have not yet been released to PyPI. To directly pip install from that repo:
#### If you use the command `python` on your computer to invoke Python (Windows):
```bash
python -m pip install --upgrade https://github.com/PySimpleGUI/psghotkey/zipball/main
```
#### If you use the command `python3` on your computer to invoke Python (Linux, Mac):
```bash
python3 -m pip install --upgrade https://github.com/PySimpleGUI/psghotkey/zipball/main
```
## Usage
Once installed, launch psghotkey by typing the following in your command line:
`psghotkey`
# 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](https://github.com/dchen327/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](https://github.com/PySimpleGUI/psgtray). The psgtray package is an important add-on to the tkinter port of PySimpleGUI as it enables you to run your applications in the system tray.
<p align="center"><p>
# Docstring Utilities
The reason that a hotkey was needed in the first place was a convenient 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:
```python
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:
```python
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
```python
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`.
```python
"""
: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.
## License & Copyright
Copyright 2023-2024 PySimpleSoft, Inc. and/or its licensors.
This is a free-to-use "Utility" and is licensed under the
PySimpleGUI License Agreement, a copy of which is included in the
license.txt file and also available at https://pysimplegui.com/eula.
Please see Section 1.2 of the license regarding the use of this Utility,
and see https://pysimplegui.com/faq for any questions.
## Contributing
We are happy to receive issues describing bug reports and feature
requests! If your bug report relates to a security vulnerability,
please do not file a public issue, and please instead reach out to us
at issues@PySimpleGUI.com.
We do not accept (and do not wish to receive) contributions of
user-created or third-party code, including patches, pull requests, or
code snippets incorporated into submitted issues. Please do not send
us any such code! Bug reports and feature requests should not include
any source code.
If you nonetheless submit any user-created or third-party code to us,
(1) you assign to us all rights and title in or relating to the code;
and (2) to the extent any such assignment is not fully effective, you
hereby grant to us a royalty-free, perpetual, irrevocable, worldwide,
unlimited, sublicensable, transferrable license under all intellectual
property rights embodied therein or relating thereto, to exploit the
code in any manner we choose, including to incorporate the code into
PySimpleGUI and to redistribute it under any terms at our discretion.
Raw data
{
"_id": null,
"home_page": "https://github.com/PySimpleGUI",
"name": "psghotkey",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "GUI UI PySimpleGUI tkinter psghotkey hotkey autohotkey",
"author": "PySimpleSoft Inc.",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/0d/ca/8c0740b1501489716f3437cf94e848f4abca8c1e4b943f20b422286d5910/psghotkey-5.0.0.tar.gz",
"platform": null,
"description": "<p align=\"center\">\r\n <p align=\"center\"><img width=\"238\" height=\"135\" src=\"https://pysimplegui.net/images/logos/psglogofull.svg\"><p>\r\n\r\n <h2 align=\"center\">psghotkey</h2>\r\n <h2 align=\"center\">A PySimpleGUI Application</h2>\r\n</p>\r\n\r\nWindows Hotkeys Tool\r\n\r\nTBD\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n<p align=\"center\"><img width=\"583\" height=\"415\" src=\"screenshot.gif\"><p>\r\n\r\n\r\n\r\n## Features\r\n\r\n* A complete hotkey manager\r\n* Demonstrates integrating the system tray into your application\r\n* Example sophisticated docstring formatting application of a hotkey\r\n\r\n\r\n## Installation\r\n\r\n### Using PIP with PyPI\r\n\r\nThe latest official release of PySimpleGUI products can be found on PyPI. To pip install the demo applications from PyPI, use this command\r\n\r\n#### If you use the command `python` on your computer to invoke Python (Windows):\r\n\r\n`python -m pip install --upgrade psghotkey`\r\n\r\n#### If you use the command `python3` on your computer to invoke Python (Linux, Mac):\r\n\r\n`python3 -m pip install --upgrade psghotkey`\r\n\r\n### Using PIP with GitHub\r\n\r\nYou can also pip install the PySimpleGUI Applications that are in the PySimpleGUI GitHub account. The GitHub versions have bug fixes and new programs/features that have not yet been released to PyPI. To directly pip install from that repo:\r\n\r\n#### If you use the command `python` on your computer to invoke Python (Windows):\r\n\r\n```bash\r\npython -m pip install --upgrade https://github.com/PySimpleGUI/psghotkey/zipball/main\r\n```\r\n\r\n#### If you use the command `python3` on your computer to invoke Python (Linux, Mac):\r\n\r\n```bash\r\npython3 -m pip install --upgrade https://github.com/PySimpleGUI/psghotkey/zipball/main\r\n```\r\n\r\n\r\n\r\n\r\n## Usage\r\n\r\nOnce installed, launch psghotkey by typing the following in your command line:\r\n\r\n`psghotkey`\r\n\r\n# Packages Used\r\n\r\nThis project uses these pip installable packages:\r\n* PySimpleGUI\r\n* psgtray\r\n* keyboard\r\n\r\n# Mash-up\r\n\r\nThis project is a mash-up of some PySimpleGUI demo programs and a program called [pingmote](https://github.com/dchen327/pingmote). The `pingmote` project is the origin of the keyboard handler. A big thank you to @dchen327 for the code and inspiration.\r\n\r\nThe system tray code is from the [psgtray](https://github.com/PySimpleGUI/psgtray). The psgtray package is an important add-on to the tkinter port of PySimpleGUI as it enables you to run your applications in the system tray.\r\n\r\n<p align=\"center\"><p>\r\n\r\n\r\n# Docstring Utilities\r\n\r\nThe reason that a hotkey was needed in the first place was a convenient 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.\r\n\r\nThe idea is to have a workflow that follows these steps:\r\n\r\n* Text with docstring is copied onto clipboard\r\n* Hotkey is pressed to invoke one of the docstring tools\r\n* The modified clipboard is pasted into the code\r\n\r\n## AlignDocstrings.py\r\n\r\nThis 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.\r\n\r\nAn example is the easiest way to show what it does.\r\n\r\n## Input\r\n\r\nThis is the input that is on the clipboard:\r\n\r\n```python\r\ndef execute_py_file(pyfile, parms=None, cwd=None, interpreter_command=None, wait=False, pipe_output=False):\r\n \"\"\"\r\n Executes a Python file.\r\n The interpreter to use is chosen based on this priority order:\r\n 1. interpreter_command paramter\r\n 2. global setting \"-python command-\"\r\n 3. the interpreter running running PySimpleGUI\r\n\r\n :param pyfile: the file to run\r\n :type pyfile: (str)\r\n :param parms: parameters to pass on the command line\r\n :type parms: (str)\r\n :param cwd: the working directory to use\r\n :type cwd: (str)\r\n :param interpreter_command: the command used to invoke the Python interpreter\r\n :type interpreter_command: (str)\r\n :param wait: the working directory to use\r\n :type wait: (bool)\r\n :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\r\n :type pipe_output: (bool)\r\n :return: Popen object\r\n :rtype: (subprocess.Popen) | None\r\n \"\"\"\r\n```\r\n\r\n## Output\r\n\r\n\r\nThis is the result that is left on the clipboard:\r\n\r\n```python\r\ndef execute_py_file(pyfile, parms=None, cwd=None, interpreter_command=None, wait=False, pipe_output=False):\r\n \"\"\"\r\n Executes a Python file.\r\n The interpreter to use is chosen based on this priority order:\r\n 1. interpreter_command paramter\r\n 2. global setting \"-python command-\"\r\n 3. the interpreter running running PySimpleGUI\r\n\r\n :param pyfile: the file to run\r\n :type pyfile: (str)\r\n :param parms: parameters to pass on the command line\r\n :type parms: (str)\r\n :param cwd: the working directory to use\r\n :type cwd: (str)\r\n :param interpreter_command: the command used to invoke the Python interpreter\r\n :type interpreter_command: (str)\r\n :param wait: the working directory to use\r\n :type wait: (bool)\r\n :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\r\n :type pipe_output: (bool)\r\n :return: Popen object\r\n :rtype: (subprocess.Popen) | None\r\n \"\"\"\r\n```\r\n\r\n\r\n## AddTypesToDocstring.py\r\n\r\nPyCharm 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.\r\n\r\nBut.... 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.\r\n\r\n## Input\r\n\r\n```python\r\ndef execute_py_file(pyfile, parms=None, cwd=None, interpreter_command=None, wait=False, pipe_output=False):\r\n \"\"\"\r\n\r\n :param pyfile:\r\n :param parms:\r\n :param cwd:\r\n :param interpreter_command:\r\n :param wait:\r\n :param pipe_output:\r\n :return:\r\n \"\"\"\r\n```\r\n\r\n\r\n## Output\r\n\r\nThis 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`.\r\n\r\n```python\r\n \"\"\"\r\n\r\n :param pyfile:\r\n :type pyfile:\r\n :param parms:\r\n :type parms:\r\n :param cwd:\r\n :type cwd:\r\n :param interpreter_command:\r\n :type interpreter_command:\r\n :param wait:\r\n :type wait:\r\n :param pipe_output:\r\n :type pipe_output:\r\n :return:\r\n :rtype:\r\n \"\"\"\r\n```\r\n\r\n# Windows Only (most likely)\r\n\r\n`psgtray` runs the best on Windows and is used in this project. It's not been tried on Linux nor the Mac.\r\n\r\n# Opportunities for Improvement\r\n\r\nNot 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.\r\n\r\nIn 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.\r\n\r\n\"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.\r\n\r\nI hope you are able to find something here that helps you create your own tools that makes you more efficient.\r\n\r\n## License & Copyright\r\n\r\nCopyright 2023-2024 PySimpleSoft, Inc. and/or its licensors.\r\n\r\nThis is a free-to-use \"Utility\" and is licensed under the\r\nPySimpleGUI License Agreement, a copy of which is included in the\r\nlicense.txt file and also available at https://pysimplegui.com/eula.\r\n\r\nPlease see Section 1.2 of the license regarding the use of this Utility,\r\nand see https://pysimplegui.com/faq for any questions.\r\n\r\n\r\n## Contributing\r\n\r\nWe are happy to receive issues describing bug reports and feature\r\nrequests! If your bug report relates to a security vulnerability,\r\nplease do not file a public issue, and please instead reach out to us\r\nat issues@PySimpleGUI.com.\r\n\r\nWe do not accept (and do not wish to receive) contributions of\r\nuser-created or third-party code, including patches, pull requests, or\r\ncode snippets incorporated into submitted issues. Please do not send\r\nus any such code! Bug reports and feature requests should not include\r\nany source code.\r\n\r\nIf you nonetheless submit any user-created or third-party code to us,\r\n(1) you assign to us all rights and title in or relating to the code;\r\nand (2) to the extent any such assignment is not fully effective, you\r\nhereby grant to us a royalty-free, perpetual, irrevocable, worldwide,\r\nunlimited, sublicensable, transferrable license under all intellectual\r\nproperty rights embodied therein or relating thereto, to exploit the\r\ncode in any manner we choose, including to incorporate the code into\r\nPySimpleGUI and to redistribute it under any terms at our discretion.\r\n",
"bugtrack_url": null,
"license": "Free To Use But Restricted",
"summary": "A Hotkey Manager using PySimpleGUI and psgtray",
"version": "5.0.0",
"project_urls": {
"Homepage": "https://github.com/PySimpleGUI"
},
"split_keywords": [
"gui",
"ui",
"pysimplegui",
"tkinter",
"psghotkey",
"hotkey",
"autohotkey"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fe7bf371b1679617acbb110a085ad13488d3556ebc26186f868af72351a95976",
"md5": "989c001eddcf0196c194dcaa74840313",
"sha256": "99b732c61480dad1b25b2a6a513fd5a4497914f672a8893e9ea63baa5d29366a"
},
"downloads": -1,
"filename": "psghotkey-5.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "989c001eddcf0196c194dcaa74840313",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 1075413,
"upload_time": "2024-02-26T15:38:48",
"upload_time_iso_8601": "2024-02-26T15:38:48.052239Z",
"url": "https://files.pythonhosted.org/packages/fe/7b/f371b1679617acbb110a085ad13488d3556ebc26186f868af72351a95976/psghotkey-5.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0dca8c0740b1501489716f3437cf94e848f4abca8c1e4b943f20b422286d5910",
"md5": "8d744afff7fbff25b65939858fddbf16",
"sha256": "ff4b88ed51aebbe5166502aae3c8d75095aa80dee4e6d5736f8cba5622de978b"
},
"downloads": -1,
"filename": "psghotkey-5.0.0.tar.gz",
"has_sig": false,
"md5_digest": "8d744afff7fbff25b65939858fddbf16",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 1078537,
"upload_time": "2024-02-26T15:38:51",
"upload_time_iso_8601": "2024-02-26T15:38:51.528417Z",
"url": "https://files.pythonhosted.org/packages/0d/ca/8c0740b1501489716f3437cf94e848f4abca8c1e4b943f20b422286d5910/psghotkey-5.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-26 15:38:51",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "psghotkey"
}