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] How to trap an event #6738
Comments
pysimpleissue
bot
added
Fill issue form or you will be REJECTED
You MUST use the supplied template to submit a request.
PySimpleGUI Issues Bot Has Detected an Error
labels
Apr 8, 2024
jason990420
changed the title
[ Enhancement/Bug/Question] NOTE - you can also call sg.main() or sg.main_open_github_issue() to post an issue
[Question] How to trap an event
Apr 8, 2024
pysimpleissue
bot
removed
Fill issue form or you will be REJECTED
You MUST use the supplied template to submit a request.
PySimpleGUI Issues Bot Has Detected an Error
labels
Apr 8, 2024
Some options to element or sg.Window, refer Tkinter Port Call Reference
Revised code import PySimpleGUI as sg
layout = [
[sg.Text('Name: ',justification='right',tooltip="Name 3-31 Char") ,sg.InputText(size=(31,1), enable_events=True, key="Name")],
[sg.Text('Age: ', justification='right', tooltip="Age 16-99"), sg.InputText(size=(3, 1), enable_events=True, key="Age")],
[sg.Button("Update"), sg.Button("Exit")],
]
winx = sg.Window('Simple data entry window', layout, enable_close_attempted_event=True)
while True:
event, values = winx.read() # Display Window & wait for an event
if event == 'Exit' or event == sg.WINDOW_CLOSE_ATTEMPTED_EVENT: # Exit button or upper left X
break
if event == 'Name' : # THIS DOESN'T Trap Name Entry
print('Name Validation:', values[event])
if event == 'Age' : # THIS DOESN'T Trap Age Entry
print('Age Validation:', values[event])
winx.close() |
jason990420
added
question
Further information is requested
Port - TK
PySimpleGUI
labels
Apr 8, 2024
This Demo Program does input validation: You can also run it from the eCookbook here: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Type of Issue (Enhancement, Error, Bug, Question)
Question
Operating System
ubuntu 22.04
PySimpleGUI Port (tkinter, Qt, Wx, Web)
tkinter
Versions 5
Version information can be obtained by calling
sg.main_get_debug_data()
Or you can print each version shown in ()
Python version (
sg.sys.version
)3,12
PySimpleGUI Version (
sg.__version__
)5
GUI Version (tkinter (
sg.tclversion_detailed
), PySide2, WxPython, Remi)5
Your Experience In Months or Years (optional)
Years Python programming experience6 months
Years Programming experience overall40 years
Have used another Python GUI Framework? (tkinter, Qt, etc) (yes/no is fine)no
Anything else you think would be helpful?
Troubleshooting
These items may solve your problem. Please check those you've done by changing - [ ] to - [X]
Detailed Description
How to Trap an event when user enters a field ?
Code To Duplicate
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. Small home project
The text was updated successfully, but these errors were encountered: