classification
Title: IDLE: Fix open/saveas 'Files of type' choices
Type: behavior Stage: resolved
Components: IDLE Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: eli.bendersky, gpolo, kbk, md1512, taleinat, terry.reedy
Priority: normal Keywords: easy, patch

Created on 2010-07-11 00:44 by terry.reedy, last changed 2010-11-23 06:49 by terry.reedy. This issue is now closed.

Files
File name Uploaded Description Edit
IOBinding.py md1512, 2010-07-11 17:42 IOBinding.py fixed for python3.1
issue9122.1.patch eli.bendersky, 2010-07-12 18:17 review
Messages (11)
msg109951 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-07-11 00:44
In the open and save-as dialog boxes, the choices for the 'Files of type' field are governed by the filetypes list in Lib\idlelib\IOBinding.py, about line 225 (found by a friend).

    filetypes = [
        ("Python and text files", "*.py *.pyw *.txt", "TEXT"),
        ("All text files", "*", "TEXT"),
        ("All files", "*"),
        ]

I see multiple problems with this:

1. The first line, which for me is the default, mixes Python and text files, while one nearly only wants to only search through Python files. I propose to remove 'and text' and '*.txt'.

2. The second line, which would currently be redundant with the first if it did what it said (but would not be with the first fix), has a bug in the file spec, '*' instead of '*.txt', that makes it redundant with the third line. I propose to fix that bug.

The following is copied from my patched and tested version of the file:

    filetypes = [
        ("Python files", "*.py *.pyw", "TEXT"),
        ("Text files", "*.txt", "TEXT"),
        ("All files", "*"),
        ]

So this is a trivial 2 line patch.
msg110032 - (view) Author: Marco Donato Torsello (md1512) Date: 2010-07-11 17:42
My fix for IDLE of Python3.1 .

This is the first time for me, so I didn't know what i have to do , sorry
msg110057 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-07-11 23:58
The upload still needed is a .diff patch file. This is most easily done with a VCS, in particular svn or possibly hg. I have asked someone with the proper setup to make one.
msg110120 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2010-07-12 18:17
Attaching a patch file for Lib/idlelib/IOBinding.py, diffed against the latest SVN trunk.
msg110494 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-07-16 20:58
gp, do you see any reason not to commit this?
If not, could you do so?
msg110507 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2010-07-16 21:44
I remember about another issue regarding extensions and save-as/open dialog boxes. Let me try to find it, just to be sure that the problem described here is different.
msg110514 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2010-07-16 22:10
I was thinking of issue4832. The patch provided here seems fine to me, although the behavior remains the same in Mac.
msg110909 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2010-07-20 15:20
On Windows, I can't think of any common reason to want to save a file edited in IDLE without the .py extension. On the other hand, accidentally forgetting the .py extension is annoying, and users have come to expect a default extension being added by applications (e.g. MS Office).

Guilherme's patch (applied manually) works fine here on Windows7. I'm all for committing this if it has been tested to work as expected on Linux and OSX.

(minor nit-pick: could use sys.platform.startswith('win') instead of slicing)
msg110942 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-07-20 18:21
Tal, I agree with your comment, but I believe it applies to #4832 and should be moved there. The patch here fixes (and only fixes) an obvious bug in the filetypes list.
msg110961 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2010-07-20 20:12
You're right Terry, my bad, I got the issues mixed up.
msg122194 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-11-23 06:49
3.2, 3.1, 2.7: r86702, r86703, r86704
History
Date User Action Args
2010-11-23 06:49:14terry.reedysetstatus: open -> closed
resolution: fixed
messages: + msg122194

stage: commit review -> resolved
2010-07-20 20:12:44taleinatsetmessages: + msg110961
2010-07-20 18:21:28terry.reedysetmessages: + msg110942
2010-07-20 15:20:29taleinatsetnosy: + taleinat
messages: + msg110909
2010-07-16 22:10:54gpolosetmessages: + msg110514
2010-07-16 21:44:48gpolosetmessages: + msg110507
2010-07-16 20:58:18terry.reedysetnosy: + gpolo
messages: + msg110494
2010-07-13 03:32:12terry.reedysetnosy: + kbk
2010-07-12 19:55:08terry.reedysetstage: commit review
2010-07-12 18:17:55eli.benderskysetfiles: + issue9122.1.patch

nosy: + eli.bendersky
messages: + msg110120

keywords: + patch
2010-07-11 23:58:15terry.reedysetmessages: + msg110057
2010-07-11 17:42:41md1512setfiles: + IOBinding.py
nosy: + md1512
messages: + msg110032

2010-07-11 00:44:09terry.reedycreate