PySimpleGUI / PySimpleGUI/PySimpleGUI

[Question] No event generated when target=(None, None) for FileBrowse

Open
#2,421 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation
Dominant language
Python
Stars
13.8k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

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

When I put Text and FileBrowse at same line, file path selected will be shown on Text. To stop it, I add target = (None, None), then no event generated.
If not put Text and FileBrowse at the same line, I don't need option target and work well.
Why no event generated when target=(None, None) and enable_events=True ?

Operating System

Win 10

Python version

Python 3.7.2

PySimpleGUI Port and Version

PySimpleGUI 4.14.0

You have completed these steps:
  • Read instructions on how to file an Issue
  • Searched through main docs http://www.PySimpleGUI.org for your problem
  • Searched through the readme for your specific port if not PySimpleGUI (Qt, WX, Remi)
  • Looked for Demo Programs that are similar to your goal http://www.PySimpleGUI.com
  • Note that there are also Demo Programs under each port on GitHub
  • Run your program outside of your debugger (from a command line)
  • Searched through Issues (open and closed) to see if already reported
Code or partial code causing the problem
import PySimpleGUI as sg

font1 = 'Courier 16'
font2 = 'Courier 12'

layout = [[sg.Text('Select File to check', font=font1),
           sg.FileBrowse(
                'Browse', target=(None, None),
                file_types=[("All Python Files", "*.py")],
                enable_events=True, size=(10,1), font=font1, key='-Browse-')],
          [sg.Output(size=(120, 30), font=font2, key='-Output-')]]

window = sg.Window('test', layout=layout, finalize=True)

while True:

    event, values = window.read()
    print(event, values)

    if event is None:
        break

    if event == '-Browse-':
        path = values['-Browse-']
        f = open(path, 'rt', encoding='utf-8')
        lines = f.readlines()
        for line in lines:
            print(line.strip())

window.close()

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided Python snippet and trace FileBrowse's handling of target=(None, None) together with enable_events=True. Determine whether the documented behavior or event dispatch should change, then verify the chosen behavior with a focused reproduction or test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.