Skip to content

Commit bd570f4

Browse files
authored
[3.6] bpo-24813: IDLE: Add default title to help_about (GH-2366) (#2369)
Patch by Cheryl Sabella. (cherry picked from commit 18ede06)
1 parent 9db3ae0 commit bd570f4

File tree

4 files changed

+33
-9
lines changed

4 files changed

+33
-9
lines changed

Lib/idlelib/editor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ def rmenu_check_paste(self):
463463
def about_dialog(self, event=None):
464464
"Handle Help 'About IDLE' event."
465465
# Synchronize with macosx.overrideRootMenu.about_dialog.
466-
help_about.AboutDialog(self.top,'About IDLE')
466+
help_about.AboutDialog(self.top)
467467

468468
def config_dialog(self, event=None):
469469
"Handle Options 'Configure IDLE' event."

Lib/idlelib/help_about.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
"""
44
import os
5-
from sys import version
5+
from platform import python_version
66

77
from tkinter import Toplevel, Frame, Label, Button, PhotoImage
88
from tkinter import SUNKEN, TOP, BOTTOM, LEFT, X, BOTH, W, EW, NSEW, E
@@ -14,7 +14,7 @@ class AboutDialog(Toplevel):
1414
"""Modal about dialog for idle
1515
1616
"""
17-
def __init__(self, parent, title, _htest=False, _utest=False):
17+
def __init__(self, parent, title=None, _htest=False, _utest=False):
1818
"""Create popup, do not return until tk widget destroyed.
1919
2020
parent - parent of this dialog
@@ -32,7 +32,7 @@ def __init__(self, parent, title, _htest=False, _utest=False):
3232
self.fg = "#ffffff"
3333
self.create_widgets()
3434
self.resizable(height=False, width=False)
35-
self.title(title)
35+
self.title(title or f'About IDLE {python_version()}')
3636
self.transient(parent)
3737
self.grab_set()
3838
self.protocol("WM_DELETE_WINDOW", self.ok)
@@ -48,7 +48,6 @@ def __init__(self, parent, title, _htest=False, _utest=False):
4848
self.wait_window()
4949

5050
def create_widgets(self):
51-
release = version[:version.index(' ')]
5251
frame = Frame(self, borderwidth=2, relief=SUNKEN)
5352
frame_buttons = Frame(self)
5453
frame_buttons.pack(side=BOTTOM, fill=X)
@@ -80,15 +79,16 @@ def create_widgets(self):
8079
justify=LEFT, fg=self.fg, bg=self.bg)
8180
email.grid(row=6, column=0, columnspan=2, sticky=W, padx=10, pady=0)
8281
docs = Label(frame_background, text='https://docs.python.org/' +
83-
version[:3] + '/library/idle.html',
82+
python_version()[:3] + '/library/idle.html',
8483
justify=LEFT, fg=self.fg, bg=self.bg)
8584
docs.grid(row=7, column=0, columnspan=2, sticky=W, padx=10, pady=0)
8685

8786
Frame(frame_background, borderwidth=1, relief=SUNKEN,
8887
height=2, bg=self.bg).grid(row=8, column=0, sticky=EW,
8988
columnspan=3, padx=5, pady=5)
9089

91-
pyver = Label(frame_background, text='Python version: ' + release,
90+
pyver = Label(frame_background,
91+
text='Python version: ' + python_version(),
9292
fg=self.fg, bg=self.bg)
9393
pyver.grid(row=9, column=0, sticky=W, padx=10, pady=0)
9494
tkver = Label(frame_background, text='Tk version: ' + tk_patchlevel,
@@ -113,7 +113,8 @@ def create_widgets(self):
113113
height=2, bg=self.bg).grid(row=11, column=0, sticky=EW,
114114
columnspan=3, padx=5, pady=5)
115115

116-
idlever = Label(frame_background, text='IDLE version: ' + release,
116+
idlever = Label(frame_background,
117+
text='IDLE version: ' + python_version(),
117118
fg=self.fg, bg=self.bg)
118119
idlever.grid(row=12, column=0, sticky=W, padx=10, pady=0)
119120
idle_buttons = Frame(frame_background, bg=self.bg)

Lib/idlelib/idle_test/test_help_about.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from idlelib.help_about import AboutDialog as About
1111
from idlelib import textview
1212
import os.path
13+
from platform import python_version
1314

1415
class LiveDialogTest(unittest.TestCase):
1516
"""Simulate user clicking buttons other than [Close].
@@ -79,6 +80,28 @@ def test_file_buttons(self):
7980
dialog._current_textview.destroy()
8081

8182

83+
class DefaultTitleTest(unittest.TestCase):
84+
"Test default title."
85+
86+
@classmethod
87+
def setUpClass(cls):
88+
requires('gui')
89+
cls.root = Tk()
90+
cls.root.withdraw()
91+
cls.dialog = About(cls.root, _utest=True)
92+
93+
@classmethod
94+
def tearDownClass(cls):
95+
del cls.dialog
96+
cls.root.update_idletasks()
97+
cls.root.destroy()
98+
del cls.root
99+
100+
def test_dialog_title(self):
101+
"""Test about dialog title"""
102+
self.assertEqual(self.dialog.title(), f'About IDLE {python_version()}')
103+
104+
82105
class CloseTest(unittest.TestCase):
83106
"""Simulate user clicking [Close] button"""
84107

Lib/idlelib/macosx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def about_dialog(event=None):
165165
"Handle Help 'About IDLE' event."
166166
# Synchronize with editor.EditorWindow.about_dialog.
167167
from idlelib import help_about
168-
help_about.AboutDialog(root, 'About IDLE')
168+
help_about.AboutDialog(root)
169169

170170
def config_dialog(event=None):
171171
"Handle Options 'Configure IDLE' event."

0 commit comments

Comments
 (0)