Skip to content
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

Set "DefExt" argument in Win32FileChooser run method. #824

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions plyer/platforms/win/filechooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ def run(self):
filters += f[0] + "\x00" + ";".join(f[1:]) + "\x00"
args["Filter"] = filters

# === PATCH ===
# Set the default extension using the value from the first filter.
# A side-effect of this is the dialog will append the currently
# selected filter extension to the filename if the user does not provide one.
if self.filters:
# get the characters of the first filter (after the .)
args["DefExt"] = self.filters[0][1].partition(".")
# === END PATCH ===

flags = win32con.OFN_OVERWRITEPROMPT
flags |= win32con.OFN_HIDEREADONLY

Expand Down