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
display python version on idle title bar #61592
Comments
useful for those who routinely use different versions of python on idle. as it ships, idle displays "python shell" on its title bar. it would be useful to have there the version displayed as well. see http://bagratte.blogspot.it/2013/03/display-python-version-on-idle-title-bar_10.html |
Sounds like a good idea to me. Would you like to propose a patch? The devguide contains information to do that. Hint: sys.version is not meant to be parsed, there is sys.version_info for that (no regex needed! :) |
I agree. Sometimes when I have multiple IDLE windows open I have to scroll back to the top to make sure which one I am in. I suggest: |
... import platform
version = platform.python_version() + " " + platform.architecture()[0]
shell_title = "Python %s Shell" % version
...
(PyShell.py) i'll take a look at the devguide and see if i can figure a patch out. |
or better still: ... |
Suggesting a patch which addresses this enhancement. I did not include architecture() in the title bar but can add it as well if others think it is appropriate. Import of platform.python_version is done at the top of PyShell.py rather than inside the class as per PEP-8. |
good. thank you. i'm not sure about the architecture. i understand it's not crucial for most of the users. i would like to have it though. |
Updated patch to conform to PEP-3101 |
The 0 in "{0}" can be omitted, otherwise patch looks good to me. I agree that the architecture is not necessary. |
I have been planning to test and commit some version of this patch after PEP-434 is resolved, as I would like to backport it at least to 2.7 and 3.3. The only thing that could break is some esoteric application that looks at window title bars from outside and looks for an exact match rather than startswith('IDLE') or the equivalent. |
I think it's safe to apply this patch to 2.7/3.2/3.3/3.4. |
Edmond: please fill in, sign, and send by your preferred method a PSF Contributor Agreement For a patch more complicated than this, the CA would now be required before applying a patch of yours. |
Terry, I submitted my contributor form on March 15th, and received the confirmation, but it has not yet been applied to my account. I saw some discussion on one of the mailing lists of there being a potential backlog due to the PyCon sprints, so I just assumed that I was still waiting in the queue. If there is someone in particular I should contact at this point, I'm happy to do this. Thanks, |
New changeset 74d9a9507019 by Terry Jan Reedy in branch '3.3': New changeset e0f66c924544 by Terry Jan Reedy in branch 'default': New changeset 225022955c65 by Terry Jan Reedy in branch '2.7': |
Can you find the place where the editor title is set? I am currently thinking of something like Python x.y.z: xxx.py (directory path) # or I am guessing that the reason to put the file name at the beginning is in case the path is so long that the end gets cut off. (Let's give the secretary a couple more weeks to catch up.) |
Here is a patch to add a more descriptive title to the IDLE editor. Python <version> Editor: <filename> - <path> |
bpo-10747 is tangentially related. It is about adding the python version to the short cuts on Windows. |
issue17390_editor_title.patch is not correct, it changes the title on any window that inherits from EditorWindow, including the shell window. Here is a new patch that changes short_title() instead of saved_change_hook(), so it can be overridden by derived classes. This is the same method used to change the title of the shell window. Derived classes of EditorWindow are PyShellEditorWindow and OutputWindow. OutputWindow overrides short_title() and IIUC PyShellEditorWindow should use the same title as a normal editor window. |
Why this issue has been closed even though people were still discussing it and submitting patches? Terry, can you check if the new patches should be applied? |
I presume the OP only cared about the Shell Window, and that was fixed. |
New changeset bcfbab86f49a by Terry Jan Reedy in branch '2.7': New changeset b26db63bb931 by Terry Jan Reedy in branch '3.3': |
Edmond and Kent, thanks for the patch. Ezio, thanks for re-opening. After testing the patch with and without 'Editor', I preferred without. It is slightly redundant and noisy, especially when editing EditorWindow.py ;-). Also, Windows 7 stacks icons for windows belonging to a program under the program icon on the task bar. When the mouse is over the program icon, it pop up a window of *limited* width listing the window titles. The popup is narrow enough that paths to Idle test files in my repository clone get truncated when 'Editor' is added. I suspect that adding '''else: filename = "Untitled"''' to short_title() makes the corresponding '''else: title = "Untitled"''' in saved_change_hook() useless. I will check later for possible removal. Since I sometimes have multiple Find in File Output windows, I would like to expand their titles also. Since the Python version is irrelevant. I am thinking of class FiFWindow(OutputWindow):
def short_title(self):
return <fif title> |
How about adding an optional argument to OutputWindow that specifies the title for the window? Or would this be more suitable for EditorWindow (which OutputWindow inherits from)? Either way, doing this would allow any OutputWindow to specify its own title. The current title "Output", is pretty useless. I've written a patch that adds the functionality. In addition, I changed the title of the Find in Files output window to what you imagined. |
That looks like a sensible approach. |
As far as I can tell, there are 4 window classes to be concerned with. (Dialogs would be a separate issue.) EditorWindow PyShellEditorWindow does not override the title methods and is of no concern to us. If we want the title for all these windows to start with 'Python', we should 'factor' that out and start with it at the beginning of EditorWindow.saved_change_hook (and change other things in EW). Thinking ahead, another possible use for OutputWindow is for containing the result of running an external program on a file. I think that a leading 'Python' would be fine something like Adding the flexibility of a title parameter to OutputWindow instead of EditorWindow seems about right. If we do that, the override of .short_title for PyShell in the first patch should be removed and the title passed in to the one and only call that creates a PyShell (PyShell.py, 315). I would like to add some minimal automated tests (maybe in a new test_misc.py file) using either mock classes or unittest.mock (which I have not used yet). |
guys, |
Bagrat, are you on XP by any chance? In Win7, all windows for a program are attached to one program icon on the taskbar, which has the program name. When I hover over the program icon, mini views of each window are displayed, with each window view showing about 30 chars of the window title. For instance "Python 3.4.0: CallTipsWindow", which is fine for me. Moving the mouse over the mini window displays the complete title. |
terry, i'm on 7 but i have my taskbar configured not to combine buttons. see the screenshot attached. (does anyone know why on earth i am not receiving email notifications when someone posts to an issue i have started or i have commented to?) |
Other editors (e.g. Kate) use the format "filename - editor name". This is common for other applications as well (e.g. Firefox uses "page title - Mozilla Firefox"), so the request seems reasonable to me. If you want to go the extra mile you could have an option to decide if the filename should be first or not or even a format string that would allow users to fully configure the titlebar (e.g. "{file} - IDLE {version}"), but that might be out of the scope of this issue. FWIW I don't think Kate has an option for that, but it has one to show the full path in titlebar. (@bagrat: assuming your email address is correct, if you are not getting notifications they might have ended up in the spam folder.) |
The general issue of Idle title bars is definitely not finished, though I may close this issue and open others.
1a. Shell: Since the link in msg183874 is dead, I don't know what Bagrat suggested. I said 'Python' in msg183932, hinted 'Idle' in msg184620, and pushed the patch that had 'Python'. I could argue either way, but 'Python x.y.z Shell' (versus 'Idle x.y.z Shell') works as the name of the Idle product and also identifies what will run the code entered. I am now thinking 'neither' and propose making the title 'Shell x.y.z' -- see the more on this below. 1b. Editor: The patch I applied followed the same pattern, and again, I could argue for either 'Idle x.y.z' (what is doing the editing) or 'Python x.y.z' (what will run the code with F5)'. In this and the shell case, the version is the most important new information. If we consider the titles of other windows (see still more below), I think the class title should be 'Editor x.y.z'. 1c. OutputWindow: This is a bit tougher. 'Output' only works, sort of, as long as the class is only used for FIF, (Find in Files, grep). The initial title is actually '*Output*', indicating unsaved content, with no file name specified. Once saved, the title changes to "Output - <file name>". This is a precedent for 'Editor - <file name>' Since this issue started about adding versions, and version is not relevant to this and the following windows, a patch for OutputWindows should be a new issue. However, the design options need to be considered together. 1d. Read-only windows: We have "Debug Control", "Path Browser", and "Class Browser - Output Window". (For the last, "- Output Window" should go since it adds nothing and misleads in that the window is not an OutputWindow. It could be replaced with the class name.)
Most windows have a generic title for windows of a class. Part of my thinking above in suggesting 'Shell x.y.z' and 'Editor x.y.z' for the respective classes is that none of the class titles should contain either 'Python' or 'Idle' [separate? issue 0 -- it would be a correction of the patches on this issue]. Once an OutputWindow is saved, its title has a generic and specific component, in that order. The specific component identifies the specific contents of the instance. While I expect to replace 'Output' with names that reflect the subclasses of usage, the pattern will remain the same [separate issue 1]. Before we added a generic component for editor windows, they were unique in not having one. They currently follow the output pattern. I am also thinking a giving the title for ClassBrowswer (which is really ModuleBrowser) a specific component -- the module name [separate issue 2]. My point is that we have gone from one generic-specific (class-instance) name pair to two, and soon to more. If someone wants one pair flipped, then it seems logical to me that the same person would want all such pairs flipped, for the same reason. Bagrat, is this true for you? I know you only mentioned editor pairs, but you may not have known about output pairs, and certainly not future pairs that do not exist yet. I am willing to consider a user-settable option [separate issue 3], but I would think it should cover all such pairs, and not just editor window pairs. Currently, editor window titles are also unique in repeating part of the specific title. Output windows, when saved, do not repeat the short file name. Do any other editor programs do this? I expect we may decide to eliminate the redundancy as it exist now. Notepad++ puts "<complete path> - Notepad++" on the title bar and the filename on the notebook tab. When the tabbed selected changes, the title bar changes. Firefox does the title to match the tab also. There is already an issue to use tabbed notebooks with Idle and when we do that, I would expect to remove the duplication in the title and imitate Notepad++. |
terry, i indeed didn't know about output windows. (or at least i didn't know i knew. by the way, what are they?) the logic behind my request is that the file being edited in the editor is the most important thing of the editor. a quick glance at the taskbar, for those like me that have it set not to combine taskbar buttons, or for those on xp and the like, should reveal what is what. (terry, i received your email but still none from issue tracker, neither in spam. the last notification i received was that of msg186751, back in 2013. do you think i should file an issue on meta tracker?) |
I second that the title should start with the filename, by default. This seems to be the precedent, and it makes it easy when working with multiple files. Example: Terry, I think we can generalize this as '<important/useful title> - <general>: <specific>' and apply it to all windows. The first element essentially guarantees that the title name will be a good one for the taskbar. We can apply this to say the FIF output window: but maybe everything after the hyphen isn't necessary. I wonder if long titles could be annoying or distracting. Regardless, anything more specific than 'Output Window' will be better. |
I taught a python class this week with Python 2.7.7 and the learners found this change to be an impediment to usability. The filename and fullpath are the most important pieces of information in the title bar. They are now obscured by the version information which is somewhat unimportant (it has already been shown in the shell window and it is uncommon to run multiple versions of python using IDLE at the same time). Looking to Microsoft Excel and Word as comparative examples, they only show the document name. I conclude that this change should be reverted. For the time being, I can't continue to use IDLE in 2.7.7 to teach with. Not seeing the filename is especially important when many small windows are open (as they usually are during tdd and pdb sessions). |
Since no title format can satisfy everyone, I propose to make it user configurable. The default can be the old style. I opened bpo-21588 for that and marked it high priority. |
I don't know if this is related but the Window tab has been affect as well. It shows all open windows like this *Python 2.7.7 Shell* This is a bit over the top :-) I would really like the old behavior restored. |
I agree that the repeated 'Python x.y.z: " in the listing is too much. bpo-21588 has a patch but I am not ready to push it or do the review and revision needed . So I propose to reduce the current prefix to the minimum needed to know what version F5 will run the file with, x.y with minimal dressing, and put it in the middle or at the end. Your example Windows listing would then look like *Python 2.7.7 Shell* Which do you like best? I am trying out the second one in my 3.4 installation, and will switch to the third later. |
New changeset 6d41f139709b by Terry Jan Reedy in branch '2.7': New changeset ba141f9e58b6 by Terry Jan Reedy in branch '3.4': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: