如果文件从未保存过,如何在IDLE中重新引入“无提示保存”选项(How to reintroduce “no prompt to save” option in IDLE if file has ne

编程入门 行业动态 更新时间:2024-10-10 15:19:20
如果文件从未保存过,如何在IDLE中重新引入“无提示保存”选项(How to reintroduce “no prompt to save” option in IDLE if file has never been saved)

目前我在我的笔记本电脑(2.7.12)上使用最新版本的Python 2,以及IDLE版本2.7.12和TK版本8.5.15,如果这些是相关的。

在我的学校计算机上使用稍微旧版本的IDLE(版本2.7a0),它在IDLE首选项的“常规”选项卡中(在选项下,配置IDLE ...),我不再看到的特定首选项我在笔记本电脑上安装的最新版IDLE。

特别是,对于“运行(F5)首选项”小节,它在标题“如果文件从未保存过”之后提供了两个选项; 一个“提示保存”,另一个“没有提示”。

我在更现代的IDLE环境下找不到这个选项。 我希望你们中的一个人可能知道是否有某种方法可以改变现代版本的IDLE或Python来重新引入这个功能? (例如,我可以为Python打开某种源文档并自己进行修改吗?)。

我有时会觉得它很令人沮丧,因为我经常想用一些非常简单的代码创建一个新文件,以测试我对Python的理解是否与特定概念(即虚数在数组中的工作原理)有关,而不运行我的整个程序这通常要复杂得多,并且需要花费更长的时间来进行测试(并且在代码越长的情况下评论所有内容都非常繁琐)。 必须打开一个新文件,输入我的代码,将其保存在我的桌面上,这是一种耗时。

不管你信不信,有时候我会有多个窗口测试不同的概念,因为我想继续以多种方式测试Python,而不会删除我之前在其他测试中所做的工作。

如果它是相关的,学校的计算机使用Python版本2.7.12和TK版本8.5(我仍然需要弄清楚TK的含义)。

我知道我可能只是将IDLE的版本回滚到这个早期版本(我假设这无论如何都会工作) - 但我也担心我可能会失去现代版本的一些关键功能,或者我会重新介绍一些先前已经处理过的错误。

〜感谢您的帮助〜

Unununium

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

最满意答案

我对这份报告感到困惑。 “自动保存首选项”部分仍然存在。 idlelib.configDialog.py,类ConfigDialog,方法CreatePageGeneral在第384和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')

除了在2014年添加空格以符合PEP 8之外,此代码自2003年以来没有变化。它先于启动首选项和初始窗口大小成功。 我使用hg annotate来查看文件在2.6和2.7之前的情况。

存储库记录可能不完整或者在alpha0版本中尝试了某些内容并将其删除,因为它无法正常工作(并且提交和还原都已删除)。 如果您找到不同的代码,您可以将剪切和启动标题的部分粘贴到您的问题中,该标题看起来像“Python 2.7.12(v2.7.12:d33e0cf91556,2016年6月27日,15:24:40)”。

AFAIK,IDLE始终要求使用名称将新文件保存到磁盘,否则将无法创建正确的回溯。 跟踪器上的问题19042是一个提议,通过让IDLE选择名称和路径来运行“无标题”窗口而不给出名称。 或者可以保存在用户配置的目录中。

2.7的alpha-0版本将是最可能的。 它应该被替换。

OT:Tk是Tcl的GUI工具包。 Tkinter是Python与tk的接口。

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.

更多推荐

本文发布于:2023-04-29 03:24:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1334424.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:选项   提示   文件   如何在   IDLE

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!