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
[Question] Button Refresh Slow #6674
Comments
Call method |
I have tried refresh right after the update and it does not work. just put in 3 different spots and 4 sec delay to the button colour change. Previously thought that was the answer but did not fix it.
|
Can you post a script, short and executable to demo your question ? Maybe something like this from random import choice
import PySimpleGUI as sg
layout = [
[sg.Image(filename='', key='image')],
[sg.Button('Exit'),
sg.Button('',image_data=sg.EMOJI_BASE64_GUESS, key='-RY-', button_color=(sg.theme_background_color(), sg.theme_background_color()), border_width=0)],
]
window = sg.Window("OpenCV", layout, alpha_channel=0)
show = 1
while True:
event, values = window.read(timeout=10)
if event == sg.WIN_CLOSED:
break
elif event == sg.TIMEOUT_EVENT:
show = not show
if show:
window['image'].update(data=choice(sg.EMOJI_BASE64_LIST))
window.set_alpha(1)
window['-RY-'].update(image_data=choice(sg.EMOJI_BASE64_LIST))
else:
print(event, values)
window.close() |
I removed the 2 reads from the Arduino on USB and it works. Simulated the reads swapping from Yellow to Red and back. To get into the second window press the red Off button on the first window. Need a Cam though.
|
So why do the USB comms reads of Arduino pins stop/delay the window button update? Interesting. May have turned into a Firmata issue? |
I cannot run you code for hardware issue. IMO, maybe the execution of your script blocked at some statements, like the USB comms reads or else. It will be better to do them under sub-thread and call Refer Issue #5521 |
My issue was that the Arduino read was asynchronous. I looked at your suggested thread examples and got a thread running. I plan now to return the thread when the read changes a value.Sent from my iPadOn 15 Feb 2024, at 2:42 am, Jason Yang ***@***.***> wrote:
I cannot run you code for hardware issue.
IMO, maybe the execution of your script blocked at some statements, like the USB comms reads or else. It will be better to do them under sub-thread and call window.write_event_value to generate an event to update the GUI under your event loop.
Refer Issue #5521
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Type of Issue (Enhancement, Error, Bug, Question)
Question
Environment
Operating System
Windows version ('11', '10.0.22621', 'SP0', 'Multiprocessor Free')
PySimpleGUI Port (tkinter, Qt, Wx, Web)
tkinter
Versions
Python version (
sg.sys.version
)3.12.1 (tags/v3.12.1:2305ca5, Dec 7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)]
PySimpleGUI Version (
sg.__version__
)4.60.5
GUI Version (tkinter (
sg.tclversion_detailed
), PySide2, WxPython, Remi)8.6.13
Your Experience In Months or Years (optional)
<1 Years Python programming experience
40+ Years Programming experience overall
No Have used another Python GUI Framework? (tkinter, Qt, etc) (yes/no is fine)
just came back to programming after retirement. Started in IBM assembler in late 70s.
Troubleshooting
These items may solve your problem. Please check those you've done by changing - [ ] to - [X]
Detailed Description
I have a Cam window that I want to use as a reversing camera. I have an Arduino attached by USB that I want to show an 'LED' button changing from Green to Yellow to Red etc. The red LED is on pin 5, whilst the Yellow is on pin 8.
It works, but updates button very slowly. Judging by my print statements, it loops many times before updating the button colour. It appears to me that the button changes are stacking up. Researched this for many weeks...but cannot work it out.
Cannot really supply a working program due to the Arduino USB interface.
Code To Duplicate
Screenshot, Sketch, or Drawing
The text was updated successfully, but these errors were encountered: