Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thanks for the inspiration and code! #21

Open
PySimpleGUI opened this issue Jul 20, 2021 · 4 comments
Open

Thanks for the inspiration and code! #21

PySimpleGUI opened this issue Jul 20, 2021 · 4 comments

Comments

@PySimpleGUI
Copy link

Hiya David. I wanted to take a moment to say "thank you" for being an inspiration and also for providing code that I used to make a new PySimpleHotKey program.

It's far from perfect, but it's turning out to be making a big impact already on my efficiency and abilities.

It's one thing to have a hotkey program that enables you to launch programs, etc, but it's entirely different when you've got complete control of that program and the actions. Being able to call PySimpleGUI code directly from the HotKey manager is AWESOME. Same with being able to control how it operates in the system tray.

There's a public version of it posted, and there's a private version I use. This is the private table settings that I'm using:

# Defintions of the hotkeys
DOCSTRING_SHORTCUT = 'ctrl+alt+shift+d'
DOCSTRING_TYPES_SHORTCUT = 'ctrl+alt+shift+f5'
KOLYA_SHORTCUT = 'alt+shift+k'
MILKA_SHORTCUT = 'ctrl+alt+shift+m'
POPUP_SHORTCUT = 'ctrl+alt+shift+f6'

# Special keys for PySimpleGUI to take action
POPUP_EMOJIS = '-POPUP EMOJIS-'

# dictionary that maps a hotkey to an action
hotkey_dict = {
    DOCSTRING_SHORTCUT :        (lambda :  sg.execute_py_file(r'DocstringTools\AlignDocstrings.py', '--clipboard', cwd='.')),
    DOCSTRING_TYPES_SHORTCUT :  (lambda :  sg.execute_py_file(r'DocstringTools\AddTypesToDocstring.py', cwd='.')),
    KOLYA_SHORTCUT:             (lambda: keyboard.write('Коля')),
    MILKA_SHORTCUT:             (lambda: keyboard.write('Милка')),
    POPUP_SHORTCUT:             (lambda: show_popup_at_cursor(POPUP_EMOJIS))
                }

You did a fantastic job of showing me a nice design pattern as well as providing a way to specify and parse the keystrokes.

I'm using this program to:

  • Insert text
  • Launch some utilities that work on the clipboard
  • Show a simple emoji chooser (sort of like pingmote, but much more direct)

The point I want to make is that anyone, regardless of skill level, can be a contributor to the greater good of the programming world. You don't have to be someone with decades of experience to have a substantial and positive impact. You did this with your pingmote program. Thank you for creating it and making it available to everyone.

I'll close with an example of your hotkey inspired emoji chooser that was used to add the little guy at the bottom:

46rLq4V29z

image

@dchen327
Copy link
Owner

dchen327 commented Jul 20, 2021 via email

@PySimpleGUI
Copy link
Author

Yea, I'm familiar with AutoHotKey. A friend suggested it a few days back. I've used countless hotkey managers over the decades. In fact, I'm still running one of them called HotKeyBind. It was your code that I started to tack some shortcuts onto that got me to realize that it is not difficult to just make my own which is what let to PySimpleHotkey over the weekend.

I'm a tool lover for sure, which my tools folder at a total of:
image

folders worth of tools... and many of those are by manufacturer. I've always been a "mosiac of tools" kind of person where I use many tools to stitch together my quilt of tools rather than trying to use / find a single monolithic tool.

PySimpleGUI really caused my toolsmithing to explode though. I quickly replaced Rainmeter as it's trivial to make a "desktop widget" using PySimpleGUI.

Totally with you on the laziness, which is why I wasn't keen on learning another language, like a scripting language when I've got Python and PySimpleGUI right under my fingertips.

My point this weekend with PySimpleHotkeys is that it was created by gluing together a number of Demo programs. Because of the PySimpleGUI coding guidelines and the architecture, the parts fit together really well.

I've been struggling a bit today to detect and kill previously running hotkey copies, but I just solved the problem after I discovered a debugging method I hadn't used before with subprocesses...the PySimpleGUI Debug Window. I'm going to write up a Cookbook entry / announcement / Tweet about it. I was surprised I had never tried it. I was struggling with these programs started using the PySimpleGUI exec apis because I don't see the output because they have no console. All I had to do was set

print= = sg.Print

while I was debugging those programs and suddenly I had all the debug info I needed.

I'm doing a lot with Automation right now with this new PySimpleGUIQt testing. Trying to make it so that all of the ports can be more easily tested.

Anyway, thanks again for the inspiration.

I added an integration with pyuautogui today so that it's easier for me to add emoji's to my posts... like here:
image

Thanks again! Keep building... you've got great instincts, curious and thus innovation often results.

@dchen327
Copy link
Owner

The print = sg.Print is brilliant -- I'll definitely have to steal that sometime in the future :)
Good luck with PySimpleGUIQt!

@PySimpleGUI
Copy link
Author

If you don't want to "shadow" the print call by reassigning print, then you can set a parameter in the call to sg.Print to reroute stdout:

sg.Print('', do_not_reroute_stdout=False)

After that, all prints will go to the debug window.

DdhteYwiwj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants