Longer process time when using hotkey

43 Views Asked by At

I have a Tkinter Frame with a tksheet (https://github.com/ragardner/tksheet, version: 30th June 2021) (actully 8 tksheets on 8 tabs). When I refresh the sheet(s) (clear content and fill it again) with the button, the process time is very low and you can't even see the update process but when I use the hotkey, in this case ctrl+s, the refresh of the active sheet takes much longer (still much less than a second) when the same method is called by the hotkey functionality of the keyboard library (0.13.5) and you can see that an update of the sheet is done. I tried to set the focus on different widgets while hitting ctrl+s but the behavior didn't change. Anyone an idea why and how to accelerate it?

Additional information:

  • keyboard.add_hotkey("ctrl+s", self.onRefresh)
  • Python version: 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)] on win32
  • OS: Windows 10 Enterprise
  • Because of the distribution of the Python runtime, I didn't install both libraries (tksheet, keyboard) with pip but I created a lib directory in the project and copied the downloaded libraries manually.

I measured the time for the method which refreshes the tksheets with time.process_time() :

Tab A active and button clicked:

1: 0.0
2: 0.0
3: 0.0
4: 0.0
5: 0.0
6: 0.0
7: 0.0
8: 0.0

Tab A active and ctrl+s:

1: 0.140625
2: 0.0
3: 0.0
4: 0.0
5: 0.015625
6: 0.0
7: 0.0
8: 0.0

Tab B active and ctrl+s:

1: 0.015625
2: 0.15625
3: 0.015625
4: 0.0
5: 0.0
6: 0.0
7: 0.0
8: 0.0

Tkinter window with tksheet

0

There are 0 best solutions below