-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Hidden behavior : No event on FolderBrowse button #1553
Comments
The target by default for these buttons is the input field to the left of the button, as described in the docs. These buttons do not generate events by design. The color and date choosers also have this behavior. Should you want an event generated when the user completes choosing a file, folder, color, etc, then set the |
Can we confirm that enable_events on the FolderBrowse button is activating? I'm having difficulty getting my program to recognize there is an event when they select the FolderBrowse button, like so: contlabel_layout = [[sg.Text("Export Container Labels", font=("Roboto", 14))],
[sg.Button(button_text="EXPORT", key="_EXPORT_LABEL_")],
[sg.Text("Options", font=("Roboto", 11))],
[sg.Button(button_text="Open Output", key="_OPEN_LABEL_DEST_")],
[sg.FolderBrowse("Choose Output Folder:", enable_events=True, key="_OUTPUT_DIR_LABEL_",
initial_folder=defaults["labels_export_default"]),
sg.InputText(defaults["labels_export_default"], key="_OUTPUT_DIR_LABEL_INPUT_")]
]
window_simple = sg.Window("ArchivesSpace EAD Export/Cleanup/Upload Program", contlabel_layout)
while True:
event_simple, values_simple = window_simple.Read()
# More code here
if event_simple == "_OUTPUT_DIR_LABEL_":
with open("defaults.json", "w") as defaults_labels:
print(values_simple["_OUTPUT_DIR_LABEL_"])
defaults["labels_export_default"] = values_simple["_OUTPUT_DIR_LABEL_"]
json.dump(defaults, defaults_labels)
defaults_labels.close() |
Don't use the enable events for folder browse. As described above and I think in the cookbook as well, the technique to do this now is to set as the target an invisible input element. Then set events for the input element. Sorry for the confusion. I'll make a note in the docstrings so that it's not used. If the button itself is the target, then it will likely generate the event. The way to set the button as the target is to use (None, None). But I wouldn't do that. Use an invisible Input Element as the target with enable events set on it and you'll be good. |
See the entry prior to yours:
I'm really sorry that PySimpleGUI has been an evolution. Old parms have to stay in place for backward compatibility, but it can lead to difficult to understand situations. |
I should have read that part more closely, my bad. Thank you for the swift response! I put enable_events on my input element and it works very elegantly. |
I'm impressed you searched for and found this Issue! No bad on your part bud.... it's on me for this one :-) |
Please put a empty target by default and let the filebrowse and folderbrowse have their own events.
This part is breaking with the rest of the API simplicity. it is hard to understand because it is not in the text of the code and is different from the other buttons. For no reason from the user perspective.
The text was updated successfully, but these errors were encountered: