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
[Bug/Question] First Window Finalize is Slower Than Subsequent #4977
Comments
IMO, the import time for tkinter or PySimpleGUI should be less than 0.2 seconds. Script is ready to accept user input only after the GUI ready. |
tkinter cannot be run as a thread. Can you share some quantified data? What's slow to one person is incredibly fast to another. It would be helpful to know the values we're working with. Maybe take a moment to write the code described in the block of text. I can't run a block of text. So many things, as I'm sure you're very aware, impact the speed. Everything from your hardware to caching at various levels, the specific version of PySimpleGUI and tkinter, etc. I'm interested in the timing values you get from the initial load and then the subsequent ones as well. Thanks for taking the time to open this issue. It's a good discussion to have. |
The This is not a problem in the all elements demo program so I suspect it's a combination of images that's causing the issue. It's extremely difficult to recreate a demo that mimics my application without requiring the bloat. But I'll try to do my best. |
Okay I updated the code, you will also need to download https://raw.githubusercontent.com/elibroftw/music-caster/master/src/b64_images.py for the base64 images I used in the example.
|
One source (0.047 seconds) comes from frame, *others = inspect.stack()[1] # 0.046 seconds for first run, This can be replaced with frame = inspect.currentframe().f_back # 0 seconds
# OR
frame = inspect.stack(0)[1][0] # 0 seconds |
|
I got all the way to |
Makes sense and they're reasonable numbers overall. 158ms startup time is faster than I thought it would be. Performance tuning has had 0 cycles spent to date. I've fixed a couple of spots that were slow, but no further than that. Still in the first 2 of the "1. Make it run. 2. Make it right. 3. Make it fast." progression. .. and thank you for tracking down a couple of the slower spots currently. You've gone further than I am able to at the moment so thanks for taking the time. |
💗 that you've really utilized this capability. None of my projects have separate image files except to provide the originals that were used to make the encoded byte-strings, and lately some ICO files so that the |
Sorry do you know how to change it back without changing the button theme? |
I don't know what that means. I would open another issue if you're stumped. There are detailed release notes for each release going back to July 2018 in the documentation, and PyPI has releases going back a number of years. https://pysimplegui.readthedocs.io/en/latest/#release-notes Maybe Combo Elements are tricky because they use a TTK widget, which means a complex can of worms. They're not as simple as the Tk widgets. |
I found a workaround. I manually set the button colors for some buttons but set the button color theme to what I want for combos. |
If there's not an enhancement on being able to set the colors, feel free to open one |
I'm thinking this kind of interface: layout = [ [sg.Text('My Window')],
[sg.Input(key='-IN-')],
[sg.Combo((1,2,3,4,5,6,7,8,9), size=(5,5))],
[sg.Combo((1,2,3,4,5,6,7,8,9), size=(5,5), button_arrow_color='yellow', button_background_color='red')],
[sg.Combo((1,2,3,4,5,6,7,8,9), size=(5,5), button_arrow_color='red', button_background_color='yellow')],
[sg.Combo((1,2,3,4,5,6,7,8,9), size=(5,5))],
[sg.Text(size=(12,1), key='-OUT-')],
[sg.Button('Go'), sg.Button('Exit')] ] |
Yeah, that'd be optimal, but implement at your own pace. |
I've added the details of the combo change to this enhancement issue: Enjoy! |
Type of Issue (Enhancement, Error, Bug, Question)
Question / bug
Operating System
Windows
PySimpleGUI Port (tkinter, Qt, Wx, Web)
Tkinter
Versions
Version information can be obtained by calling
sg.main_get_debug_data()
Or you can print each version shown in ()
Latest
Python version (
sg.sys.version
)3.10
PySimpleGUI Version (
sg.__version__
)Latest
GUI Version (tkinter (
sg.tclversion_detailed
), PySide2, WxPython, Remi)Latest tkinter
Your Experience In Months or Years (optional)
Years Python programming experience ~6
Years Programming experience overall ~6
Have used another Python GUI Framework? (tkinter, Qt, etc) (yes/no is fine)
Yes
Anything else you think would be helpful?
No
Troubleshooting
These items may solve your problem. Please check those you've done by changing - [ ] to - [X]
Detailed Description
The issue is that the first time the Gui needs to open, it is Slower to open that if I close and open it the second time. I think this has to do with tkinter being initialized the first time I create the window so I was wondering if it's possible to preload tkinter in a thread as soon as psg is imported in order to avoid the 1 second extra delay when the Gui needs to be opened for the first time?
Code To Duplicate
A short program that isolates and demonstrates the problem (Do not paste your massive program, but instead 10-20 lines that clearly show the problem)
This pre-formatted code block is all set for you to paste in your bit of code:
Screenshot, Sketch, or Drawing
Watcha Makin?
If you care to share something about your project, it would be awesome to hear what you're building.
The text was updated successfully, but these errors were encountered: