Skip to content

[Question] bind_return_key does not work with Combo #4244

@starrry123

Description

@starrry123

Type of Issue (Enhancement, Error, Bug, Question)

Question


Operating System

Windows

PySimpleGUI Port (tkinter)


Versions

Version information can be obtained by calling sg.main_get_debug_data()
Or you can print each version shown in ()

Python version (3.7.4)

PySimpleGUI Version (4.40.0)

GUI Version (tkinter)


Your Experience In Months or Years (optional)

Years Python programming experience

Years Programming experience overall

Have used another Python GUI Framework? (tkinter, Qt, etc) (yes)

Anything else you think would be helpful?


Troubleshooting

These items may solve your problem. Please check those you've done by changing - [ ] to - [X]

  • Searched main docs for your problem www.PySimpleGUI.org
  • Looked for Demo Programs that are similar to your goal Demos.PySimpleGUI.org
  • 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
  • Tried using the PySimpleGUI.py file on GitHub. Your problem may have already been fixed but not released

Detailed Description

bind_return_key works with sg.Input, however it does not seems to work with Combo.

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:

# Paste your code here
import PySimpleGUI as sg


layout = [ [sg.Txt('Calculate 1/x:')],
           [sg.Combo(size=(8,1), key='-DENOMINATAOR-',values='1') ],
           [sg.Txt(size=(8,1), key='-OUTPUT-')  ],
           [sg.Button('Calculate', bind_return_key=True)]]

window = sg.Window('Math', layout)

while True:
    event, values = window.read()

    if event != sg.WIN_CLOSED:
        try:
            denominator = float(values['-DENOMINATAOR-'])
            calc = 1/denominator
        except:
            calc = 'Invalid'

        window['-OUTPUT-'].update(calc)
    else:
        break

Screenshot, Sketch, or Drawing

2021-05-03 09_20_38-

Metadata

Metadata

Assignees

No one assigned

    Labels

    Done - Install Dev Build (see docs for how)See https://docs.pysimplegui.com/en/latest/documentation/installing_licensing/upgrading/enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions