Search code examples
pythonsavepreferencespromptpython-idle

How to reintroduce "no prompt to save" option in IDLE if file has never been saved


Currently I am using the latest version of Python 2 on my laptop (2.7.12), along with IDLE version 2.7.12 and TK version 8.5.15, in case those are relevant.

On my school computers a slightly older version of IDLE is being used (version 2.7a0) which has, in the "general" tab of the IDLE preferences (under Options, Configure IDLE...), particular preferences that I no longer see in the latest version of IDLE that I installed on my laptop.

In particular, for the subsection "Run (F5) Preferences", it provides two options after the heading "If file has never been saved"; one "Prompt to Save" and the other "No Prompt".

I can't find this option under my more modern IDLE environment. I was hoping that one of you people might know whether there was some way to alter the modern version of IDLE or Python to reintroduce this feature? (For example, could I just open up some kind of source document for Python and make the modification myself?).

I just find it frustrating sometimes, because I often want to just create a new file with some very simple code to test whether my understanding of Python is correct with respect to particular concepts (i.e. how imaginary numbers work in arrays) without running my entire program which is often significantly more complex and will take a lot longer to test (and commenting everything out is extremely tedious the longer your code is). Having to open up a new file, enter my code, save it on my desktop, is kind of time consuming.

And believe it or not sometimes I will have multiple windows testing different concepts, because I want to continue testing Python in multiple ways without erasing the work I had previously done in other tests, which are ongoing.

Also in case it is relevant, the school computers are using Python version 2.7.12 and TK version 8.5 (I still need to figure out what TK means).

I understand that I could probably just roll back the version of IDLE to this earlier form (I'm assuming this would work anyway) - but I am also concerned that I may lose some key features that modern versions have, or that I will reintroduce some bugs that have previously been dealt with.

~Thanks for any help~

Unununium


Solution

  • I am puzzled by this report. The Autosave Preferences section is still present. idlelib.configDialog.py, class ConfigDialog, method CreatePageGeneral has (should have) this code at lines 384 and 396.

        frameSave = LabelFrame(frame, borderwidth=2, relief=GROOVE,
                               text=' Autosave Preferences ')
        ...
        #frameSave
        labelRunSaveTitle = Label(frameSave, text='At Start of Run (F5)  ')
        radioSaveAsk = Radiobutton(
                frameSave, variable=self.autoSave, value=0,
                command=self.SetKeysType, text="Prompt to Save")
        radioSaveAuto = Radiobutton(
                frameSave, variable=self.autoSave, value=1,
                command=self.SetKeysType, text='No Prompt')
    

    Except for adding spaces in 2014 to conform to PEP 8, this code is unchanged since 2003. It is preceeded by Startup Preferences and Succeeded by Initial Window size. I used hg annotate to look at how the file was in 2.6 and early 2.7.

    It is possible that the repository record incomplete or that something was tried in an alpha0 release and removed because it did not work right (and both commit and revert erased). If you find different code, you could paste the snipped and the part of the startup header that looks line "Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40)" into your question.

    AFAIK, IDLE has always required new files to be saved to disk with a name as otherwise it would not be possible to create proper tracebacks. Issue 19042on the tracker is a proposal to run 'Untitled' windows without given a name by having IDLE pick a name and path. Or perhaps save in a user-configured directory.

    The alpha-0 release of 2.7 would be the buggiest possible. It should have been replaced.

    OT: Tk is the GUI toolkit for Tcl. Tkinter is Python's inter-face to tk.