PySimpleGUI / PySimpleGUI/PySimpleGUI
[Bug] Multiline element not generating events for pressing enter when enter_submits=True
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 13.8k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
Type of Issue (Enhancement, Error, Bug, Question)
Bug
Operating System
Windows 11
PySimpleGUI Port (tkinter, Qt, Wx, Web)
tkinter
Versions
Python version: 3.11.6 (tags/v3.11.6:8b6ee5b, Oct 2 2023, 14:57:12) [MSC v.1935 64 bit (AMD64)]
port: tkinter
tkinter version: 8.6.12
PySimpleGUI version: 4.60.5
PySimpleGUI filename: c:\Users\XXX\venv\Lib\site-packages\PySimpleGUI\PySimpleGUI.py
Troubleshooting
- Searched main docs for your problem www.PySimpleGUI.org
- Looked for Demo Programs that are similar to your goal. It is recommend you use the Demo Browser! Demos.PySimpleGUI.org
- None of your GUI code was generated by an AI algorithm like GPT
- If not tkinter - looked for Demo Programs for specific port
- For non tkinter - Looked at readme for your specific port if not PySimpleGUI (Qt, WX, Remi)
- Run your program outside of your debugger (from a command line)
- Searched through Issues (open and closed) to see if already reported Issues.PySimpleGUI.org
- Have upgraded to the latest release of PySimpleGUI on PyPI (lastest official version)
- Tried using the PySimpleGUI.py file on GitHub. Your problem may have already been fixed but not released
Detailed Description
The argument enter_submits=True in Multiline is not causing events to be generated upon hitting the Return key.
- When
enable_events=Trueandenter_submits=Falsethe Return key generates an event like all other key-presses. - When
enable_events=Trueandenter_submits=Trueno event is generated by the Return key. A new line is generated in the window.
Code To Duplicate
import PySimpleGUI as sg
def make_layout(enable_events: bool, enter_submits: bool) -> sg.Multiline:
value = f"{enable_events=}, {enter_submits=}"
return sg.Multiline(
value,
size=(20, 5),
enable_events=enable_events,
enter_submits=enter_submits,
key=value,
)
layout = [
[make_layout(False, False), make_layout(False, True)],
[make_layout(True, False), make_layout(True, True)],
]
window = sg.Window(
title="Various combinations of multiline options", layout=layout, finalize=True
)
while True:
event, values = window.read()
if event == sg.WIN_CLOSED:
break
print(f"Got event: {event}, with value: '{values[event]}'")
window.close()
Screenshot, Sketch, or Drawing
Neither of the multiline boxes in the right column generate events when the Enter key is pressed. The enable_events=True, enter_submits=False box in the lower left does.
Apologies if this is user error and not a bug.
Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided tkinter reproduction and trace the Multiline handling for enable_events=True with enter_submits=True. Compare it with the working enter_submits=False case; done means pressing Enter generates an event while preserving the intended enter_submits behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100