summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/configHelpSourceEdit.py
diff options
context:
space:
mode:
authorTerry Jan Reedy <tjreedy@udel.edu>2016-05-15 05:30:47 (GMT)
committerTerry Jan Reedy <tjreedy@udel.edu>2016-05-15 05:30:47 (GMT)
commitc64d942e8d3cdca5450f5a622578d488c7982807 (patch)
tree163c44d664ab082db9b2a67ee022ca55974de8d3 /Lib/idlelib/configHelpSourceEdit.py
parent507898d35d92835f19565249e44c9afbea238192 (diff)
downloadcpython-c64d942e8d3cdca5450f5a622578d488c7982807.zip
cpython-c64d942e8d3cdca5450f5a622578d488c7982807.tar.gz
cpython-c64d942e8d3cdca5450f5a622578d488c7982807.tar.bz2
Issue #20640: Add tests for idlelib.configHelpSourceEdit.
Patch by Saimadhav Heblikar.
Diffstat (limited to 'Lib/idlelib/configHelpSourceEdit.py')
-rw-r--r--Lib/idlelib/configHelpSourceEdit.py46
1 files changed, 25 insertions, 21 deletions
diff --git a/Lib/idlelib/configHelpSourceEdit.py b/Lib/idlelib/configHelpSourceEdit.py
index 242b08d..b3028e9 100644
--- a/Lib/idlelib/configHelpSourceEdit.py
+++ b/Lib/idlelib/configHelpSourceEdit.py
@@ -23,10 +23,10 @@ class GetHelpSourceDialog(Toplevel):
self.title(title)
self.transient(parent)
self.grab_set()
- self.protocol("WM_DELETE_WINDOW", self.Cancel)
+ self.protocol("WM_DELETE_WINDOW", self.cancel)
self.parent = parent
self.result = None
- self.CreateWidgets()
+ self.create_widgets()
self.menu.set(menuItem)
self.path.set(filePath)
self.withdraw() #hide while setting geometry
@@ -41,10 +41,10 @@ class GetHelpSourceDialog(Toplevel):
((parent.winfo_height()/2 - self.winfo_reqheight()/2)
if not _htest else 150)))
self.deiconify() #geometry set, unhide
- self.bind('<Return>', self.Ok)
+ self.bind('<Return>', self.ok)
self.wait_window()
- def CreateWidgets(self):
+ def create_widgets(self):
self.menu = StringVar(self)
self.path = StringVar(self)
self.fontSize = StringVar(self)
@@ -65,18 +65,18 @@ class GetHelpSourceDialog(Toplevel):
labelPath.pack(anchor=W, padx=5, pady=3)
self.entryPath.pack(anchor=W, padx=5, pady=3)
browseButton = Button(self.frameMain, text='Browse', width=8,
- command=self.browseFile)
+ command=self.browse_file)
browseButton.pack(pady=3)
frameButtons = Frame(self)
frameButtons.pack(side=BOTTOM, fill=X)
self.buttonOk = Button(frameButtons, text='OK',
- width=8, default=ACTIVE, command=self.Ok)
+ width=8, default=ACTIVE, command=self.ok)
self.buttonOk.grid(row=0, column=0, padx=5,pady=5)
self.buttonCancel = Button(frameButtons, text='Cancel',
- width=8, command=self.Cancel)
+ width=8, command=self.cancel)
self.buttonCancel.grid(row=0, column=1, padx=5, pady=5)
- def browseFile(self):
+ def browse_file(self):
filetypes = [
("HTML Files", "*.htm *.html", "TEXT"),
("PDF Files", "*.pdf", "TEXT"),
@@ -99,9 +99,9 @@ class GetHelpSourceDialog(Toplevel):
if file:
self.path.set(file)
- def MenuOk(self):
+ def menu_ok(self):
"Simple validity check for a sensible menu item name"
- menuOk = True
+ menu_ok = True
menu = self.menu.get()
menu.strip()
if not menu:
@@ -109,19 +109,19 @@ class GetHelpSourceDialog(Toplevel):
message='No menu item specified',
parent=self)
self.entryMenu.focus_set()
- menuOk = False
+ menu_ok = False
elif len(menu) > 30:
tkMessageBox.showerror(title='Menu Item Error',
message='Menu item too long:'
'\nLimit 30 characters.',
parent=self)
self.entryMenu.focus_set()
- menuOk = False
- return menuOk
+ menu_ok = False
+ return menu_ok
- def PathOk(self):
+ def path_ok(self):
"Simple validity check for menu file path"
- pathOk = True
+ path_ok = True
path = self.path.get()
path.strip()
if not path: #no path specified
@@ -129,7 +129,7 @@ class GetHelpSourceDialog(Toplevel):
message='No help file path specified.',
parent=self)
self.entryPath.focus_set()
- pathOk = False
+ path_ok = False
elif path.startswith(('www.', 'http')):
pass
else:
@@ -140,11 +140,11 @@ class GetHelpSourceDialog(Toplevel):
message='Help file path does not exist.',
parent=self)
self.entryPath.focus_set()
- pathOk = False
- return pathOk
+ path_ok = False
+ return path_ok
- def Ok(self, event=None):
- if self.MenuOk() and self.PathOk():
+ def ok(self, event=None):
+ if self.menu_ok() and self.path_ok():
self.result = (self.menu.get().strip(),
self.path.get().strip())
if sys.platform == 'darwin':
@@ -157,10 +157,14 @@ class GetHelpSourceDialog(Toplevel):
self.result[1] = "file://" + path
self.destroy()
- def Cancel(self, event=None):
+ def cancel(self, event=None):
self.result = None
self.destroy()
if __name__ == '__main__':
+ import unittest
+ unittest.main('idlelib.idle_test.test_config_help',
+ verbosity=2, exit=False)
+
from idlelib.idle_test.htest import run
run(GetHelpSourceDialog)