robertlugg / easygui

easygui for Python
http://easygui.readthedocs.org/en/master/
BSD 3-Clause "New" or "Revised" License
451 stars 114 forks source link

Bugfix: pressing arrows generates `AttributeError` #222

Closed tomhea closed 9 months ago

tomhea commented 9 months ago

More info about the bug: I used the easygui.enterbox, and while pressing the left/right/up/down arrows - easygui generated these weird errors to me:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\tomhe\AppData\Local\Programs\Python\Python311\Lib\tkinter\__init__.py", line 1948, in __call__
    return self.func(*args)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\tomhe\AppData\Local\Programs\Python\Python311\Lib\site-packages\easygui\boxes\base_boxes.py", line 23, in tabRight
    boxRoot.event_generate("<Tab>")
    ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'event_generate'

It seems like the exact problem in #170.

This Pull Request is a solution to that problem. I tested it and it works for me. It's only two new ifs to the codebase so it should be very simple to verify.

I also strongly believe that this bugfix should be deployed now by creating version 0.98.4 (I know I would love to use this library with the fixed bug).

zadacka commented 9 months ago

Hi Tom, thanks for the bug report and the PR. It’s frustrating that there is a condition in which ‘boxRoot’ is none - so it may be that we’re masking a problem by checking it at this point.

That said - the fix you have here is nicely minimal and looks to do exactly what you’ve described.

I can review / approve now (on mobile) but am travelling so can’t rebuild a point version until I’m back with proper PC access - so getting a patched version out may take a few days. Hope that’s ok - and thank you for your input!

tomhea commented 8 months ago

Hi, is there a chance that you can rebuild a new version? :)