dchen327 / pingmote

Cross-platform Python global emote picker to quickly insert custom images/gifs
MIT License
25 stars 3 forks source link

Wow! Amazing work! Reporting a tkinter crash, a 3.6 issue, and a menu suggestion..... #12

Closed PySimpleGUI closed 3 years ago

PySimpleGUI commented 3 years ago

How about starting with the recognition that you've done a really amazing thing here. Congrats. I'm SURE I'll learn a few things from you.

:::'###::::'##::::'##::::'###::::'########:'####:'##::: ##::'######:::
::'## ##::: ###::'###:::'## ##:::..... ##::. ##:: ###:: ##:'##... ##::
:'##:. ##:: ####'####::'##:. ##:::::: ##:::: ##:: ####: ##: ##:::..:::
'##:::. ##: ## ### ##:'##:::. ##:::: ##::::: ##:: ## ## ##: ##::'####:
 #########: ##. #: ##: #########::: ##:::::: ##:: ##. ####: ##::: ##::
 ##.... ##: ##:.:: ##: ##.... ##:: ##::::::: ##:: ##:. ###: ##::: ##::
 ##:::: ##: ##:::: ##: ##:::: ##: ########:'####: ##::. ##:. ######:::
..:::::..::..:::::..::..:::::..::........::....::..::::..:::......::::
'##:::::'##::'#######::'########::'##:::'##:'####:
 ##:'##: ##:'##.... ##: ##.... ##: ##::'##:: ####:
 ##: ##: ##: ##:::: ##: ##:::: ##: ##:'##::: ####:
 ##: ##: ##: ##:::: ##: ########:: #####::::: ##::
 ##: ##: ##: ##:::: ##: ##.. ##::: ##. ##::::..:::
 ##: ##: ##: ##:::: ##: ##::. ##:: ##:. ##::'####:
. ###. ###::. #######:: ##:::. ##: ##::. ##: ####:
:...::...::::.......:::..:::::..::..::::..::....::

Threading

I am unsure how you're handling threads, but it appears one of them is attempting to perform calls into PySimpleGUI.

This MAY sometimes work.... for a while.... until you get something like this that shows up:

Traceback (most recent call last):
  File "X:\Python\Python37\lib\site-packages\keyboard\_generic.py", line 22, in invoke_handlers
    if handler(event):
  File "C:/Python/PycharmProjects/GitHub/pingmote/pingmote.py", line 249, in custom_hotkey
    func()
  File "C:/Python/PycharmProjects/GitHub/pingmote/pingmote.py", line 265, in on_activate
    self.show_gui()
  File "C:/Python/PycharmProjects/GitHub/pingmote/pingmote.py", line 258, in show_gui
    self.window.un_hide()
  File "C:\Python\PycharmProjects\PSG\PySimpleGUI.py", line 9181, in un_hide
    self.TKroot.deiconify()
  File "X:\Python\Python37\lib\tkinter\__init__.py", line 1818, in wm_deiconify
    return self.tk.call('wm', 'deiconify', self._w)
RuntimeError: main thread is not in main loop
Traceback (most recent call last):
  File "X:\Python\Python37\lib\site-packages\keyboard\_generic.py", line 22, in invoke_handlers
    if handler(event):
  File "C:/Python/PycharmProjects/GitHub/pingmote/pingmote.py", line 249, in custom_hotkey
    func()
  File "C:/Python/PycharmProjects/GitHub/pingmote/pingmote.py", line 265, in on_activate
    self.show_gui()
  File "C:/Python/PycharmProjects/GitHub/pingmote/pingmote.py", line 258, in show_gui
    self.window.un_hide()
  File "C:\Python\PycharmProjects\PSG\PySimpleGUI.py", line 9181, in un_hide
    self.TKroot.deiconify()
  File "X:\Python\Python37\lib\tkinter\__init__.py", line 1818, in wm_deiconify
    return self.tk.call('wm', 'deiconify', self._w)
RuntimeError: main thread is not in main loop

The mechanism that PySimpleGUI provides is a call that enables you to communicate from a thread to any window. The call is:

window.write_event_value('-TheEvent-', some_values)

It causes your read call to return with the event and a value added to your values dictionary. If you need to pass back multiple values, no problem, the value can be a tuple, dictionary, etc.

The latest PySimpleGUI on GitHub has an important fix to this method. It will be released to PyPI this weekend.

Python 3.6 problem

This was only discovered very recently... this past week... by the PySimpleGUI team. I initially ran into it working with the new PIL book, and then Jason tracked it down. Some PNG files have something in them that causes tkinter to not be happy. Upgrading to 3.7 fixes it.


Right Click Menu

I love the hotkey idea! Nice work. Exiting the program was problematic until I dug further into the instructions (i.e. I read instead of continuing to randomly trying stuff).

I ended up adding a right-click menu to your window. This enabled a few things

Here is what your program looks like with this right click menu

image


Storing images

I put my images on GitHub and was able to add them to your links.txt file. It wasn't clear to me if that would work or not. It worked out great!

https://raw.githubusercontent.com/PySimpleGUI/PySimpleGUI/master/images/emojis/happy_112.png


Thank you again for the inspiration! Keep building stuff!!