diff options
Diffstat (limited to 'Lib/idlelib')
-rw-r--r-- | Lib/idlelib/NEWS.txt | 55 | ||||
-rw-r--r-- | Lib/idlelib/README.txt | 268 | ||||
-rw-r--r-- | Lib/idlelib/__init__.py | 1 | ||||
-rw-r--r-- | Lib/idlelib/__main__.py | 4 | ||||
-rw-r--r-- | Lib/idlelib/autocomplete.py (renamed from Lib/idlelib/AutoComplete.py) | 10 | ||||
-rw-r--r-- | Lib/idlelib/autocomplete_w.py (renamed from Lib/idlelib/AutoCompleteWindow.py) | 11 | ||||
-rw-r--r-- | Lib/idlelib/autoexpand.py (renamed from Lib/idlelib/AutoExpand.py) | 0 | ||||
-rw-r--r-- | Lib/idlelib/browser.py (renamed from Lib/idlelib/ClassBrowser.py) | 16 | ||||
-rw-r--r-- | Lib/idlelib/calltip_w.py (renamed from Lib/idlelib/CallTipWindow.py) | 4 | ||||
-rw-r--r-- | Lib/idlelib/calltips.py (renamed from Lib/idlelib/CallTips.py) | 8 | ||||
-rw-r--r-- | Lib/idlelib/codecontext.py (renamed from Lib/idlelib/CodeContext.py) | 6 | ||||
-rw-r--r-- | Lib/idlelib/colorizer.py (renamed from Lib/idlelib/ColorDelegator.py) | 17 | ||||
-rw-r--r-- | Lib/idlelib/config.py (renamed from Lib/idlelib/configHandler.py) | 30 | ||||
-rw-r--r-- | Lib/idlelib/config_help.py (renamed from Lib/idlelib/configHelpSourceEdit.py) | 0 | ||||
-rw-r--r-- | Lib/idlelib/config_key.py (renamed from Lib/idlelib/keybindingDialog.py) | 21 | ||||
-rw-r--r-- | Lib/idlelib/config_sec.py (renamed from Lib/idlelib/configSectionNameDialog.py) | 2 | ||||
-rw-r--r-- | Lib/idlelib/configdialog.py (renamed from Lib/idlelib/configDialog.py) | 17 | ||||
-rw-r--r-- | Lib/idlelib/debugger.py (renamed from Lib/idlelib/Debugger.py) | 17 | ||||
-rw-r--r-- | Lib/idlelib/debugger_r.py (renamed from Lib/idlelib/RemoteDebugger.py) | 8 | ||||
-rw-r--r-- | Lib/idlelib/debugobj.py (renamed from Lib/idlelib/ObjectBrowser.py) | 4 | ||||
-rw-r--r-- | Lib/idlelib/debugobj_r.py (renamed from Lib/idlelib/RemoteObjectBrowser.py) | 0 | ||||
-rw-r--r-- | Lib/idlelib/delegator.py (renamed from Lib/idlelib/Delegator.py) | 0 | ||||
-rw-r--r-- | Lib/idlelib/dynoption.py (renamed from Lib/idlelib/dynOptionMenuWidget.py) | 0 | ||||
-rw-r--r-- | Lib/idlelib/editor.py (renamed from Lib/idlelib/EditorWindow.py) | 187 | ||||
-rw-r--r-- | Lib/idlelib/filelist.py (renamed from Lib/idlelib/FileList.py) | 4 | ||||
-rw-r--r-- | Lib/idlelib/grep.py (renamed from Lib/idlelib/GrepDialog.py) | 10 | ||||
-rw-r--r-- | Lib/idlelib/help.py | 28 | ||||
-rw-r--r-- | Lib/idlelib/help.txt | 372 | ||||
-rw-r--r-- | Lib/idlelib/help_about.py (renamed from Lib/idlelib/aboutDialog.py) | 6 | ||||
-rw-r--r-- | Lib/idlelib/history.py (renamed from Lib/idlelib/IdleHistory.py) | 4 | ||||
-rw-r--r-- | Lib/idlelib/hyperparser.py (renamed from Lib/idlelib/HyperParser.py) | 4 | ||||
-rw-r--r-- | Lib/idlelib/idle.py | 4 | ||||
-rw-r--r-- | Lib/idlelib/idle.pyw | 12 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/__init__.py | 2 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/htest.py | 69 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/mock_idle.py | 4 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_autocomplete.py | 12 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_autoexpand.py | 4 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_calltips.py | 2 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_colorizer.py | 56 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_config_help.py | 4 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_config_key.py | 31 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_config_sec.py (renamed from Lib/idlelib/idle_test/test_config_name.py) | 4 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_configdialog.py | 6 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_debugger.py | 29 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_delegator.py | 2 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_editmenu.py | 28 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_editor.py | 2 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_grep.py | 6 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_help.py | 34 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_history.py (renamed from Lib/idlelib/idle_test/test_idlehistory.py) | 4 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_hyperparser.py | 6 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_iomenu.py (renamed from Lib/idlelib/idle_test/test_io.py) | 2 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_macosx.py | 101 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_paragraph.py (renamed from Lib/idlelib/idle_test/test_formatparagraph.py) | 8 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_parenmatch.py | 4 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_pathbrowser.py | 8 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_percolator.py | 4 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_redirector.py (renamed from Lib/idlelib/idle_test/test_widgetredir.py) | 5 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_replace.py (renamed from Lib/idlelib/idle_test/test_replacedialog.py) | 6 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_rstrip.py | 4 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_scrolledlist.py | 29 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_search.py (renamed from Lib/idlelib/idle_test/test_searchdialog.py) | 6 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_searchbase.py (renamed from Lib/idlelib/idle_test/test_searchdialogbase.py) | 6 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_searchengine.py | 4 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_textview.py | 4 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_tree.py | 36 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_undo.py (renamed from Lib/idlelib/idle_test/test_undodelegator.py) | 6 | ||||
-rw-r--r-- | Lib/idlelib/idle_test/test_warning.py | 6 | ||||
-rw-r--r-- | Lib/idlelib/idlever.py | 12 | ||||
-rw-r--r-- | Lib/idlelib/iomenu.py (renamed from Lib/idlelib/IOBinding.py) | 5 | ||||
-rw-r--r-- | Lib/idlelib/macosx.py (renamed from Lib/idlelib/macosxSupport.py) | 96 | ||||
-rw-r--r-- | Lib/idlelib/mainmenu.py (renamed from Lib/idlelib/Bindings.py) | 4 | ||||
-rw-r--r-- | Lib/idlelib/multicall.py (renamed from Lib/idlelib/MultiCall.py) | 0 | ||||
-rw-r--r-- | Lib/idlelib/outwin.py (renamed from Lib/idlelib/OutputWindow.py) | 6 | ||||
-rw-r--r-- | Lib/idlelib/paragraph.py (renamed from Lib/idlelib/FormatParagraph.py) | 4 | ||||
-rw-r--r-- | Lib/idlelib/parenmatch.py (renamed from Lib/idlelib/ParenMatch.py) | 4 | ||||
-rw-r--r-- | Lib/idlelib/pathbrowser.py (renamed from Lib/idlelib/PathBrowser.py) | 6 | ||||
-rw-r--r-- | Lib/idlelib/percolator.py (renamed from Lib/idlelib/Percolator.py) | 4 | ||||
-rw-r--r-- | Lib/idlelib/pyparse.py (renamed from Lib/idlelib/PyParse.py) | 0 | ||||
-rwxr-xr-x | Lib/idlelib/pyshell.py (renamed from Lib/idlelib/PyShell.py) | 99 | ||||
-rw-r--r-- | Lib/idlelib/redirector.py (renamed from Lib/idlelib/WidgetRedirector.py) | 2 | ||||
-rw-r--r-- | Lib/idlelib/replace.py (renamed from Lib/idlelib/ReplaceDialog.py) | 8 | ||||
-rw-r--r-- | Lib/idlelib/rstrip.py (renamed from Lib/idlelib/RstripExtension.py) | 0 | ||||
-rw-r--r-- | Lib/idlelib/run.py | 42 | ||||
-rw-r--r-- | Lib/idlelib/runscript.py (renamed from Lib/idlelib/ScriptBinding.py) | 16 | ||||
-rw-r--r-- | Lib/idlelib/scrolledlist.py (renamed from Lib/idlelib/ScrolledList.py) | 17 | ||||
-rw-r--r-- | Lib/idlelib/search.py (renamed from Lib/idlelib/SearchDialog.py) | 6 | ||||
-rw-r--r-- | Lib/idlelib/searchbase.py (renamed from Lib/idlelib/SearchDialogBase.py) | 2 | ||||
-rw-r--r-- | Lib/idlelib/searchengine.py (renamed from Lib/idlelib/SearchEngine.py) | 2 | ||||
-rw-r--r-- | Lib/idlelib/stackviewer.py (renamed from Lib/idlelib/StackViewer.py) | 9 | ||||
-rw-r--r-- | Lib/idlelib/statusbar.py (renamed from Lib/idlelib/MultiStatusBar.py) | 0 | ||||
-rw-r--r-- | Lib/idlelib/textview.py (renamed from Lib/idlelib/textView.py) | 3 | ||||
-rw-r--r-- | Lib/idlelib/tooltip.py (renamed from Lib/idlelib/ToolTip.py) | 4 | ||||
-rw-r--r-- | Lib/idlelib/tree.py (renamed from Lib/idlelib/TreeWidget.py) | 21 | ||||
-rw-r--r-- | Lib/idlelib/undo.py (renamed from Lib/idlelib/UndoDelegator.py) | 4 | ||||
-rw-r--r-- | Lib/idlelib/windows.py (renamed from Lib/idlelib/WindowList.py) | 0 | ||||
-rw-r--r-- | Lib/idlelib/zoomheight.py (renamed from Lib/idlelib/ZoomHeight.py) | 4 |
98 files changed, 1002 insertions, 1052 deletions
diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt index 6c41e2892c..68a555c993 100644 --- a/Lib/idlelib/NEWS.txt +++ b/Lib/idlelib/NEWS.txt @@ -1,15 +1,26 @@ -What's New in IDLE 3.5.2? -========================= -*Release date: 2016-06-30?* +What's New in IDLE 3.6.0? +=========================== +*Release date: 2016-09-??* - Issue #5124: Paste with text selected now replaces the selection on X11. This matches how paste works on Windows, Mac, most modern Linux apps, and ttk widgets. Original patch by Serhiy Storchaka. +- Issue #24750: Switch all scrollbars in IDLE to ttk versions. + Where needed, minimal tests are added to cover changes. + +- Issue #24759: IDLE requires tk 8.5 and availability ttk widgets. + Delete now unneeded tk version tests and code for older versions. + Add test for IDLE syntax colorizer. + +- Issue #27239: idlelib.macosx.isXyzTk functions initialize as needed. + +- Issue #27262: move Aqua unbinding code, which enable context menus, to maxosx. + - Issue #24759: Make clear in idlelib.idle_test.__init__ that the directory is a private implementation of test.test_idle and tool for maintainers. -- Issue #27196: Stop 'ThemeChangef' warnings when running IDLE tests. +- Issue #27196: Stop 'ThemeChanged' warnings when running IDLE tests. These persisted after other warnings were suppressed in #20567. Apply Serhiy Storchaka's update_idletasks solution to four test files. Record this additional advice in idle_test/README.txt @@ -17,9 +28,26 @@ What's New in IDLE 3.5.2? - Issue #20567: Revise idle_test/README.txt with advice about avoiding tk warning messages from tests. Apply advice to several IDLE tests. +- Issue # 24225: Update idlelib/README.txt with new file names + and event handlers. + +- Issue #27156: Remove obsolete code not used by IDLE. Replacements: + 1. help.txt, replaced by help.html, is out-of-date and should not be used. + Its dedicated viewer has be replaced by the html viewer in help.py. + 2. 'import idlever; I = idlever.IDLE_VERSION' is the same as + 'import sys; I = version[:version.index(' ')]' + 3. After 'ob = stackviewer.VariablesTreeItem(*args)', + 'ob.keys()' == 'list(ob.object.keys). + 4. In macosc, runningAsOSXAPP == isAquaTk; idCarbonAquaTk == isCarbonTk + - Issue #27117: Make colorizer htest and turtledemo work with dark themes. Move code for configuring text widget colors to a new function. +- Issue #24225: Rename many idlelib/*.py and idle_test/test_*.py files. + Edit files to replace old names with new names when the old name + referred to the module rather than the class it contained. + See the issue and IDLE section in What's New in 3.6 for more. + - Issue #26673: When tk reports font size as 0, change to size 10. Such fonts on Linux prevented the configuration dialog from opening. @@ -32,8 +60,8 @@ What's New in IDLE 3.5.2? - Issue #18410: Add test for IDLE's search dialog. Original patch by Westley Martínez. -- Issue #21703: Add test for undo delegator. - Original patch by Saimadhav Heblikar . +- Issue #21703: Add test for undo delegator. Patch mostly by + Saimadhav Heblikar . - Issue #27044: Add ConfigDialog.remove_var_callbacks to stop memory leaks. @@ -52,11 +80,6 @@ What's New in IDLE 3.5.2? MARK in README.txt and open this and NEWS.txt with 'ascii'. Re-encode CREDITS.txt to utf-8 and open it with 'utf-8'. - -What's New in IDLE 3.5.1? -========================= -*Release date: 2015-12-06* - - Issue 15348: Stop the debugger engine (normally in a user process) before closing the debugger window (running in the IDLE process). This prevents the RuntimeErrors that were being caught and ignored. @@ -334,6 +357,11 @@ What's New in IDLE 3.1b1? - Use of 'filter' in keybindingDialog.py was causing custom key assignment to fail. Patch 5707 amaury.forgeotdarc. + +What's New in IDLE 3.1a1? +========================= +*Release date: 07-Mar-09* + - Issue #4815: Offer conversion to UTF-8 if source files have no encoding declaration and are not encoded in UTF-8. @@ -373,6 +401,11 @@ What's New in IDLE 2.7? (UNRELEASED, but merged into 3.1 releases above.) - Issue #3549: On MacOS the preferences menu was not present + +What's New in IDLE 3.0? +======================= +*Release date: 03-Dec-2008* + - IDLE would print a "Unhandled server exception!" message when internal debugging is enabled. diff --git a/Lib/idlelib/README.txt b/Lib/idlelib/README.txt index 7bf74c0fc4..e1d682e276 100644 --- a/Lib/idlelib/README.txt +++ b/Lib/idlelib/README.txt @@ -29,61 +29,61 @@ idle.pyw Implementation -------------- -AutoComplete.py # Complete attribute names or filenames. -AutoCompleteWindow.py # Display completions. -AutoExpand.py # Expand word with previous word in file. -Bindings.py # Define most of IDLE menu. -CallTipWindow.py # Display calltip. -CallTips.py # Create calltip text. -ClassBrowser.py # Create module browser window. -CodeContext.py # Show compound statement headers otherwise not visible. -ColorDelegator.py # Colorize text (nim). -Debugger.py # Debug code run from editor; show window. -Delegator.py # Define base class for delegators (nim). -EditorWindow.py # Define most of editor and utility functions. -FileList.py # Open files and manage list of open windows (nim). -FormatParagraph.py# Re-wrap multiline strings and comments. -GrepDialog.py # Find all occurrences of pattern in multiple files. -HyperParser.py # Parse code around a given index. -IOBinding.py # Open, read, and write files -IdleHistory.py # Get previous or next user input in shell (nim) -MultiCall.py # Wrap tk widget to allow multiple calls per event (nim). -MultiStatusBar.py # Define status bar for windows (nim). -ObjectBrowser.py # Define class used in StackViewer (nim). -OutputWindow.py # Create window for grep output. -ParenMatch.py # Match fenceposts: (), [], and {}. -PathBrowser.py # Create path browser window. -Percolator.py # Manage delegator stack (nim). -PyParse.py # Give information on code indentation -PyShell.py # Start IDLE, manage shell, complete editor window -RemoteDebugger.py # Debug code run in remote process. -RemoteObjectBrowser.py # Communicate objects between processes with rpc (nim). -ReplaceDialog.py # Search and replace pattern in text. -RstripExtension.py# Strip trailing whitespace -ScriptBinding.py # Check and run user code. -ScrolledList.py # Define ScrolledList widget for IDLE (nim). -SearchDialog.py # Search for pattern in text. -SearchDialogBase.py # Define base for search, replace, and grep dialogs. -SearchEngine.py # Define engine for all 3 search dialogs. -StackViewer.py # View stack after exception. -TreeWidget.py # Define tree widger, used in browsers (nim). -UndoDelegator.py # Manage undo stack. -WidgetRedirector.py # Intercept widget subcommands (for percolator) (nim). -WindowList.py # Manage window list and define listed top level. -ZoomHeight.py # Zoom window to full height of screen. -aboutDialog.py # Display About IDLE dialog. -configDialog.py # Display user configuration dialogs. -configHandler.py # Load, fetch, and save configuration (nim). -configHelpSourceEdit.py # Specify help source. -configSectionNameDialog.py # Spefify user config section name -dynOptionMenuWidget.py # define mutable OptionMenu widget (nim). +autocomplete.py # Complete attribute names or filenames. +autocomplete_w.py # Display completions. +autoexpand.py # Expand word with previous word in file. +browser.py # Create module browser window. +calltip_w.py # Display calltip. +calltips.py # Create calltip text. +codecontext.py # Show compound statement headers otherwise not visible. +colorizer.py # Colorize text (nim) +config.py # Load, fetch, and save configuration (nim). +configdialog.py # Display user configuration dialogs. +config_help.py # Specify help source in configdialog. +config_key.py # Change keybindings. +config_sec.py # Spefify user config section name +dynoption.py # Define mutable OptionMenu widget (nim). +debugobj.py # Define class used in stackviewer. +debugobj_r.py # Communicate objects between processes with rpc (nim). +debugger.py # Debug code run from shell or editor; show window. +debugger_r.py # Debug code run in remote process. +delegator.py # Define base class for delegators (nim). +editor.py # Define most of editor and utility functions. +filelist.py # Open files and manage list of open windows (nim). +grep.py # Find all occurrences of pattern in multiple files. help.py # Display IDLE's html doc. -keybindingDialog.py # Change keybindings. -macosxSupport.py # Help IDLE run on Macs (nim). +help_about.py # Display About IDLE dialog. +history.py # Get previous or next user input in shell (nim) +hyperparser.py # Parse code around a given index. +iomenu.py # Open, read, and write files +macosx.py # Help IDLE run on Macs (nim). +mainmenu.py # Define most of IDLE menu. +multicall.py # Wrap tk widget to allow multiple calls per event (nim). +outwin.py # Create window for grep output. +paragraph.py # Re-wrap multiline strings and comments. +parenmatch.py # Match fenceposts: (), [], and {}. +pathbrowser.py # Create path browser window. +percolator.py # Manage delegator stack (nim). +pyparse.py # Give information on code indentation +pyshell.py # Start IDLE, manage shell, complete editor window +redirector.py # Intercept widget subcommands (for percolator) (nim). +replace.py # Search and replace pattern in text. rpc.py # Commuicate between idle and user processes (nim). +rstrip.py # Strip trailing whitespace. run.py # Manage user code execution subprocess. +runscript.py # Check and run user code. +scrolledlist.py # Define scrolledlist widget for IDLE (nim). +search.py # Search for pattern in text. +searchbase.py # Define base for search, replace, and grep dialogs. +searchengine.py # Define engine for all 3 search dialogs. +stackviewer.py # View stack after exception. +statusbar.py # Define status bar for windows (nim). tabbedpages.py # Define tabbed pages widget (nim). -textView.py # Define read-only text widget (nim). +textview.py # Define read-only text widget (nim). +tree.py # Define tree widger, used in browsers (nim). +undo.py # Manage undo stack. +windows.py # Manage window list and define listed top level. +zoomheight.py # Zoom window to full height of screen. Configuration ------------- @@ -104,126 +104,128 @@ help.html # copy of idle.html in docs, displayed by IDLE Help Subdirectories -------------- -Icons # small image files -idle_test # files for human test and automated unit tests +Icons # small image files +idle_test # files for human test and automated unit tests Unused and Deprecated files and objects (nim) --------------------------------------------- -EditorWindow.py: Helpdialog and helpDialog -ToolTip.py: unused. -help.txt -idlever.py +tooltip.py # unused + IDLE MENUS -Top level items and most submenu items are defined in Bindings. +Top level items and most submenu items are defined in mainmenu. Extenstions add submenu items when active. The names given are found, quoted, in one of these modules, paired with a '<<pseudoevent>>'. Each pseudoevent is bound to an event handler. Some event handlers call another function that does the actual work. The annotations below are intended to at least give the module where the actual work is done. +'eEW' = editor.EditorWindow -File # IOBindig except as noted - New File - Open... # IOBinding.open - Open Module +File + New File # eEW.new_callback + Open... # iomenu.open + Open Module # eEw.open_module Recent Files - Class Browser # Class Browser - Path Browser # Path Browser + Class Browser # eEW.open_class_browser, browser.ClassBrowser + Path Browser # eEW.open_path_browser, pathbrowser --- - Save # IDBinding.save - Save As... # IOBinding.save_as - Save Copy As... # IOBindling.save_a_copy + Save # iomenu.save + Save As... # iomenu.save_as + Save Copy As... # iomenu.save_a_copy --- - Print Window # IOBinding.print_window + Print Window # iomenu.print_window --- - Close - Exit + Close # eEW.close_event + Exit # flist.close_all_callback (bound in eEW) Edit - Undo # undoDelegator - Redo # undoDelegator - --- - Cut - Copy - Paste - Select All - --- # Next 5 items use SearchEngine; dialogs use SearchDialogBase - Find # Search Dialog - Find Again - Find Selection - Find in Files... # GrepDialog - Replace... # ReplaceDialog - Go to Line - Show Completions # AutoComplete extension and AutoCompleteWidow (&HP) - Expand Word # AutoExpand extension - Show call tip # Calltips extension and CalltipWindow (& Hyperparser) - Show surrounding parens # ParenMatch (& Hyperparser) - -Shell # PyShell - View Last Restart # PyShell.? - Restart Shell # PyShell.? + Undo # undodelegator + Redo # undodelegator + --- # eEW.right_menu_event + Cut # eEW.cut + Copy # eEW.copy + Paste # eEW.past + Select All # eEW.select_all (+ see eEW.remove_selection) + --- # Next 5 items use searchengine; dialogs use searchbase + Find # eEW.find_event, search.SearchDialog.find + Find Again # eEW.find_again_event, sSD.find_again + Find Selection # eEW.find_selection_event, sSD.find_selection + Find in Files... # eEW.find_in_files_event, grep + Replace... # eEW.replace_event, replace.ReplaceDialog.replace + Go to Line # eEW.goto_line_event + Show Completions # autocomplete extension and autocompleteWidow (&HP) + Expand Word # autoexpand extension + Show call tip # Calltips extension and CalltipWindow (& Hyperparser) + Show surrounding parens # parenmatch (& Hyperparser) + +Shell # pyshell + View Last Restart# pyshell.? + Restart Shell # pyshell.? Debug (Shell only) Go to File/Line - Debugger # Debugger, RemoteDebugger - Stack Viewer # StackViewer - Auto-open Stack Viewer # StackViewer + debugger # debugger, debugger_r + Stack Viewer # stackviewer + Auto-open Stack Viewer # stackviewer Format (Editor only) - Indent Region - Dedent Region - Comment Out Region - Uncomment Region - Tabify Region - Untabify Region - Toggle Tabs - New Indent Width - Format Paragraph # FormatParagraph extension + Indent Region # eEW.indent_region_event + Dedent Region # eEW.dedent_region_event + Comment Out Reg. # eEW.comment_region_event + Uncomment Region # eEW.uncomment_region_event + Tabify Region # eEW.tabify_region_event + Untabify Region # eEW.untabify_region_event + Toggle Tabs # eEW.toggle_tabs_event + New Indent Width # eEW.change_indentwidth_event + Format Paragraph # paragraph extension --- - Strip tailing whitespace # RstripExtension extension + Strip tailing whitespace # rstrip extension Run (Editor only) - Python Shell # PyShell + Python Shell # pyshell --- - Check Module # ScriptBinding - Run Module # ScriptBinding + Check Module # runscript + Run Module # runscript Options - Configure IDLE # configDialog + Configure IDLE # eEW.config_dialog, configdialog (tabs in the dialog) - Font tab # onfig-main.def - Highlight tab # configSectionNameDialog, config-highlight.def - Keys tab # keybindingDialog, configSectionNameDialog, onfig-keus.def - General tab # configHelpSourceEdit, config-main.def - Configure Extensions # configDialog - Xyz tab # xyz.py, config-extensions.def + Font tab # config-main.def + Highlight tab # config_sec, config-highlight.def + Keys tab # config_key, configconfig_secg-keus.def + General tab # config_help, config-main.def + Extensions tab # config-extensions.def, corresponding .py --- - Code Context (editor only) # CodeContext extension + Code Context (ed)# codecontext extension Window - Zoomheight # ZoomHeight extension + Zoomheight # zoomheight extension --- - <open windows> # WindowList + <open windows> # windows Help - About IDLE # aboutDialog + About IDLE # eEW.about_dialog, help_about.AboutDialog --- - IDLE Help # help - Python Doc - Turtle Demo + IDLE Help # eEW.help_dialog, helpshow_idlehelp + Python Doc # eEW.python_docs + Turtle Demo # eEW.open_turtle_demo --- <other help sources> <Context Menu> (right click) -Defined in EditorWindow, PyShell, Output - Cut - Copy - Paste - --- - Go to file/line (shell and output only) - Set Breakpoint (editor only) - Clear Breakpoint (editor only) - Defined in Debugger - Go to source line - Show stack frame + Defined in editor, PyShelpyshellut + Cut + Copy + Paste + --- + Go to file/line (shell and output only) + Set Breakpoint (editor only) + Clear Breakpoint (editor only) + Defined in debugger + Go to source line + Show stack frame + +<No menu> +Center Insert # eEW.center_insert_event + diff --git a/Lib/idlelib/__init__.py b/Lib/idlelib/__init__.py index 711f61bb69..fef21bee14 100644 --- a/Lib/idlelib/__init__.py +++ b/Lib/idlelib/__init__.py @@ -1,6 +1,7 @@ """The idlelib package implements the Idle application. Idle includes an interactive shell and editor. +Starting with Python 3.6, IDLE requires tcl/tk 8.5 or later. Use the files named idle.* to start Idle. The other files are private implementations. Their details are subject to diff --git a/Lib/idlelib/__main__.py b/Lib/idlelib/__main__.py index 2edf5f7dc1..6349ec75c6 100644 --- a/Lib/idlelib/__main__.py +++ b/Lib/idlelib/__main__.py @@ -3,6 +3,6 @@ IDLE main entry point Run IDLE as python -m idlelib """ -import idlelib.PyShell -idlelib.PyShell.main() +import idlelib.pyshell +idlelib.pyshell.main() # This file does not work for 2.7; See issue 24212. diff --git a/Lib/idlelib/AutoComplete.py b/Lib/idlelib/autocomplete.py index ff085d5c70..5ba8dc5dd5 100644 --- a/Lib/idlelib/AutoComplete.py +++ b/Lib/idlelib/autocomplete.py @@ -1,4 +1,4 @@ -"""AutoComplete.py - An IDLE extension for automatically completing names. +"""autocomplete.py - An IDLE extension for automatically completing names. This extension can complete either attribute names or file names. It can pop a window with all available names, for the user to select from. @@ -7,7 +7,7 @@ import os import sys import string -from idlelib.configHandler import idleConf +from idlelib.config import idleConf # This string includes all chars that may be in an identifier ID_CHARS = string.ascii_letters + string.digits + "_" @@ -15,8 +15,8 @@ ID_CHARS = string.ascii_letters + string.digits + "_" # These constants represent the two different types of completions COMPLETE_ATTRIBUTES, COMPLETE_FILES = range(1, 2+1) -from idlelib import AutoCompleteWindow -from idlelib.HyperParser import HyperParser +from idlelib import autocomplete_w +from idlelib.hyperparser import HyperParser import __main__ @@ -49,7 +49,7 @@ class AutoComplete: self._delayed_completion_index = None def _make_autocomplete_window(self): - return AutoCompleteWindow.AutoCompleteWindow(self.text) + return autocomplete_w.AutoCompleteWindow(self.text) def _remove_autocomplete_window(self, event=None): if self.autocompletewindow: diff --git a/Lib/idlelib/AutoCompleteWindow.py b/Lib/idlelib/autocomplete_w.py index 2ee6878396..38f8601156 100644 --- a/Lib/idlelib/AutoCompleteWindow.py +++ b/Lib/idlelib/autocomplete_w.py @@ -1,9 +1,10 @@ """ -An auto-completion window for IDLE, used by the AutoComplete extension +An auto-completion window for IDLE, used by the autocomplete extension """ from tkinter import * -from idlelib.MultiCall import MC_SHIFT -from idlelib.AutoComplete import COMPLETE_FILES, COMPLETE_ATTRIBUTES +from tkinter.ttk import Scrollbar +from idlelib.multicall import MC_SHIFT +from idlelib.autocomplete import COMPLETE_FILES, COMPLETE_ATTRIBUTES HIDE_VIRTUAL_EVENT_NAME = "<<autocompletewindow-hide>>" HIDE_SEQUENCES = ("<FocusOut>", "<ButtonPress>") @@ -34,8 +35,8 @@ class AutoCompleteWindow: self.completions = None # A list with more completions, or None self.morecompletions = None - # The completion mode. Either AutoComplete.COMPLETE_ATTRIBUTES or - # AutoComplete.COMPLETE_FILES + # The completion mode. Either autocomplete.COMPLETE_ATTRIBUTES or + # autocomplete.COMPLETE_FILES self.mode = None # The current completion start, on the text box (a string) self.start = None diff --git a/Lib/idlelib/AutoExpand.py b/Lib/idlelib/autoexpand.py index 7059054281..7059054281 100644 --- a/Lib/idlelib/AutoExpand.py +++ b/Lib/idlelib/autoexpand.py diff --git a/Lib/idlelib/ClassBrowser.py b/Lib/idlelib/browser.py index d09c52fe4d..9968333c24 100644 --- a/Lib/idlelib/ClassBrowser.py +++ b/Lib/idlelib/browser.py @@ -14,13 +14,13 @@ import os import sys import pyclbr -from idlelib import PyShell -from idlelib.WindowList import ListedToplevel -from idlelib.TreeWidget import TreeNode, TreeItem, ScrolledCanvas -from idlelib.configHandler import idleConf +from idlelib import pyshell +from idlelib.windows import ListedToplevel +from idlelib.tree import TreeNode, TreeItem, ScrolledCanvas +from idlelib.config import idleConf file_open = None # Method...Item and Class...Item use this. -# Normally PyShell.flist.open, but there is no PyShell.flist for htest. +# Normally pyshell.flist.open, but there is no pyshell.flist for htest. class ClassBrowser: @@ -32,7 +32,7 @@ class ClassBrowser: """ global file_open if not _htest: - file_open = PyShell.flist.open + file_open = pyshell.flist.open self.name = name self.file = os.path.join(path[0], self.name + ".py") self._htest = _htest @@ -95,7 +95,7 @@ class ModuleBrowserTreeItem(TreeItem): return if not os.path.exists(self.file): return - PyShell.flist.open(self.file) + pyshell.flist.open(self.file) def IsExpandable(self): return os.path.normcase(self.file[-3:]) == ".py" @@ -226,7 +226,7 @@ def _class_browser(parent): #Wrapper for htest file = sys.argv[0] dir, file = os.path.split(file) name = os.path.splitext(file)[0] - flist = PyShell.PyShellFileList(parent) + flist = pyshell.PyShellFileList(parent) global file_open file_open = flist.open ClassBrowser(flist, name, [dir], _htest=True) diff --git a/Lib/idlelib/CallTipWindow.py b/Lib/idlelib/calltip_w.py index 8e68a76b2a..9f6cdc1771 100644 --- a/Lib/idlelib/CallTipWindow.py +++ b/Lib/idlelib/calltip_w.py @@ -1,7 +1,7 @@ """A CallTip window class for Tkinter/IDLE. -After ToolTip.py, which uses ideas gleaned from PySol -Used by the CallTips IDLE extension. +After tooltip.py, which uses ideas gleaned from PySol +Used by the calltips IDLE extension. """ from tkinter import Toplevel, Label, LEFT, SOLID, TclError diff --git a/Lib/idlelib/CallTips.py b/Lib/idlelib/calltips.py index 81bd5f1890..3a9b1c6776 100644 --- a/Lib/idlelib/CallTips.py +++ b/Lib/idlelib/calltips.py @@ -1,4 +1,4 @@ -"""CallTips.py - An IDLE Extension to Jog Your Memory +"""calltips.py - An IDLE Extension to Jog Your Memory Call Tips are floating windows which display function, class, and method parameter and docstring information when you type an opening parenthesis, and @@ -12,8 +12,8 @@ import sys import textwrap import types -from idlelib import CallTipWindow -from idlelib.HyperParser import HyperParser +from idlelib import calltip_w +from idlelib.hyperparser import HyperParser class CallTips: @@ -37,7 +37,7 @@ class CallTips: def _make_tk_calltip_window(self): # See __init__ for usage - return CallTipWindow.CallTip(self.text) + return calltip_w.CallTip(self.text) def _remove_calltip_window(self, event=None): if self.active_calltip: diff --git a/Lib/idlelib/CodeContext.py b/Lib/idlelib/codecontext.py index 7d25adaa4c..2a21a1f84a 100644 --- a/Lib/idlelib/CodeContext.py +++ b/Lib/idlelib/codecontext.py @@ -1,11 +1,11 @@ -"""CodeContext - Extension to display the block context above the edit window +"""codecontext - Extension to display the block context above the edit window Once code has scrolled off the top of a window, it can be difficult to determine which block you are in. This extension implements a pane at the top of each IDLE edit window which provides block structure hints. These hints are the lines which contain the block opening keywords, e.g. 'if', for the enclosing block. The number of hint lines is determined by the numlines -variable in the CodeContext section of config-extensions.def. Lines which do +variable in the codecontext section of config-extensions.def. Lines which do not open blocks are not shown in the context hints pane. """ @@ -13,7 +13,7 @@ import tkinter from tkinter.constants import TOP, LEFT, X, W, SUNKEN import re from sys import maxsize as INFINITY -from idlelib.configHandler import idleConf +from idlelib.config import idleConf BLOCKOPENERS = {"class", "def", "elif", "else", "except", "finally", "for", "if", "try", "while", "with"} diff --git a/Lib/idlelib/ColorDelegator.py b/Lib/idlelib/colorizer.py index 02eac47068..5b6dc67594 100644 --- a/Lib/idlelib/ColorDelegator.py +++ b/Lib/idlelib/colorizer.py @@ -2,9 +2,8 @@ import time import re import keyword import builtins -from tkinter import TkVersion -from idlelib.Delegator import Delegator -from idlelib.configHandler import idleConf +from idlelib.delegator import Delegator +from idlelib.config import idleConf DEBUG = False @@ -49,11 +48,8 @@ def color_config(text): # Called from htest, Editor, and Turtle Demo. insertbackground=cursor_color, selectforeground=select_colors['foreground'], selectbackground=select_colors['background'], - ) - if TkVersion >= 8.5: - text.config( - inactiveselectbackground=select_colors['background']) - + inactiveselectbackground=select_colors['background'], # new in 8.5 + ) class ColorDelegator(Delegator): @@ -259,7 +255,7 @@ class ColorDelegator(Delegator): def _color_delegator(parent): # htest # from tkinter import Toplevel, Text - from idlelib.Percolator import Percolator + from idlelib.percolator import Percolator top = Toplevel(parent) top.title("Test ColorDelegator") @@ -277,5 +273,8 @@ def _color_delegator(parent): # htest # p.insertfilter(d) if __name__ == "__main__": + import unittest + unittest.main('idlelib.idle_test.test_colorizer', + verbosity=2, exit=False) from idlelib.idle_test.htest import run run(_color_delegator) diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/config.py index 8ac1f6097a..4d87de0605 100644 --- a/Lib/idlelib/configHandler.py +++ b/Lib/idlelib/config.py @@ -7,7 +7,7 @@ duplicate the defaults will be removed from the user's configuration files, and if a file becomes empty, it will be deleted. The contents of the user files may be altered using the Options/Configure IDLE -menu to access the configuration GUI (configDialog.py), or manually. +menu to access the configuration GUI (configdialog.py), or manually. Throughout this module there is an emphasis on returning useable defaults when a problem occurs in returning a requested configuration value back to @@ -22,7 +22,6 @@ import os import sys from configparser import ConfigParser -from tkinter import TkVersion from tkinter.font import Font, nametofont class InvalidConfigType(Exception): pass @@ -230,7 +229,7 @@ class IdleConf: return self.userCfg[configType].Get(section, option, type=type, raw=raw) except ValueError: - warning = ('\n Warning: configHandler.py - IdleConf.GetOption -\n' + warning = ('\n Warning: config.py - IdleConf.GetOption -\n' ' invalid %r value for configuration option %r\n' ' from section %r: %r' % (type, option, section, @@ -247,7 +246,7 @@ class IdleConf: pass #returning default, print warning if warn_on_default: - warning = ('\n Warning: configHandler.py - IdleConf.GetOption -\n' + warning = ('\n Warning: config.py - IdleConf.GetOption -\n' ' problem retrieving configuration option %r\n' ' from section %r.\n' ' returning default value: %r' % @@ -358,7 +357,7 @@ class IdleConf: for element in theme: if not cfgParser.has_option(themeName, element): # Print warning that will return a default color - warning = ('\n Warning: configHandler.IdleConf.GetThemeDict' + warning = ('\n Warning: config.IdleConf.GetThemeDict' ' -\n problem retrieving theme element %r' '\n from theme %r.\n' ' returning default color: %r' % @@ -644,7 +643,7 @@ class IdleConf: if binding: keyBindings[event] = binding else: #we are going to return a default, print warning - warning=('\n Warning: configHandler.py - IdleConf.GetCoreKeys' + warning=('\n Warning: config.py - IdleConf.GetCoreKeys' ' -\n problem retrieving key binding for event %r' '\n from key set %r.\n' ' returning default value: %r' % @@ -713,16 +712,13 @@ class IdleConf: bold = self.GetOption(configType, section, 'font-bold', default=0, type='bool') if (family == 'TkFixedFont'): - if TkVersion < 8.5: - family = 'Courier' - else: - f = Font(name='TkFixedFont', exists=True, root=root) - actualFont = Font.actual(f) - family = actualFont['family'] - size = actualFont['size'] - if size <= 0: - size = 10 # if font in pixels, ignore actual size - bold = actualFont['weight']=='bold' + f = Font(name='TkFixedFont', exists=True, root=root) + actualFont = Font.actual(f) + family = actualFont['family'] + size = actualFont['size'] + if size <= 0: + size = 10 # if font in pixels, ignore actual size + bold = actualFont['weight'] == 'bold' return (family, size, 'bold' if bold else 'normal') def LoadCfgFiles(self): @@ -740,7 +736,7 @@ class IdleConf: idleConf = IdleConf() # TODO Revise test output, write expanded unittest -### module test +# if __name__ == '__main__': def dumpCfg(cfg): print('\n', cfg, '\n') diff --git a/Lib/idlelib/configHelpSourceEdit.py b/Lib/idlelib/config_help.py index cde8118fe6..cde8118fe6 100644 --- a/Lib/idlelib/configHelpSourceEdit.py +++ b/Lib/idlelib/config_help.py diff --git a/Lib/idlelib/keybindingDialog.py b/Lib/idlelib/config_key.py index e6438bfc39..26022934c3 100644 --- a/Lib/idlelib/keybindingDialog.py +++ b/Lib/idlelib/config_key.py @@ -2,31 +2,35 @@ Dialog for building Tkinter accelerator key bindings """ from tkinter import * +from tkinter.ttk import Scrollbar import tkinter.messagebox as tkMessageBox import string import sys class GetKeysDialog(Toplevel): - def __init__(self,parent,title,action,currentKeySequences,_htest=False): + def __init__(self, parent, title, action, currentKeySequences, + _htest=False, _utest=False): """ action - string, the name of the virtual event these keys will be mapped to currentKeys - list, a list of all key sequence lists currently mapped to virtual events, for overlap checking + _utest - bool, do not wait when running unittest _htest - bool, change box location when running htest """ Toplevel.__init__(self, parent) + self.withdraw() #hide while setting geometry self.configure(borderwidth=5) - self.resizable(height=FALSE,width=FALSE) + self.resizable(height=FALSE, width=FALSE) self.title(title) self.transient(parent) self.grab_set() self.protocol("WM_DELETE_WINDOW", self.Cancel) self.parent = parent self.action=action - self.currentKeySequences=currentKeySequences - self.result='' - self.keyString=StringVar(self) + self.currentKeySequences = currentKeySequences + self.result = '' + self.keyString = StringVar(self) self.keyString.set('') self.SetModifiersForPlatform() # set self.modifiers, self.modifier_label self.modifier_vars = [] @@ -37,7 +41,6 @@ class GetKeysDialog(Toplevel): self.advanced = False self.CreateWidgets() self.LoadFinalKeyList() - self.withdraw() #hide while setting geometry self.update_idletasks() self.geometry( "+%d+%d" % ( @@ -47,8 +50,9 @@ class GetKeysDialog(Toplevel): ((parent.winfo_height()/2 - self.winfo_reqheight()/2) if not _htest else 150) ) ) #centre dialog over parent (or below htest box) - self.deiconify() #geometry set, unhide - self.wait_window() + if not _utest: + self.deiconify() #geometry set, unhide + self.wait_window() def CreateWidgets(self): frameMain = Frame(self,borderwidth=2,relief=SUNKEN) @@ -261,6 +265,7 @@ class GetKeysDialog(Toplevel): keysOK = True return keysOK + if __name__ == '__main__': from idlelib.idle_test.htest import run run(GetKeysDialog) diff --git a/Lib/idlelib/configSectionNameDialog.py b/Lib/idlelib/config_sec.py index 5137836981..7b59124507 100644 --- a/Lib/idlelib/configSectionNameDialog.py +++ b/Lib/idlelib/config_sec.py @@ -1,7 +1,7 @@ """ Dialog that allows user to specify a new config file section name. Used to get new highlight theme and keybinding set names. -The 'return value' for the dialog, used two placed in configDialog.py, +The 'return value' for the dialog, used two placed in configdialog.py, is the .result attribute set in the Ok and Cancel methods. """ from tkinter import * diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configdialog.py index 5f5bd36f8a..d19749a07e 100644 --- a/Lib/idlelib/configDialog.py +++ b/Lib/idlelib/configdialog.py @@ -10,18 +10,19 @@ Refer to comments in EditorWindow autoindent code for details. """ from tkinter import * +from tkinter.ttk import Scrollbar import tkinter.messagebox as tkMessageBox import tkinter.colorchooser as tkColorChooser import tkinter.font as tkFont -from idlelib.configHandler import idleConf -from idlelib.dynOptionMenuWidget import DynOptionMenu -from idlelib.keybindingDialog import GetKeysDialog -from idlelib.configSectionNameDialog import GetCfgSectionNameDialog -from idlelib.configHelpSourceEdit import GetHelpSourceDialog +from idlelib.config import idleConf +from idlelib.dynoption import DynOptionMenu +from idlelib.config_key import GetKeysDialog +from idlelib.config_sec import GetCfgSectionNameDialog +from idlelib.config_help import GetHelpSourceDialog from idlelib.tabbedpages import TabbedPageSet -from idlelib.textView import view_text -from idlelib import macosxSupport +from idlelib.textview import view_text +from idlelib import macosx class ConfigDialog(Toplevel): @@ -91,7 +92,7 @@ class ConfigDialog(Toplevel): self.create_action_buttons().pack(side=BOTTOM) def create_action_buttons(self): - if macosxSupport.isAquaTk(): + if macosx.isAquaTk(): # Changing the default padding on OSX results in unreadable # text in the buttons paddingArgs = {} diff --git a/Lib/idlelib/Debugger.py b/Lib/idlelib/debugger.py index d5e217dde9..ea393b12c0 100644 --- a/Lib/idlelib/Debugger.py +++ b/Lib/idlelib/debugger.py @@ -1,9 +1,10 @@ import os import bdb from tkinter import * -from idlelib.WindowList import ListedToplevel -from idlelib.ScrolledList import ScrolledList -from idlelib import macosxSupport +from tkinter.ttk import Scrollbar +from idlelib.windows import ListedToplevel +from idlelib.scrolledlist import ScrolledList +from idlelib import macosx class Idb(bdb.Bdb): @@ -34,8 +35,10 @@ class Idb(bdb.Bdb): return True else: prev_frame = frame.f_back - if prev_frame.f_code.co_filename.count('Debugger.py'): - # (that test will catch both Debugger.py and RemoteDebugger.py) + prev_name = prev_frame.f_code.co_filename + if 'idlelib' in prev_name and 'debugger' in prev_name: + # catch both idlelib/debugger.py and idlelib/debugger_r.py + # on both posix and windows return False return self.in_rpc_code(prev_frame) @@ -370,7 +373,7 @@ class Debugger: class StackViewer(ScrolledList): def __init__(self, master, flist, gui): - if macosxSupport.isAquaTk(): + if macosx.isAquaTk(): # At least on with the stock AquaTk version on OSX 10.4 you'll # get a shaking GUI that eventually kills IDLE if the width # argument is specified. @@ -502,7 +505,7 @@ class NamespaceViewer: # # There is also an obscure bug in sorted(dict) where the # interpreter gets into a loop requesting non-existing dict[0], - # dict[1], dict[2], etc from the RemoteDebugger.DictProxy. + # dict[1], dict[2], etc from the debugger_r.DictProxy. ### keys_list = dict.keys() names = sorted(keys_list) diff --git a/Lib/idlelib/RemoteDebugger.py b/Lib/idlelib/debugger_r.py index be2262f080..bc971276de 100644 --- a/Lib/idlelib/RemoteDebugger.py +++ b/Lib/idlelib/debugger_r.py @@ -21,7 +21,7 @@ barrier, in particular frame and traceback objects. """ import types -from idlelib import Debugger +from idlelib import debugger debugging = 0 @@ -187,7 +187,7 @@ def start_debugger(rpchandler, gui_adap_oid): """ gui_proxy = GUIProxy(rpchandler, gui_adap_oid) - idb = Debugger.Idb(gui_proxy) + idb = debugger.Idb(gui_proxy) idb_adap = IdbAdapter(idb) rpchandler.register(idb_adap_oid, idb_adap) return idb_adap_oid @@ -362,7 +362,7 @@ def start_remote_debugger(rpcclt, pyshell): idb_adap_oid = rpcclt.remotecall("exec", "start_the_debugger",\ (gui_adap_oid,), {}) idb_proxy = IdbProxy(rpcclt, pyshell, idb_adap_oid) - gui = Debugger.Debugger(pyshell, idb_proxy) + gui = debugger.Debugger(pyshell, idb_proxy) gui_adap = GUIAdapter(rpcclt, gui) rpcclt.register(gui_adap_oid, gui_adap) return gui @@ -373,7 +373,7 @@ def close_remote_debugger(rpcclt): Request that the RPCServer shut down the subprocess debugger and link. Unregister the GUIAdapter, which will cause a GC on the Idle process debugger and RPC link objects. (The second reference to the debugger GUI - is deleted in PyShell.close_remote_debugger().) + is deleted in pyshell.close_remote_debugger().) """ close_subprocess_debugger(rpcclt) diff --git a/Lib/idlelib/ObjectBrowser.py b/Lib/idlelib/debugobj.py index 7b57aa4c68..4016c032d4 100644 --- a/Lib/idlelib/ObjectBrowser.py +++ b/Lib/idlelib/debugobj.py @@ -11,7 +11,7 @@ import re -from idlelib.TreeWidget import TreeItem, TreeNode, ScrolledCanvas +from idlelib.tree import TreeItem, TreeNode, ScrolledCanvas from reprlib import Repr @@ -126,7 +126,7 @@ def _object_browser(parent): import sys from tkinter import Tk root = Tk() - root.title("Test ObjectBrowser") + root.title("Test debug object browser") width, height, x, y = list(map(int, re.split('[x+]', parent.geometry()))) root.geometry("+%d+%d"%(x, y + 150)) root.configure(bd=0, bg="yellow") diff --git a/Lib/idlelib/RemoteObjectBrowser.py b/Lib/idlelib/debugobj_r.py index 8031aaeaf1..8031aaeaf1 100644 --- a/Lib/idlelib/RemoteObjectBrowser.py +++ b/Lib/idlelib/debugobj_r.py diff --git a/Lib/idlelib/Delegator.py b/Lib/idlelib/delegator.py index dc2a1aaeea..dc2a1aaeea 100644 --- a/Lib/idlelib/Delegator.py +++ b/Lib/idlelib/delegator.py diff --git a/Lib/idlelib/dynOptionMenuWidget.py b/Lib/idlelib/dynoption.py index 515b4bafc2..515b4bafc2 100644 --- a/Lib/idlelib/dynOptionMenuWidget.py +++ b/Lib/idlelib/dynoption.py diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/editor.py index 9944da3e70..7f910e76f9 100644 --- a/Lib/idlelib/EditorWindow.py +++ b/Lib/idlelib/editor.py @@ -7,20 +7,21 @@ import re import string import sys from tkinter import * +from tkinter.ttk import Scrollbar import tkinter.simpledialog as tkSimpleDialog import tkinter.messagebox as tkMessageBox import traceback import webbrowser -from idlelib.MultiCall import MultiCallCreator -from idlelib import WindowList -from idlelib import SearchDialog -from idlelib import GrepDialog -from idlelib import ReplaceDialog -from idlelib import PyParse -from idlelib.configHandler import idleConf -from idlelib import aboutDialog, textView, configDialog -from idlelib import macosxSupport +from idlelib.multicall import MultiCallCreator +from idlelib import windows +from idlelib import search +from idlelib import grep +from idlelib import replace +from idlelib import pyparse +from idlelib.config import idleConf +from idlelib import help_about, textview, configdialog +from idlelib import macosx from idlelib import help # The default tab setting for a Text widget, in average-width characters. @@ -40,62 +41,14 @@ def _sphinx_version(): return release -class HelpDialog(object): - - def __init__(self): - self.parent = None # parent of help window - self.dlg = None # the help window iteself - - def display(self, parent, near=None): - """ Display the help dialog. - - parent - parent widget for the help window - - near - a Toplevel widget (e.g. EditorWindow or PyShell) - to use as a reference for placing the help window - """ - import warnings as w - w.warn("EditorWindow.HelpDialog is no longer used by Idle.\n" - "It will be removed in 3.6 or later.\n" - "It has been replaced by private help.HelpWindow\n", - DeprecationWarning, stacklevel=2) - if self.dlg is None: - self.show_dialog(parent) - if near: - self.nearwindow(near) - - def show_dialog(self, parent): - self.parent = parent - fn=os.path.join(os.path.abspath(os.path.dirname(__file__)),'help.txt') - self.dlg = dlg = textView.view_file(parent,'Help',fn, modal=False) - dlg.bind('<Destroy>', self.destroy, '+') - - def nearwindow(self, near): - # Place the help dialog near the window specified by parent. - # Note - this may not reposition the window in Metacity - # if "/apps/metacity/general/disable_workarounds" is enabled - dlg = self.dlg - geom = (near.winfo_rootx() + 10, near.winfo_rooty() + 10) - dlg.withdraw() - dlg.geometry("=+%d+%d" % geom) - dlg.deiconify() - dlg.lift() - - def destroy(self, ev=None): - self.dlg = None - self.parent = None - -helpDialog = HelpDialog() # singleton instance, no longer used - - class EditorWindow(object): - from idlelib.Percolator import Percolator - from idlelib.ColorDelegator import ColorDelegator, color_config - from idlelib.UndoDelegator import UndoDelegator - from idlelib.IOBinding import IOBinding, filesystemencoding, encoding - from idlelib import Bindings + from idlelib.percolator import Percolator + from idlelib.colorizer import ColorDelegator, color_config + from idlelib.undo import UndoDelegator + from idlelib.iomenu import IOBinding, filesystemencoding, encoding + from idlelib import mainmenu from tkinter import Toplevel - from idlelib.MultiStatusBar import MultiStatusBar + from idlelib.statusbar import MultiStatusBar help_url = None @@ -136,11 +89,11 @@ class EditorWindow(object): except AttributeError: sys.ps1 = '>>> ' self.menubar = Menu(root) - self.top = top = WindowList.ListedToplevel(root, menu=self.menubar) + self.top = top = windows.ListedToplevel(root, menu=self.menubar) if flist: self.tkinter_vars = flist.vars #self.top.instance_dict makes flist.inversedict available to - #configDialog.py so it can access all EditorWindow instances + #configdialog.py so it can access all EditorWindow instances self.top.instance_dict = flist.inversedict else: self.tkinter_vars = {} # keys: Tkinter event names @@ -158,13 +111,10 @@ class EditorWindow(object): 'wrap': 'none', 'highlightthickness': 0, 'width': self.width, - 'height': idleConf.GetOption('main', 'EditorWindow', - 'height', type='int')} - if TkVersion >= 8.5: - # Starting with tk 8.5 we have to set the new tabstyle option - # to 'wordprocessor' to achieve the same display of tabs as in - # older tk versions. - text_options['tabstyle'] = 'wordprocessor' + 'tabstyle': 'wordprocessor', # new in 8.5 + 'height': idleConf.GetOption( + 'main', 'EditorWindow', 'height', type='int'), + } self.text = text = MultiCallCreator(Text)(text_frame, **text_options) self.top.focused_widget = self.text @@ -173,7 +123,7 @@ class EditorWindow(object): self.top.protocol("WM_DELETE_WINDOW", self.close) self.top.bind("<<close-window>>", self.close_event) - if macosxSupport.isAquaTk(): + if macosx.isAquaTk(): # Command-W on editorwindows doesn't work without this. text.bind('<<close-window>>', self.close_event) # Some OS X systems have only one mouse button, so use @@ -309,7 +259,7 @@ class EditorWindow(object): menu.add_separator() end = end + 1 self.wmenu_end = end - WindowList.register_callback(self.postwindowsmenu) + windows.register_callback(self.postwindowsmenu) # Some abstractions so IDLE extensions are cross-IDE self.askyesno = tkMessageBox.askyesno @@ -418,7 +368,7 @@ class EditorWindow(object): underline, label = prepstr(label) menudict[name] = menu = Menu(mbar, name=name, tearoff=0) mbar.add_cascade(label=label, menu=menu, underline=underline) - if macosxSupport.isCarbonTk(): + if macosx.isCarbonTk(): # Insert the application menu menudict['application'] = menu = Menu(mbar, name='apple', tearoff=0) @@ -439,7 +389,7 @@ class EditorWindow(object): end = -1 if end > self.wmenu_end: menu.delete(self.wmenu_end+1, end) - WindowList.add_windows_to_menu(menu) + windows.add_windows_to_menu(menu) rmenu = None @@ -507,17 +457,17 @@ class EditorWindow(object): def about_dialog(self, event=None): "Handle Help 'About IDLE' event." - # Synchronize with macosxSupport.overrideRootMenu.about_dialog. - aboutDialog.AboutDialog(self.top,'About IDLE') + # Synchronize with macosx.overrideRootMenu.about_dialog. + help_about.AboutDialog(self.top,'About IDLE') def config_dialog(self, event=None): "Handle Options 'Configure IDLE' event." - # Synchronize with macosxSupport.overrideRootMenu.config_dialog. - configDialog.ConfigDialog(self.top,'Settings') + # Synchronize with macosx.overrideRootMenu.config_dialog. + configdialog.ConfigDialog(self.top,'Settings') def help_dialog(self, event=None): "Handle Help 'IDLE Help' event." - # Synchronize with macosxSupport.overrideRootMenu.help_dialog. + # Synchronize with macosx.overrideRootMenu.help_dialog. if self.root: parent = self.root else: @@ -590,23 +540,23 @@ class EditorWindow(object): return "break" def find_event(self, event): - SearchDialog.find(self.text) + search.find(self.text) return "break" def find_again_event(self, event): - SearchDialog.find_again(self.text) + search.find_again(self.text) return "break" def find_selection_event(self, event): - SearchDialog.find_selection(self.text) + search.find_selection(self.text) return "break" def find_in_files_event(self, event): - GrepDialog.grep(self.text, self.io, self.flist) + grep.grep(self.text, self.io, self.flist) return "break" def replace_event(self, event): - ReplaceDialog.replace(self.text) + replace.replace(self.text) return "break" def goto_line_event(self, event): @@ -673,12 +623,12 @@ class EditorWindow(object): return head, tail = os.path.split(filename) base, ext = os.path.splitext(tail) - from idlelib import ClassBrowser - ClassBrowser.ClassBrowser(self.flist, base, [head]) + from idlelib import browser + browser.ClassBrowser(self.flist, base, [head]) def open_path_browser(self, event=None): - from idlelib import PathBrowser - PathBrowser.PathBrowser(self.flist) + from idlelib import pathbrowser + pathbrowser.PathBrowser(self.flist) def open_turtle_demo(self, event = None): import subprocess @@ -739,7 +689,7 @@ class EditorWindow(object): def ResetColorizer(self): "Update the color theme" - # Called from self.filename_change_hook and from configDialog.py + # Called from self.filename_change_hook and from configdialog.py self._rmcolorizer() self._addcolorizer() EditorWindow.color_config(self.text) @@ -759,14 +709,14 @@ class EditorWindow(object): def ResetFont(self): "Update the text widgets' font if it is changed" - # Called from configDialog.py + # Called from configdialog.py self.text['font'] = idleConf.GetFont(self.root, 'main','EditorWindow') def RemoveKeybindings(self): "Remove the keybindings before they are changed." - # Called from configDialog.py - self.Bindings.default_keydefs = keydefs = idleConf.GetCurrentKeySet() + # Called from configdialog.py + self.mainmenu.default_keydefs = keydefs = idleConf.GetCurrentKeySet() for event, keylist in keydefs.items(): self.text.event_delete(event, *keylist) for extensionName in self.get_standard_extension_names(): @@ -777,8 +727,8 @@ class EditorWindow(object): def ApplyKeybindings(self): "Update the keybindings after they are changed" - # Called from configDialog.py - self.Bindings.default_keydefs = keydefs = idleConf.GetCurrentKeySet() + # Called from configdialog.py + self.mainmenu.default_keydefs = keydefs = idleConf.GetCurrentKeySet() self.apply_bindings() for extensionName in self.get_standard_extension_names(): xkeydefs = idleConf.GetExtensionBindings(extensionName) @@ -786,7 +736,7 @@ class EditorWindow(object): self.apply_bindings(xkeydefs) #update menu accelerators menuEventDict = {} - for menu in self.Bindings.menudefs: + for menu in self.mainmenu.menudefs: menuEventDict[menu[0]] = {} for item in menu[1]: if item: @@ -813,7 +763,7 @@ class EditorWindow(object): def set_notabs_indentwidth(self): "Update the indentwidth if changed and not using tabs in this window" - # Called from configDialog.py + # Called from configdialog.py if not self.usetabs: self.indentwidth = idleConf.GetOption('main', 'Indent','num-spaces', type='int') @@ -993,7 +943,7 @@ class EditorWindow(object): def _close(self): if self.io.filename: self.update_recent_files_list(new_file=self.io.filename) - WindowList.unregister_callback(self.postwindowsmenu) + windows.unregister_callback(self.postwindowsmenu) self.unload_extensions() self.io.close() self.io = None @@ -1031,12 +981,25 @@ class EditorWindow(object): def get_standard_extension_names(self): return idleConf.GetExtensions(editor_only=True) + extfiles = { # map config-extension section names to new file names + 'AutoComplete': 'autocomplete', + 'AutoExpand': 'autoexpand', + 'CallTips': 'calltips', + 'CodeContext': 'codecontext', + 'FormatParagraph': 'paragraph', + 'ParenMatch': 'parenmatch', + 'RstripExtension': 'rstrip', + 'ScriptBinding': 'runscript', + 'ZoomHeight': 'zoomheight', + } + def load_extension(self, name): + fname = self.extfiles.get(name, name) try: try: - mod = importlib.import_module('.' + name, package=__package__) + mod = importlib.import_module('.' + fname, package=__package__) except (ImportError, TypeError): - mod = importlib.import_module(name) + mod = importlib.import_module(fname) except ImportError: print("\nFailed to import extension: ", name) raise @@ -1060,7 +1023,7 @@ class EditorWindow(object): def apply_bindings(self, keydefs=None): if keydefs is None: - keydefs = self.Bindings.default_keydefs + keydefs = self.mainmenu.default_keydefs text = self.text text.keydefs = keydefs for event, keylist in keydefs.items(): @@ -1073,9 +1036,9 @@ class EditorWindow(object): Menus that are absent or None in self.menudict are ignored. """ if menudefs is None: - menudefs = self.Bindings.menudefs + menudefs = self.mainmenu.menudefs if keydefs is None: - keydefs = self.Bindings.default_keydefs + keydefs = self.mainmenu.default_keydefs menudict = self.menudict text = self.text for mname, entrylist in menudefs: @@ -1302,7 +1265,7 @@ class EditorWindow(object): # adjust indentation for continuations and block # open/close first need to find the last stmt lno = index2line(text.index('insert')) - y = PyParse.Parser(self.indentwidth, self.tabwidth) + y = pyparse.Parser(self.indentwidth, self.tabwidth) if not self.context_use_ps1: for context in self.num_context_lines: startat = max(lno - context, 1) @@ -1326,22 +1289,22 @@ class EditorWindow(object): y.set_lo(0) c = y.get_continuation_type() - if c != PyParse.C_NONE: + if c != pyparse.C_NONE: # The current stmt hasn't ended yet. - if c == PyParse.C_STRING_FIRST_LINE: + if c == pyparse.C_STRING_FIRST_LINE: # after the first line of a string; do not indent at all pass - elif c == PyParse.C_STRING_NEXT_LINES: + elif c == pyparse.C_STRING_NEXT_LINES: # inside a string which started before this line; # just mimic the current indent text.insert("insert", indent) - elif c == PyParse.C_BRACKET: + elif c == pyparse.C_BRACKET: # line up with the first (if any) element of the # last open bracket structure; else indent one # level beyond the indent of the line with the # last open bracket self.reindent_to(y.compute_bracket_indent()) - elif c == PyParse.C_BACKSLASH: + elif c == pyparse.C_BACKSLASH: # if more than one line in this stmt already, just # mimic the current indent; else if initial line # has a start on an assignment stmt, indent to @@ -1644,7 +1607,7 @@ def get_accelerator(keydefs, eventname): keylist = keydefs.get(eventname) # issue10940: temporary workaround to prevent hang with OS X Cocoa Tk 8.5 # if not keylist: - if (not keylist) or (macosxSupport.isCocoaTk() and eventname in { + if (not keylist) or (macosx.isCocoaTk() and eventname in { "<<open-module>>", "<<goto-line>>", "<<change-indentwidth>>"}): @@ -1679,7 +1642,7 @@ def _editor_window(parent): # htest # filename = sys.argv[1] else: filename = None - macosxSupport.setupApp(root, None) + macosx.setupApp(root, None) edit = EditorWindow(root=root, filename=filename) edit.text.bind("<<close-all-windows>>", edit.close_event) # Does not stop error, neither does following diff --git a/Lib/idlelib/FileList.py b/Lib/idlelib/filelist.py index a9989a8624..b5af90ccaf 100644 --- a/Lib/idlelib/FileList.py +++ b/Lib/idlelib/filelist.py @@ -6,7 +6,7 @@ import tkinter.messagebox as tkMessageBox class FileList: # N.B. this import overridden in PyShellFileList. - from idlelib.EditorWindow import EditorWindow + from idlelib.editor import EditorWindow def __init__(self, root): self.root = root @@ -111,7 +111,7 @@ class FileList: def _test(): - from idlelib.EditorWindow import fixwordbreaks + from idlelib.editor import fixwordbreaks import sys root = Tk() fixwordbreaks(root) diff --git a/Lib/idlelib/GrepDialog.py b/Lib/idlelib/grep.py index 721b231a9e..28132a8917 100644 --- a/Lib/idlelib/GrepDialog.py +++ b/Lib/idlelib/grep.py @@ -4,14 +4,14 @@ import re # for htest import sys from tkinter import StringVar, BooleanVar, Checkbutton # for GrepDialog from tkinter import Tk, Text, Button, SEL, END # for htest -from idlelib import SearchEngine -from idlelib.SearchDialogBase import SearchDialogBase +from idlelib import searchengine +from idlelib.searchbase import SearchDialogBase # Importing OutputWindow fails due to import loop # EditorWindow -> GrepDialop -> OutputWindow -> EditorWindow def grep(text, io=None, flist=None): root = text._root() - engine = SearchEngine.get(root) + engine = searchengine.get(root) if not hasattr(engine, "_grepdialog"): engine._grepdialog = GrepDialog(root, engine, flist) dialog = engine._grepdialog @@ -67,7 +67,7 @@ class GrepDialog(SearchDialogBase): if not path: self.top.bell() return - from idlelib.OutputWindow import OutputWindow # leave here! + from idlelib.outwin import OutputWindow # leave here! save = sys.stdout try: sys.stdout = OutputWindow(self.flist) @@ -131,7 +131,7 @@ class GrepDialog(SearchDialogBase): def _grep_dialog(parent): # htest # - from idlelib.PyShell import PyShellFileList + from idlelib.pyshell import PyShellFileList root = Tk() root.title("Test GrepDialog") width, height, x, y = list(map(int, re.split('[x+]', parent.geometry()))) diff --git a/Lib/idlelib/help.py b/Lib/idlelib/help.py index d0c59c5fcf..d18d1ca3f2 100644 --- a/Lib/idlelib/help.py +++ b/Lib/idlelib/help.py @@ -4,7 +4,7 @@ Contents are subject to revision at any time, without notice. Help => About IDLE: diplay About Idle dialog -<to be moved here from aboutDialog.py> +<to be moved here from help_about.py> Help => IDLE Help: Display help.html with proper formatting. @@ -25,14 +25,11 @@ copy_strip - Copy idle.html to help.html, rstripping each line. show_idlehelp - Create HelpWindow. Called in EditorWindow.help_dialog. """ from html.parser import HTMLParser -from os.path import abspath, dirname, isdir, isfile, join -from tkinter import Tk, Toplevel, Frame, Text, Scrollbar, Menu, Menubutton +from os.path import abspath, dirname, isfile, join +from tkinter import Toplevel, Frame, Text, Menu +from tkinter.ttk import Menubutton, Scrollbar from tkinter import font as tkfont -from idlelib.configHandler import idleConf - -use_ttk = False # until available to import -if use_ttk: - from tkinter.ttk import Menubutton +from idlelib.config import idleConf ## About IDLE ## @@ -196,15 +193,18 @@ class HelpFrame(Frame): "Display html text, scrollbar, and toc." def __init__(self, parent, filename): Frame.__init__(self, parent) - text = HelpText(self, filename) + # keep references to widgets for test access. + self.text = text = HelpText(self, filename) self['background'] = text['background'] - scroll = Scrollbar(self, command=text.yview) + self.toc = toc = self.toc_menu(text) + self.scroll = scroll = Scrollbar(self, command=text.yview) text['yscrollcommand'] = scroll.set + self.rowconfigure(0, weight=1) self.columnconfigure(1, weight=1) # text - self.toc_menu(text).grid(column=0, row=0, sticky='nw') - text.grid(column=1, row=0, sticky='nsew') - scroll.grid(column=2, row=0, sticky='ns') + toc.grid(row=0, column=0, sticky='nw') + text.grid(row=0, column=1, sticky='nsew') + scroll.grid(row=0, column=2, sticky='ns') def toc_menu(self, text): "Create table of contents as drop-down menu." @@ -265,7 +265,7 @@ def show_idlehelp(parent): if not isfile(filename): # try copy_strip, present message return - HelpWindow(parent, filename, 'IDLE Help') + return HelpWindow(parent, filename, 'IDLE Help') if __name__ == '__main__': from idlelib.idle_test.htest import run diff --git a/Lib/idlelib/help.txt b/Lib/idlelib/help.txt deleted file mode 100644 index 89fbe0b41e..0000000000 --- a/Lib/idlelib/help.txt +++ /dev/null @@ -1,372 +0,0 @@ -This file, idlelib/help.txt is out-of-date and no longer used by Idle. -It is deprecated and will be removed in the future, possibly in 3.6 ----------------------------------------------------------------------- - -[See the end of this file for ** TIPS ** on using IDLE !!] - -IDLE is the Python IDE built with the tkinter GUI toolkit. - -IDLE has the following features: --coded in 100% pure Python, using the tkinter GUI toolkit --cross-platform: works on Windows, Unix, and OS X --multi-window text editor with multiple undo, Python colorizing, smart indent, -call tips, and many other features --Python shell window (a.k.a interactive interpreter) --debugger (not complete, but you can set breakpoints, view and step) - -Menus: - -IDLE has two window types the Shell window and the Editor window. It is -possible to have multiple editor windows simultaneously. IDLE's -menus dynamically change based on which window is currently selected. Each menu -documented below indicates which window type it is associated with. - -File Menu (Shell and Editor): - - New File -- Create a new file editing window - Open... -- Open an existing file - Open Module... -- Open an existing module (searches sys.path) - Recent Files... -- Open a list of recent files - Class Browser -- Show classes and methods in current file - Path Browser -- Show sys.path directories, modules, classes, - and methods - --- - Save -- Save current window to the associated file (unsaved - windows have a * before and after the window title) - - Save As... -- Save current window to new file, which becomes - the associated file - Save Copy As... -- Save current window to different file - without changing the associated file - --- - Print Window -- Print the current window - --- - Close -- Close current window (asks to save if unsaved) - Exit -- Close all windows, quit (asks to save if unsaved) - -Edit Menu (Shell and Editor): - - Undo -- Undo last change to current window - (a maximum of 1000 changes may be undone) - Redo -- Redo last undone change to current window - --- - Cut -- Copy a selection into system-wide clipboard, - then delete the selection - Copy -- Copy selection into system-wide clipboard - Paste -- Insert system-wide clipboard into window - Select All -- Select the entire contents of the edit buffer - --- - Find... -- Open a search dialog box with many options - Find Again -- Repeat last search - Find Selection -- Search for the string in the selection - Find in Files... -- Open a search dialog box for searching files - Replace... -- Open a search-and-replace dialog box - Go to Line -- Ask for a line number and show that line - Expand Word -- Expand the word you have typed to match another - word in the same buffer; repeat to get a - different expansion - Show Calltip -- After an unclosed parenthesis for a function, open - a small window with function parameter hints - Show Parens -- Highlight the surrounding parenthesis - Show Completions -- Open a scroll window allowing selection keywords - and attributes. (see '*TIPS*', below) - -Format Menu (Editor window only): - - Indent Region -- Shift selected lines right by the indent width - (default 4 spaces) - Dedent Region -- Shift selected lines left by the indent width - (default 4 spaces) - Comment Out Region -- Insert ## in front of selected lines - Uncomment Region -- Remove leading # or ## from selected lines - Tabify Region -- Turns *leading* stretches of spaces into tabs. - (Note: We recommend using 4 space blocks to indent Python code.) - Untabify Region -- Turn *all* tabs into the corrent number of spaces - Toggle tabs -- Open a dialog to switch between indenting with - spaces and tabs. - New Indent Width... -- Open a dialog to change indent width. The - accepted default by the Python community is 4 - spaces. - Format Paragraph -- Reformat the current blank-line-separated - paragraph. All lines in the paragraph will be - formatted to less than 80 columns. - --- - Strip trailing whitespace -- Removed any space characters after the end - of the last non-space character - -Run Menu (Editor window only): - - Python Shell -- Open or wake up the Python shell window - --- - Check Module -- Check the syntax of the module currently open in the - Editor window. If the module has not been saved IDLE - will prompt the user to save the code. - Run Module -- Restart the shell to clean the environment, then - execute the currently open module. If the module has - not been saved IDLE will prompt the user to save the - code. - -Shell Menu (Shell window only): - - View Last Restart -- Scroll the shell window to the last Shell restart - Restart Shell -- Restart the shell to clean the environment - -Debug Menu (Shell window only): - - Go to File/Line -- Look around the insert point for a filename - and line number, open the file, and show the line. - Useful to view the source lines referenced in an - exception traceback. Available in the context - menu of the Shell window. - Debugger (toggle) -- This feature is not complete and considered - experimental. Run commands in the shell under the - debugger. - Stack Viewer -- Show the stack traceback of the last exception - Auto-open Stack Viewer (toggle) -- Toggle automatically opening the - stack viewer on unhandled - exception - -Options Menu (Shell and Editor): - - Configure IDLE -- Open a configuration dialog. Fonts, indentation, - keybindings, and color themes may be altered. - Startup Preferences may be set, and additional Help - sources can be specified. On OS X, open the - configuration dialog by selecting Preferences - in the application menu. - - --- - Code Context (toggle) -- Open a pane at the top of the edit window - which shows the block context of the section - of code which is scrolling off the top or the - window. This is not present in the Shell - window only the Editor window. - -Window Menu (Shell and Editor): - - Zoom Height -- Toggles the window between normal size (40x80 initial - setting) and maximum height. The initial size is in the Configure - IDLE dialog under the general tab. - --- - The rest of this menu lists the names of all open windows; - select one to bring it to the foreground (deiconifying it if - necessary). - -Help Menu: - - About IDLE -- Version, copyright, license, credits - --- - IDLE Help -- Display this file which is a help file for IDLE - detailing the menu options, basic editing and navigation, - and other tips. - Python Docs -- Access local Python documentation, if - installed. Or will start a web browser and open - docs.python.org showing the latest Python documentation. - --- - Additional help sources may be added here with the Configure IDLE - dialog under the General tab. - -Editor context menu (Right-click / Control-click on OS X in Edit window): - - Cut -- Copy a selection into system-wide clipboard, - then delete the selection - Copy -- Copy selection into system-wide clipboard - Paste -- Insert system-wide clipboard into window - Set Breakpoint -- Sets a breakpoint. Breakpoints are only enabled - when the debugger is open. - Clear Breakpoint -- Clears the breakpoint on that line - -Shell context menu (Right-click / Control-click on OS X in Shell window): - - Cut -- Copy a selection into system-wide clipboard, - then delete the selection - Copy -- Copy selection into system-wide clipboard - Paste -- Insert system-wide clipboard into window - --- - Go to file/line -- Same as in Debug menu - - -** TIPS ** -========== - -Additional Help Sources: - - Windows users can Google on zopeshelf.chm to access Zope help files in - the Windows help format. The Additional Help Sources feature of the - configuration GUI supports .chm, along with any other filetypes - supported by your browser. Supply a Menu Item title, and enter the - location in the Help File Path slot of the New Help Source dialog. Use - http:// and/or www. to identify external URLs, or download the file and - browse for its path on your machine using the Browse button. - - All users can access the extensive sources of help, including - tutorials, available at docs.python.org. Selected URLs can be added - or removed from the Help menu at any time using Configure IDLE. - -Basic editing and navigation: - - Backspace deletes char to the left; DEL deletes char to the right. - Control-backspace deletes word left, Control-DEL deletes word right. - Arrow keys and Page Up/Down move around. - Control-left/right Arrow moves by words in a strange but useful way. - Home/End go to begin/end of line. - Control-Home/End go to begin/end of file. - Some useful Emacs bindings are inherited from Tcl/Tk: - Control-a beginning of line - Control-e end of line - Control-k kill line (but doesn't put it in clipboard) - Control-l center window around the insertion point - Standard keybindings (like Control-c to copy and Control-v to - paste) may work. Keybindings are selected in the Configure IDLE - dialog. - -Automatic indentation: - - After a block-opening statement, the next line is indented by 4 spaces - (in the Python Shell window by one tab). After certain keywords - (break, return etc.) the next line is dedented. In leading - indentation, Backspace deletes up to 4 spaces if they are there. Tab - inserts spaces (in the Python Shell window one tab), number depends on - Indent Width. Currently tabs are restricted to four spaces due - to Tcl/Tk limitations. - - See also the indent/dedent region commands in the edit menu. - -Completions: - - Completions are supplied for functions, classes, and attributes of - classes, both built-in and user-defined. Completions are also provided - for filenames. - - The AutoCompleteWindow (ACW) will open after a predefined delay - (default is two seconds) after a '.' or (in a string) an os.sep is - typed. If after one of those characters (plus zero or more other - characters) a tab is typed the ACW will open immediately if a possible - continuation is found. - - If there is only one possible completion for the characters entered, a - tab will supply that completion without opening the ACW. - - 'Show Completions' will force open a completions window, by default the - Control-space keys will open a completions window. In an empty - string, this will contain the files in the current directory. On a - blank line, it will contain the built-in and user-defined functions and - classes in the current name spaces, plus any modules imported. If some - characters have been entered, the ACW will attempt to be more specific. - - If string of characters is typed, the ACW selection will jump to the - entry most closely matching those characters. Entering a tab will cause - the longest non-ambiguous match to be entered in the Edit window or - Shell. Two tabs in a row will supply the current ACW selection, as - will return or a double click. Cursor keys, Page Up/Down, mouse - selection, and the scroll wheel all operate on the ACW. - - "Hidden" attributes can be accessed by typing the beginning of hidden - name after a '.', e.g. '_'. This allows access to modules with - '__all__' set, or to class-private attributes. - - Completions and the 'Expand Word' facility can save a lot of typing! - - Completions are currently limited to those in the namespaces. Names in - an Editor window which are not via __main__ or sys.modules will not be - found. Run the module once with your imports to correct this - situation. Note that IDLE itself places quite a few modules in - sys.modules, so much can be found by default, e.g. the re module. - - If you don't like the ACW popping up unbidden, simply make the delay - longer or disable the extension. Or another option is the delay could - be set to zero. Another alternative to preventing ACW popups is to - disable the call tips extension. - -Python Shell window: - - Control-c interrupts executing command. - Control-d sends end-of-file; closes window if typed at >>> prompt. - Alt-/ expand word is also useful to reduce typing. - - Command history: - - Alt-p retrieves previous command matching what you have typed. On OS X - use Control-p. - Alt-n retrieves next. On OS X use Control-n. - Return while cursor is on a previous command retrieves that command. - - Syntax colors: - - The coloring is applied in a background "thread", so you may - occasionally see uncolorized text. To change the color - scheme, use the Configure IDLE / Highlighting dialog. - - Python default syntax colors: - - Keywords orange - Builtins royal purple - Strings green - Comments red - Definitions blue - - Shell default colors: - - Console output brown - stdout blue - stderr red - stdin black - -Other preferences: - - The font preferences, highlighting, keys, and general preferences can - be changed via the Configure IDLE menu option. Be sure to note that - keys can be user defined, IDLE ships with four built in key sets. In - addition a user can create a custom key set in the Configure IDLE - dialog under the keys tab. - -Command line usage: - - Enter idle -h at the command prompt to get a usage message. - - idle.py [-c command] [-d] [-e] [-s] [-t title] [arg] ... - - -c command run this command - -d enable debugger - -e edit mode; arguments are files to be edited - -s run $IDLESTARTUP or $PYTHONSTARTUP first - -t title set title of shell window - - If there are arguments: - 1. If -e is used, arguments are files opened for editing and sys.argv - reflects the arguments passed to IDLE itself. - 2. Otherwise, if -c is used, all arguments are placed in - sys.argv[1:...], with sys.argv[0] set to -c. - 3. Otherwise, if neither -e nor -c is used, the first argument is a - script which is executed with the remaining arguments in - sys.argv[1:...] and sys.argv[0] set to the script name. If the - script name is -, no script is executed but an interactive Python - session is started; the arguments are still available in sys.argv. - -Running without a subprocess: (DEPRECATED in Python 3.4 see Issue 16123) - - If IDLE is started with the -n command line switch it will run in a - single process and will not create the subprocess which runs the RPC - Python execution server. This can be useful if Python cannot create - the subprocess or the RPC socket interface on your platform. However, - in this mode user code is not isolated from IDLE itself. Also, the - environment is not restarted when Run/Run Module (F5) is selected. If - your code has been modified, you must reload() the affected modules and - re-import any specific items (e.g. from foo import baz) if the changes - are to take effect. For these reasons, it is preferable to run IDLE - with the default subprocess if at all possible. - -Extensions: - - IDLE contains an extension facility. See the beginning of - config-extensions.def in the idlelib directory for further information. - The default extensions are currently: - - FormatParagraph - AutoExpand - ZoomHeight - ScriptBinding - CallTips - ParenMatch - AutoComplete - CodeContext diff --git a/Lib/idlelib/aboutDialog.py b/Lib/idlelib/help_about.py index 3112e6a3da..4b6c528950 100644 --- a/Lib/idlelib/aboutDialog.py +++ b/Lib/idlelib/help_about.py @@ -5,7 +5,7 @@ import os from sys import version from tkinter import * -from idlelib import textView +from idlelib import textview class AboutDialog(Toplevel): """Modal about dialog for idle @@ -135,11 +135,11 @@ class AboutDialog(Toplevel): def display_printer_text(self, title, printer): printer._Printer__setup() text = '\n'.join(printer._Printer__lines) - textView.view_text(self, title, text) + textview.view_text(self, title, text) def display_file_text(self, title, filename, encoding=None): fn = os.path.join(os.path.abspath(os.path.dirname(__file__)), filename) - textView.view_file(self, title, fn, encoding) + textview.view_file(self, title, fn, encoding) def Ok(self, event=None): self.destroy() diff --git a/Lib/idlelib/IdleHistory.py b/Lib/idlelib/history.py index 078af29053..6068d4f9fa 100644 --- a/Lib/idlelib/IdleHistory.py +++ b/Lib/idlelib/history.py @@ -1,11 +1,11 @@ "Implement Idle Shell history mechanism with History class" -from idlelib.configHandler import idleConf +from idlelib.config import idleConf class History: ''' Implement Idle Shell history mechanism. - store - Store source statement (called from PyShell.resetoutput). + store - Store source statement (called from pyshell.resetoutput). fetch - Fetch stored statement matching prefix already entered. history_next - Bound to <<history-next>> event (default Alt-N). history_prev - Bound to <<history-prev>> event (default Alt-P). diff --git a/Lib/idlelib/HyperParser.py b/Lib/idlelib/hyperparser.py index 77cb057ce2..f904a39e24 100644 --- a/Lib/idlelib/HyperParser.py +++ b/Lib/idlelib/hyperparser.py @@ -7,7 +7,7 @@ the structure of code. import string from keyword import iskeyword -from idlelib import PyParse +from idlelib import pyparse # all ASCII chars that may be in an identifier @@ -30,7 +30,7 @@ class HyperParser: self.editwin = editwin self.text = text = editwin.text - parser = PyParse.Parser(editwin.indentwidth, editwin.tabwidth) + parser = pyparse.Parser(editwin.indentwidth, editwin.tabwidth) def index2line(index): return int(float(index)) diff --git a/Lib/idlelib/idle.py b/Lib/idlelib/idle.py index a249557dd1..c01cf992cc 100644 --- a/Lib/idlelib/idle.py +++ b/Lib/idlelib/idle.py @@ -7,5 +7,5 @@ import sys idlelib_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, idlelib_dir) -import idlelib.PyShell -idlelib.PyShell.main() +import idlelib.pyshell +idlelib.pyshell.main() diff --git a/Lib/idlelib/idle.pyw b/Lib/idlelib/idle.pyw index 142cb322ac..e73c049b70 100644 --- a/Lib/idlelib/idle.pyw +++ b/Lib/idlelib/idle.pyw @@ -1,10 +1,10 @@ try: - import idlelib.PyShell + import idlelib.pyshell except ImportError: - # IDLE is not installed, but maybe PyShell is on sys.path: - from . import PyShell + # IDLE is not installed, but maybe pyshell is on sys.path: + from . import pyshell import os - idledir = os.path.dirname(os.path.abspath(PyShell.__file__)) + idledir = os.path.dirname(os.path.abspath(pyshell.__file__)) if idledir != os.getcwd(): # We're not in the IDLE directory, help the subprocess find run.py pypath = os.environ.get('PYTHONPATH', '') @@ -12,6 +12,6 @@ except ImportError: os.environ['PYTHONPATH'] = pypath + ':' + idledir else: os.environ['PYTHONPATH'] = idledir - PyShell.main() + pyshell.main() else: - idlelib.PyShell.main() + idlelib.pyshell.main() diff --git a/Lib/idlelib/idle_test/__init__.py b/Lib/idlelib/idle_test/__init__.py index 845c92d372..ad067b405c 100644 --- a/Lib/idlelib/idle_test/__init__.py +++ b/Lib/idlelib/idle_test/__init__.py @@ -1,6 +1,8 @@ '''idlelib.idle_test is a private implementation of test.test_idle, which tests the IDLE application as part of the stdlib test suite. Run IDLE tests alone with "python -m test.test_idle". +Starting with Python 3.6, IDLE requires tcl/tk 8.5 or later. + This package and its contained modules are subject to change and any direct use is at your own risk. ''' diff --git a/Lib/idlelib/idle_test/htest.py b/Lib/idlelib/idle_test/htest.py index 58e62cb4e2..d0177bb5ad 100644 --- a/Lib/idlelib/idle_test/htest.py +++ b/Lib/idlelib/idle_test/htest.py @@ -59,19 +59,19 @@ msg: master window hints about testing the widget. Modules and classes not being tested at the moment: -PyShell.PyShellEditorWindow -Debugger.Debugger -AutoCompleteWindow.AutoCompleteWindow -OutputWindow.OutputWindow (indirectly being tested with grep test) +pyshell.PyShellEditorWindow +debugger.Debugger +autocomplete_w.AutoCompleteWindow +outwin.OutputWindow (indirectly being tested with grep test) ''' from importlib import import_module -from idlelib.macosxSupport import _initializeTkVariantTests import tkinter as tk +from tkinter.ttk import Scrollbar AboutDialog_spec = { - 'file': 'aboutDialog', - 'kwds': {'title': 'aboutDialog test', + 'file': 'help_about', + 'kwds': {'title': 'help_about test', '_htest': True, }, 'msg': "Test every button. Ensure Python, TK and IDLE versions " @@ -79,14 +79,14 @@ AboutDialog_spec = { } _calltip_window_spec = { - 'file': 'CallTipWindow', + 'file': 'calltip_w', 'kwds': {}, 'msg': "Typing '(' should display a calltip.\n" "Typing ') should hide the calltip.\n" } _class_browser_spec = { - 'file': 'ClassBrowser', + 'file': 'browser', 'kwds': {}, 'msg': "Inspect names of module, class(with superclass if " "applicable), methods and functions.\nToggle nested items.\n" @@ -95,7 +95,7 @@ _class_browser_spec = { } _color_delegator_spec = { - 'file': 'ColorDelegator', + 'file': 'colorizer', 'kwds': {}, 'msg': "The text is sample Python code.\n" "Ensure components like comments, keywords, builtins,\n" @@ -104,7 +104,7 @@ _color_delegator_spec = { } ConfigDialog_spec = { - 'file': 'configDialog', + 'file': 'configdialog', 'kwds': {'title': 'ConfigDialogTest', '_htest': True,}, 'msg': "IDLE preferences dialog.\n" @@ -121,7 +121,7 @@ ConfigDialog_spec = { # TODO Improve message _dyn_option_menu_spec = { - 'file': 'dynOptionMenuWidget', + 'file': 'dynoption', 'kwds': {}, 'msg': "Select one of the many options in the 'old option set'.\n" "Click the button to change the option set.\n" @@ -130,14 +130,14 @@ _dyn_option_menu_spec = { # TODO edit wrapper _editor_window_spec = { - 'file': 'EditorWindow', + 'file': 'editor', 'kwds': {}, 'msg': "Test editor functions of interest.\n" "Best to close editor first." } GetCfgSectionNameDialog_spec = { - 'file': 'configSectionNameDialog', + 'file': 'config_sec', 'kwds': {'title':'Get Name', 'message':'Enter something', 'used_names': {'abc'}, @@ -149,7 +149,7 @@ GetCfgSectionNameDialog_spec = { } GetHelpSourceDialog_spec = { - 'file': 'configHelpSourceEdit', + 'file': 'config_help', 'kwds': {'title': 'Get helpsource', '_htest': True}, 'msg': "Enter menu item name and help file path\n " @@ -162,7 +162,7 @@ GetHelpSourceDialog_spec = { # Update once issue21519 is resolved. GetKeysDialog_spec = { - 'file': 'keybindingDialog', + 'file': 'config_key', 'kwds': {'title': 'Test keybindings', 'action': 'find-again', 'currentKeySequences': [''] , @@ -177,7 +177,7 @@ GetKeysDialog_spec = { } _grep_dialog_spec = { - 'file': 'GrepDialog', + 'file': 'grep', 'kwds': {}, 'msg': "Click the 'Show GrepDialog' button.\n" "Test the various 'Find-in-files' functions.\n" @@ -187,7 +187,7 @@ _grep_dialog_spec = { } _io_binding_spec = { - 'file': 'IOBinding', + 'file': 'iomenu', 'kwds': {}, 'msg': "Test the following bindings.\n" "<Control-o> to open file from dialog.\n" @@ -200,7 +200,7 @@ _io_binding_spec = { } _multi_call_spec = { - 'file': 'MultiCall', + 'file': 'multicall', 'kwds': {}, 'msg': "The following actions should trigger a print to console or IDLE" " Shell.\nEntering and leaving the text area, key entry, " @@ -210,14 +210,14 @@ _multi_call_spec = { } _multistatus_bar_spec = { - 'file': 'MultiStatusBar', + 'file': 'statusbar', 'kwds': {}, 'msg': "Ensure presence of multi-status bar below text area.\n" "Click 'Update Status' to change the multi-status text" } _object_browser_spec = { - 'file': 'ObjectBrowser', + 'file': 'debugobj', 'kwds': {}, 'msg': "Double click on items upto the lowest level.\n" "Attributes of the objects and related information " @@ -225,7 +225,7 @@ _object_browser_spec = { } _path_browser_spec = { - 'file': 'PathBrowser', + 'file': 'pathbrowser', 'kwds': {}, 'msg': "Test for correct display of all paths in sys.path.\n" "Toggle nested items upto the lowest level.\n" @@ -234,7 +234,7 @@ _path_browser_spec = { } _percolator_spec = { - 'file': 'Percolator', + 'file': 'percolator', 'kwds': {}, 'msg': "There are two tracers which can be toggled using a checkbox.\n" "Toggling a tracer 'on' by checking it should print tracer" @@ -245,7 +245,7 @@ _percolator_spec = { } _replace_dialog_spec = { - 'file': 'ReplaceDialog', + 'file': 'replace', 'kwds': {}, 'msg': "Click the 'Replace' button.\n" "Test various replace options in the 'Replace dialog'.\n" @@ -253,7 +253,7 @@ _replace_dialog_spec = { } _search_dialog_spec = { - 'file': 'SearchDialog', + 'file': 'search', 'kwds': {}, 'msg': "Click the 'Search' button.\n" "Test various search options in the 'Search dialog'.\n" @@ -261,7 +261,7 @@ _search_dialog_spec = { } _scrolled_list_spec = { - 'file': 'ScrolledList', + 'file': 'scrolledlist', 'kwds': {}, 'msg': "You should see a scrollable list of items\n" "Selecting (clicking) or double clicking an item " @@ -277,7 +277,7 @@ show_idlehelp_spec = { } _stack_viewer_spec = { - 'file': 'StackViewer', + 'file': 'stackviewer', 'kwds': {}, 'msg': "A stacktrace for a NameError exception.\n" "Expand 'idlelib ...' and '<locals>'.\n" @@ -295,8 +295,8 @@ _tabbed_pages_spec = { } TextViewer_spec = { - 'file': 'textView', - 'kwds': {'title': 'Test textView', + 'file': 'textview', + 'kwds': {'title': 'Test textview', 'text':'The quick brown fox jumps over the lazy dog.\n'*35, '_htest': True}, 'msg': "Test for read-only property of text.\n" @@ -304,21 +304,21 @@ TextViewer_spec = { } _tooltip_spec = { - 'file': 'ToolTip', + 'file': 'tooltip', 'kwds': {}, 'msg': "Place mouse cursor over both the buttons\n" "A tooltip should appear with some text." } _tree_widget_spec = { - 'file': 'TreeWidget', + 'file': 'tree', 'kwds': {}, 'msg': "The canvas is scrollable.\n" "Click on folders upto to the lowest level." } _undo_delegator_spec = { - 'file': 'UndoDelegator', + 'file': 'undo', 'kwds': {}, 'msg': "Click [Undo] to undo any action.\n" "Click [Redo] to redo any action.\n" @@ -327,7 +327,7 @@ _undo_delegator_spec = { } _widget_redirector_spec = { - 'file': 'WidgetRedirector', + 'file': 'redirector', 'kwds': {}, 'msg': "Every text insert should be printed to the console." "or the IDLE shell." @@ -337,14 +337,13 @@ def run(*tests): root = tk.Tk() root.title('IDLE htest') root.resizable(0, 0) - _initializeTkVariantTests(root) # a scrollable Label like constant width text widget. frameLabel = tk.Frame(root, padx=10) frameLabel.pack() text = tk.Text(frameLabel, wrap='word') text.configure(bg=root.cget('bg'), relief='flat', height=4, width=70) - scrollbar = tk.Scrollbar(frameLabel, command=text.yview) + scrollbar = Scrollbar(frameLabel, command=text.yview) text.config(yscrollcommand=scrollbar.set) scrollbar.pack(side='right', fill='y', expand=False) text.pack(side='left', fill='both', expand=True) diff --git a/Lib/idlelib/idle_test/mock_idle.py b/Lib/idlelib/idle_test/mock_idle.py index 1672a3413e..c7b49ef02b 100644 --- a/Lib/idlelib/idle_test/mock_idle.py +++ b/Lib/idlelib/idle_test/mock_idle.py @@ -33,7 +33,7 @@ class Func: class Editor: - '''Minimally imitate EditorWindow.EditorWindow class. + '''Minimally imitate editor.EditorWindow class. ''' def __init__(self, flist=None, filename=None, key=None, root=None): self.text = Text() @@ -46,7 +46,7 @@ class Editor: class UndoDelegator: - '''Minimally imitate UndoDelegator,UndoDelegator class. + '''Minimally imitate undo.UndoDelegator class. ''' # A real undo block is only needed for user interaction. def undo_block_start(*args): diff --git a/Lib/idlelib/idle_test/test_autocomplete.py b/Lib/idlelib/idle_test/test_autocomplete.py index e4493d1205..a14c6db349 100644 --- a/Lib/idlelib/idle_test/test_autocomplete.py +++ b/Lib/idlelib/idle_test/test_autocomplete.py @@ -1,10 +1,14 @@ +''' Test autocomplete and autocomple_w + +Coverage of autocomple: 56% +''' import unittest from test.support import requires from tkinter import Tk, Text -import idlelib.AutoComplete as ac -import idlelib.AutoCompleteWindow as acw -import idlelib.macosxSupport as mac +import idlelib.autocomplete as ac +import idlelib.autocomplete_w as acw +from idlelib import macosx from idlelib.idle_test.mock_idle import Func from idlelib.idle_test.mock_tk import Event @@ -27,7 +31,7 @@ class AutoCompleteTest(unittest.TestCase): def setUpClass(cls): requires('gui') cls.root = Tk() - mac.setupApp(cls.root, None) + macosx.setupApp(cls.root, None) cls.text = Text(cls.root) cls.editor = DummyEditwin(cls.root, cls.text) diff --git a/Lib/idlelib/idle_test/test_autoexpand.py b/Lib/idlelib/idle_test/test_autoexpand.py index d2a3156dca..5d234dd862 100644 --- a/Lib/idlelib/idle_test/test_autoexpand.py +++ b/Lib/idlelib/idle_test/test_autoexpand.py @@ -1,9 +1,9 @@ -"""Unit tests for idlelib.AutoExpand""" +"""Unit tests for idlelib.autoexpand""" import unittest from test.support import requires from tkinter import Text, Tk #from idlelib.idle_test.mock_tk import Text -from idlelib.AutoExpand import AutoExpand +from idlelib.autoexpand import AutoExpand class Dummy_Editwin: diff --git a/Lib/idlelib/idle_test/test_calltips.py b/Lib/idlelib/idle_test/test_calltips.py index b2a733cc0d..0b11602ca9 100644 --- a/Lib/idlelib/idle_test/test_calltips.py +++ b/Lib/idlelib/idle_test/test_calltips.py @@ -1,5 +1,5 @@ import unittest -import idlelib.CallTips as ct +import idlelib.calltips as ct import textwrap import types diff --git a/Lib/idlelib/idle_test/test_colorizer.py b/Lib/idlelib/idle_test/test_colorizer.py new file mode 100644 index 0000000000..238bc3e114 --- /dev/null +++ b/Lib/idlelib/idle_test/test_colorizer.py @@ -0,0 +1,56 @@ +'''Test idlelib/colorizer.py + +Perform minimal sanity checks that module imports and some things run. + +Coverage 22%. +''' +from idlelib import colorizer # always test import +from test.support import requires +from tkinter import Tk, Text +import unittest + + +class FunctionTest(unittest.TestCase): + + def test_any(self): + self.assertTrue(colorizer.any('test', ('a', 'b'))) + + def test_make_pat(self): + self.assertTrue(colorizer.make_pat()) + + +class ColorConfigTest(unittest.TestCase): + + @classmethod + def setUpClass(cls): + requires('gui') + cls.root = Tk() + cls.text = Text(cls.root) + + @classmethod + def tearDownClass(cls): + del cls.text + cls.root.destroy() + del cls.root + + def test_colorizer(self): + colorizer.color_config(self.text) + +class ColorDelegatorTest(unittest.TestCase): + + @classmethod + def setUpClass(cls): + requires('gui') + cls.root = Tk() + + @classmethod + def tearDownClass(cls): + cls.root.destroy() + del cls.root + + def test_colorizer(self): + colorizer.ColorDelegator() + + +if __name__ == '__main__': + unittest.main(verbosity=2) diff --git a/Lib/idlelib/idle_test/test_config_help.py b/Lib/idlelib/idle_test/test_config_help.py index 664f8edc62..b89b4e3ca1 100644 --- a/Lib/idlelib/idle_test/test_config_help.py +++ b/Lib/idlelib/idle_test/test_config_help.py @@ -1,7 +1,7 @@ -"""Unittests for idlelib.configHelpSourceEdit""" +"""Unittests for idlelib.config_help.py""" import unittest from idlelib.idle_test.mock_tk import Var, Mbox, Entry -from idlelib import configHelpSourceEdit as help_dialog_module +from idlelib import config_help as help_dialog_module help_dialog = help_dialog_module.GetHelpSourceDialog diff --git a/Lib/idlelib/idle_test/test_config_key.py b/Lib/idlelib/idle_test/test_config_key.py new file mode 100644 index 0000000000..8109829f10 --- /dev/null +++ b/Lib/idlelib/idle_test/test_config_key.py @@ -0,0 +1,31 @@ +''' Test idlelib.config_key. + +Coverage: 56% +''' +from idlelib import config_key +from test.support import requires +requires('gui') +import unittest +from tkinter import Tk, Text + + +class GetKeysTest(unittest.TestCase): + + @classmethod + def setUpClass(cls): + cls.root = Tk() + + @classmethod + def tearDownClass(cls): + cls.root.destroy() + del cls.root + + + def test_init(self): + dia = config_key.GetKeysDialog( + self.root, 'test', '<<Test>>', ['<Key-F12>'], _utest=True) + dia.Cancel() + + +if __name__ == '__main__': + unittest.main(verbosity=2) diff --git a/Lib/idlelib/idle_test/test_config_name.py b/Lib/idlelib/idle_test/test_config_sec.py index 40e72b9551..a98b484bf7 100644 --- a/Lib/idlelib/idle_test/test_config_name.py +++ b/Lib/idlelib/idle_test/test_config_sec.py @@ -1,7 +1,7 @@ -"""Unit tests for idlelib.configSectionNameDialog""" +"""Unit tests for idlelib.config_sec""" import unittest from idlelib.idle_test.mock_tk import Var, Mbox -from idlelib import configSectionNameDialog as name_dialog_module +from idlelib import config_sec as name_dialog_module name_dialog = name_dialog_module.GetCfgSectionNameDialog diff --git a/Lib/idlelib/idle_test/test_configdialog.py b/Lib/idlelib/idle_test/test_configdialog.py index b063601b27..1801a7d6c2 100644 --- a/Lib/idlelib/idle_test/test_configdialog.py +++ b/Lib/idlelib/idle_test/test_configdialog.py @@ -1,21 +1,19 @@ -'''Test idlelib.configDialog. +'''Test idlelib.configdialog. Coverage: 46% just by creating dialog. The other half is code for working with user customizations. ''' -from idlelib.configDialog import ConfigDialog # always test import +from idlelib.configdialog import ConfigDialog # always test import from test.support import requires requires('gui') from tkinter import Tk import unittest -from idlelib import macosxSupport as macosx class ConfigDialogTest(unittest.TestCase): @classmethod def setUpClass(cls): cls.root = Tk() - macosx._initializeTkVariantTests(cls.root) @classmethod def tearDownClass(cls): diff --git a/Lib/idlelib/idle_test/test_debugger.py b/Lib/idlelib/idle_test/test_debugger.py new file mode 100644 index 0000000000..bcba9a45c1 --- /dev/null +++ b/Lib/idlelib/idle_test/test_debugger.py @@ -0,0 +1,29 @@ +''' Test idlelib.debugger. + +Coverage: 19% +''' +from idlelib import debugger +from test.support import requires +requires('gui') +import unittest +from tkinter import Tk + + +class NameSpaceTest(unittest.TestCase): + + @classmethod + def setUpClass(cls): + cls.root = Tk() + cls.root.withdraw() + + @classmethod + def tearDownClass(cls): + cls.root.destroy() + del cls.root + + def test_init(self): + debugger.NamespaceViewer(self.root, 'Test') + + +if __name__ == '__main__': + unittest.main(verbosity=2) diff --git a/Lib/idlelib/idle_test/test_delegator.py b/Lib/idlelib/idle_test/test_delegator.py index 1f0baa9c0d..85624fbc12 100644 --- a/Lib/idlelib/idle_test/test_delegator.py +++ b/Lib/idlelib/idle_test/test_delegator.py @@ -1,5 +1,5 @@ import unittest -from idlelib.Delegator import Delegator +from idlelib.delegator import Delegator class DelegatorTest(unittest.TestCase): diff --git a/Lib/idlelib/idle_test/test_editmenu.py b/Lib/idlelib/idle_test/test_editmenu.py index 50317a97e5..654f060225 100644 --- a/Lib/idlelib/idle_test/test_editmenu.py +++ b/Lib/idlelib/idle_test/test_editmenu.py @@ -5,8 +5,9 @@ Edit modules have their own test files files from test.support import requires requires('gui') import tkinter as tk +from tkinter import ttk import unittest -from idlelib import PyShell +from idlelib import pyshell class PasteTest(unittest.TestCase): '''Test pasting into widgets that allow pasting. @@ -16,16 +17,17 @@ class PasteTest(unittest.TestCase): @classmethod def setUpClass(cls): cls.root = root = tk.Tk() - PyShell.fix_x11_paste(root) + pyshell.fix_x11_paste(root) cls.text = tk.Text(root) cls.entry = tk.Entry(root) + cls.tentry = ttk.Entry(root) cls.spin = tk.Spinbox(root) root.clipboard_clear() root.clipboard_append('two') @classmethod def tearDownClass(cls): - del cls.text, cls.entry, cls.spin + del cls.text, cls.entry, cls.tentry cls.root.clipboard_clear() cls.root.update_idletasks() cls.root.destroy() @@ -43,16 +45,16 @@ class PasteTest(unittest.TestCase): def test_paste_entry(self): "Test pasting into an entry with and without a selection." - # On 3.6, generated <<Paste>> fails without empty select range - # for 'no selection'. Live widget works fine. - entry = self.entry - for end, ans in (0, 'onetwo'), ('end', 'two'): - with self.subTest(entry=entry, end=end, ans=ans): - entry.delete(0, 'end') - entry.insert(0, 'one') - entry.select_range(0, end) # see note - entry.event_generate('<<Paste>>') - self.assertEqual(entry.get(), ans) + # Generated <<Paste>> fails for tk entry without empty select + # range for 'no selection'. Live widget works fine. + for entry in self.entry, self.tentry: + for end, ans in (0, 'onetwo'), ('end', 'two'): + with self.subTest(entry=entry, end=end, ans=ans): + entry.delete(0, 'end') + entry.insert(0, 'one') + entry.select_range(0, end) + entry.event_generate('<<Paste>>') + self.assertEqual(entry.get(), ans) def test_paste_spin(self): "Test pasting into a spinbox with and without a selection." diff --git a/Lib/idlelib/idle_test/test_editor.py b/Lib/idlelib/idle_test/test_editor.py index a31d26d25d..e9d29d45b8 100644 --- a/Lib/idlelib/idle_test/test_editor.py +++ b/Lib/idlelib/idle_test/test_editor.py @@ -1,6 +1,6 @@ import unittest from tkinter import Tk, Text -from idlelib.EditorWindow import EditorWindow +from idlelib.editor import EditorWindow from test.support import requires class Editor_func_test(unittest.TestCase): diff --git a/Lib/idlelib/idle_test/test_grep.py b/Lib/idlelib/idle_test/test_grep.py index 0d8ff0d9f1..6b54c13131 100644 --- a/Lib/idlelib/idle_test/test_grep.py +++ b/Lib/idlelib/idle_test/test_grep.py @@ -1,5 +1,5 @@ """ !Changing this line will break Test_findfile.test_found! -Non-gui unit tests for idlelib.GrepDialog methods. +Non-gui unit tests for grep.GrepDialog methods. dummy_command calls grep_it calls findfiles. An exception raised in one method will fail callers. Otherwise, tests are mostly independent. @@ -8,7 +8,7 @@ Otherwise, tests are mostly independent. import unittest from test.support import captured_stdout from idlelib.idle_test.mock_tk import Var -from idlelib.GrepDialog import GrepDialog +from idlelib.grep import GrepDialog import re class Dummy_searchengine: @@ -72,7 +72,7 @@ class Grep_itTest(unittest.TestCase): self.assertTrue(lines[4].startswith('(Hint:')) class Default_commandTest(unittest.TestCase): - # To write this, mode OutputWindow import to top of GrepDialog + # To write this, move outwin import to top of GrepDialog # so it can be replaced by captured_stdout in class setup/teardown. pass diff --git a/Lib/idlelib/idle_test/test_help.py b/Lib/idlelib/idle_test/test_help.py new file mode 100644 index 0000000000..cdded2ac79 --- /dev/null +++ b/Lib/idlelib/idle_test/test_help.py @@ -0,0 +1,34 @@ +'''Test idlelib.help. + +Coverage: 87% +''' +from idlelib import help +from test.support import requires +requires('gui') +from os.path import abspath, dirname, join +from tkinter import Tk +import unittest + +class HelpFrameTest(unittest.TestCase): + + @classmethod + def setUpClass(cls): + "By itself, this tests that file parsed without exception." + cls.root = root = Tk() + root.withdraw() + helpfile = join(abspath(dirname(dirname(__file__))), 'help.html') + cls.frame = help.HelpFrame(root, helpfile) + + @classmethod + def tearDownClass(cls): + del cls.frame + cls.root.update_idletasks() + cls.root.destroy() + del cls.root + + def test_line1(self): + text = self.frame.text + self.assertEqual(text.get('1.0', '1.end'), ' IDLE ') + +if __name__ == '__main__': + unittest.main(verbosity=2) diff --git a/Lib/idlelib/idle_test/test_idlehistory.py b/Lib/idlelib/idle_test/test_history.py index d7c3d70393..6e8269c5f5 100644 --- a/Lib/idlelib/idle_test/test_idlehistory.py +++ b/Lib/idlelib/idle_test/test_history.py @@ -4,8 +4,8 @@ from test.support import requires import tkinter as tk from tkinter import Text as tkText from idlelib.idle_test.mock_tk import Text as mkText -from idlelib.IdleHistory import History -from idlelib.configHandler import idleConf +from idlelib.history import History +from idlelib.config import idleConf line1 = 'a = 7' line2 = 'b = a' diff --git a/Lib/idlelib/idle_test/test_hyperparser.py b/Lib/idlelib/idle_test/test_hyperparser.py index edfc783fe8..067e5b19e8 100644 --- a/Lib/idlelib/idle_test/test_hyperparser.py +++ b/Lib/idlelib/idle_test/test_hyperparser.py @@ -1,9 +1,9 @@ -"""Unittest for idlelib.HyperParser""" +"""Unittest for idlelib.hyperparser.py.""" import unittest from test.support import requires from tkinter import Tk, Text -from idlelib.EditorWindow import EditorWindow -from idlelib.HyperParser import HyperParser +from idlelib.editor import EditorWindow +from idlelib.hyperparser import HyperParser class DummyEditwin: def __init__(self, text): diff --git a/Lib/idlelib/idle_test/test_io.py b/Lib/idlelib/idle_test/test_iomenu.py index e0e3b985e2..f8ff1127c3 100644 --- a/Lib/idlelib/idle_test/test_io.py +++ b/Lib/idlelib/idle_test/test_iomenu.py @@ -1,6 +1,6 @@ import unittest import io -from idlelib.PyShell import PseudoInputFile, PseudoOutputFile +from idlelib.pyshell import PseudoInputFile, PseudoOutputFile class S(str): diff --git a/Lib/idlelib/idle_test/test_macosx.py b/Lib/idlelib/idle_test/test_macosx.py new file mode 100644 index 0000000000..3c6161c518 --- /dev/null +++ b/Lib/idlelib/idle_test/test_macosx.py @@ -0,0 +1,101 @@ +'''Test idlelib.macosx.py. + +Coverage: 71% on Windows. +''' +from idlelib import macosx +from test.support import requires +import sys +import tkinter as tk +import unittest +import unittest.mock as mock +from idlelib.filelist import FileList + +mactypes = {'carbon', 'cocoa', 'xquartz'} +nontypes = {'other'} +alltypes = mactypes | nontypes + + +class InitTktypeTest(unittest.TestCase): + "Test _init_tk_type." + + @classmethod + def setUpClass(cls): + requires('gui') + cls.root = tk.Tk() + cls.orig_platform = macosx.platform + + @classmethod + def tearDownClass(cls): + cls.root.update_idletasks() + cls.root.destroy() + del cls.root + macosx.platform = cls.orig_platform + + def test_init_sets_tktype(self): + "Test that _init_tk_type sets _tk_type according to platform." + for platform, types in ('darwin', alltypes), ('other', nontypes): + with self.subTest(platform=platform): + macosx.platform = platform + macosx._tk_type == None + macosx._init_tk_type() + self.assertIn(macosx._tk_type, types) + + +class IsTypeTkTest(unittest.TestCase): + "Test each of the four isTypeTk predecates." + isfuncs = ((macosx.isAquaTk, ('carbon', 'cocoa')), + (macosx.isCarbonTk, ('carbon')), + (macosx.isCocoaTk, ('cocoa')), + (macosx.isXQuartz, ('xquartz')), + ) + + @mock.patch('idlelib.macosx._init_tk_type') + def test_is_calls_init(self, mockinit): + "Test that each isTypeTk calls _init_tk_type when _tk_type is None." + macosx._tk_type = None + for func, whentrue in self.isfuncs: + with self.subTest(func=func): + func() + self.assertTrue(mockinit.called) + mockinit.reset_mock() + + def test_isfuncs(self): + "Test that each isTypeTk return correct bool." + for func, whentrue in self.isfuncs: + for tktype in alltypes: + with self.subTest(func=func, whentrue=whentrue, tktype=tktype): + macosx._tk_type = tktype + (self.assertTrue if tktype in whentrue else self.assertFalse)\ + (func()) + + +class SetupTest(unittest.TestCase): + "Test setupApp." + + @classmethod + def setUpClass(cls): + requires('gui') + cls.root = tk.Tk() + + @classmethod + def tearDownClass(cls): + cls.root.update_idletasks() + cls.root.destroy() + del cls.root + + @mock.patch('idlelib.macosx.overrideRootMenu') #27312 + def test_setupapp(self, overrideRootMenu): + "Call setupApp with each possible graphics type." + root = self.root + flist = FileList(root) + for tktype in alltypes: + with self.subTest(tktype=tktype): + macosx._tk_type = tktype + macosx.setupApp(root, flist) + if tktype in ('carbon', 'cocoa'): + self.assertTrue(overrideRootMenu.called) + overrideRootMenu.reset_mock() + + +if __name__ == '__main__': + unittest.main(verbosity=2) diff --git a/Lib/idlelib/idle_test/test_formatparagraph.py b/Lib/idlelib/idle_test/test_paragraph.py index e5561d84a6..4741eb87be 100644 --- a/Lib/idlelib/idle_test/test_formatparagraph.py +++ b/Lib/idlelib/idle_test/test_paragraph.py @@ -1,7 +1,7 @@ -# Test the functions and main class method of FormatParagraph.py +# Test the functions and main class method of paragraph.py import unittest -from idlelib import FormatParagraph as fp -from idlelib.EditorWindow import EditorWindow +from idlelib import paragraph as fp +from idlelib.editor import EditorWindow from tkinter import Tk, Text from test.support import requires @@ -38,7 +38,7 @@ class Is_Get_Test(unittest.TestCase): class FindTest(unittest.TestCase): - """Test the find_paragraph function in FormatParagraph. + """Test the find_paragraph function in paragraph module. Using the runcase() function, find_paragraph() is called with 'mark' set at multiple indexes before and inside the test paragraph. diff --git a/Lib/idlelib/idle_test/test_parenmatch.py b/Lib/idlelib/idle_test/test_parenmatch.py index 95cc22cf68..d467a9a97a 100644 --- a/Lib/idlelib/idle_test/test_parenmatch.py +++ b/Lib/idlelib/idle_test/test_parenmatch.py @@ -1,4 +1,4 @@ -'''Test idlelib.ParenMatch. +'''Test idlelib.parenmatch. This must currently be a gui test because ParenMatch methods use several text methods not defined on idlelib.idle_test.mock_tk.Text. @@ -9,7 +9,7 @@ requires('gui') import unittest from unittest.mock import Mock from tkinter import Tk, Text -from idlelib.ParenMatch import ParenMatch +from idlelib.parenmatch import ParenMatch class DummyEditwin: def __init__(self, text): diff --git a/Lib/idlelib/idle_test/test_pathbrowser.py b/Lib/idlelib/idle_test/test_pathbrowser.py index afb886fa33..813cbcc631 100644 --- a/Lib/idlelib/idle_test/test_pathbrowser.py +++ b/Lib/idlelib/idle_test/test_pathbrowser.py @@ -2,13 +2,13 @@ import unittest import os import sys import idlelib -from idlelib import PathBrowser +from idlelib import pathbrowser class PathBrowserTest(unittest.TestCase): def test_DirBrowserTreeItem(self): # Issue16226 - make sure that getting a sublist works - d = PathBrowser.DirBrowserTreeItem('') + d = pathbrowser.DirBrowserTreeItem('') d.GetSubList() self.assertEqual('', d.GetText()) @@ -17,11 +17,11 @@ class PathBrowserTest(unittest.TestCase): self.assertEqual(d.ispackagedir(dir + '/Icons'), False) def test_PathBrowserTreeItem(self): - p = PathBrowser.PathBrowserTreeItem() + p = pathbrowser.PathBrowserTreeItem() self.assertEqual(p.GetText(), 'sys.path') sub = p.GetSubList() self.assertEqual(len(sub), len(sys.path)) - self.assertEqual(type(sub[0]), PathBrowser.DirBrowserTreeItem) + self.assertEqual(type(sub[0]), pathbrowser.DirBrowserTreeItem) if __name__ == '__main__': unittest.main(verbosity=2, exit=False) diff --git a/Lib/idlelib/idle_test/test_percolator.py b/Lib/idlelib/idle_test/test_percolator.py index 4c0a7ad2bd..573b9a1e8e 100644 --- a/Lib/idlelib/idle_test/test_percolator.py +++ b/Lib/idlelib/idle_test/test_percolator.py @@ -1,10 +1,10 @@ -'''Test Percolator''' +'''Test percolator.py.''' from test.support import requires requires('gui') import unittest from tkinter import Text, Tk, END -from idlelib.Percolator import Percolator, Delegator +from idlelib.percolator import Percolator, Delegator class MyFilter(Delegator): diff --git a/Lib/idlelib/idle_test/test_widgetredir.py b/Lib/idlelib/idle_test/test_redirector.py index c68dfcc412..c8dd1184c4 100644 --- a/Lib/idlelib/idle_test/test_widgetredir.py +++ b/Lib/idlelib/idle_test/test_redirector.py @@ -1,4 +1,4 @@ -'''Test idlelib.WidgetRedirector. +'''Test idlelib.redirector. 100% coverage ''' @@ -6,7 +6,7 @@ from test.support import requires import unittest from idlelib.idle_test.mock_idle import Func from tkinter import Tk, Text, TclError -from idlelib.WidgetRedirector import WidgetRedirector +from idlelib.redirector import WidgetRedirector class InitCloseTest(unittest.TestCase): @@ -118,6 +118,5 @@ class WidgetRedirectorTest(unittest.TestCase): self.assertEqual(self.root.call(self.text._w, 'insert', 'boo'), '') - if __name__ == '__main__': unittest.main(verbosity=2) diff --git a/Lib/idlelib/idle_test/test_replacedialog.py b/Lib/idlelib/idle_test/test_replace.py index ff44820809..a9f3e15f25 100644 --- a/Lib/idlelib/idle_test/test_replacedialog.py +++ b/Lib/idlelib/idle_test/test_replace.py @@ -1,4 +1,4 @@ -"""Unittest for idlelib.ReplaceDialog""" +"""Unittest for idlelib.replace.py""" from test.support import requires requires('gui') @@ -6,8 +6,8 @@ import unittest from unittest.mock import Mock from tkinter import Tk, Text from idlelib.idle_test.mock_tk import Mbox -import idlelib.SearchEngine as se -import idlelib.ReplaceDialog as rd +import idlelib.searchengine as se +import idlelib.replace as rd orig_mbox = se.tkMessageBox showerror = Mbox.showerror diff --git a/Lib/idlelib/idle_test/test_rstrip.py b/Lib/idlelib/idle_test/test_rstrip.py index 1c90b93d21..130e6be257 100644 --- a/Lib/idlelib/idle_test/test_rstrip.py +++ b/Lib/idlelib/idle_test/test_rstrip.py @@ -1,5 +1,5 @@ import unittest -import idlelib.RstripExtension as rs +import idlelib.rstrip as rs from idlelib.idle_test.mock_idle import Editor class rstripTest(unittest.TestCase): @@ -21,7 +21,7 @@ class rstripTest(unittest.TestCase): def test_rstrip_multiple(self): editor = Editor() # Uncomment following to verify that test passes with real widgets. -## from idlelib.EditorWindow import EditorWindow as Editor +## from idlelib.editor import EditorWindow as Editor ## from tkinter import Tk ## editor = Editor(root=Tk()) text = editor.text diff --git a/Lib/idlelib/idle_test/test_scrolledlist.py b/Lib/idlelib/idle_test/test_scrolledlist.py new file mode 100644 index 0000000000..56aabfecf4 --- /dev/null +++ b/Lib/idlelib/idle_test/test_scrolledlist.py @@ -0,0 +1,29 @@ +''' Test idlelib.scrolledlist. + +Coverage: 39% +''' +from idlelib import scrolledlist +from test.support import requires +requires('gui') +import unittest +from tkinter import Tk + + +class ScrolledListTest(unittest.TestCase): + + @classmethod + def setUpClass(cls): + cls.root = Tk() + + @classmethod + def tearDownClass(cls): + cls.root.destroy() + del cls.root + + + def test_init(self): + scrolledlist.ScrolledList(self.root) + + +if __name__ == '__main__': + unittest.main(verbosity=2) diff --git a/Lib/idlelib/idle_test/test_searchdialog.py b/Lib/idlelib/idle_test/test_search.py index 190c866a18..0735d84356 100644 --- a/Lib/idlelib/idle_test/test_searchdialog.py +++ b/Lib/idlelib/idle_test/test_search.py @@ -1,4 +1,4 @@ -"""Test SearchDialog class in SearchDialogue.py""" +"""Test SearchDialog class in idlelib.search.py""" # Does not currently test the event handler wrappers. # A usage test should simulate clicks and check hilighting. @@ -11,8 +11,8 @@ requires('gui') import unittest import tkinter as tk from tkinter import BooleanVar -import idlelib.SearchEngine as se -import idlelib.SearchDialog as sd +import idlelib.searchengine as se +import idlelib.search as sd class SearchDialogTest(unittest.TestCase): diff --git a/Lib/idlelib/idle_test/test_searchdialogbase.py b/Lib/idlelib/idle_test/test_searchbase.py index 8036b918c5..5ff9476c87 100644 --- a/Lib/idlelib/idle_test/test_searchdialogbase.py +++ b/Lib/idlelib/idle_test/test_searchbase.py @@ -1,4 +1,4 @@ -'''Unittests for idlelib/SearchDialogBase.py +'''Unittests for idlelib/searchbase.py Coverage: 99%. The only thing not covered is inconsequential -- testing skipping of suite when self.needwrapbutton is false. @@ -7,8 +7,8 @@ testing skipping of suite when self.needwrapbutton is false. import unittest from test.support import requires from tkinter import Tk, Toplevel, Frame ##, BooleanVar, StringVar -from idlelib import SearchEngine as se -from idlelib import SearchDialogBase as sdb +from idlelib import searchengine as se +from idlelib import searchbase as sdb from idlelib.idle_test.mock_idle import Func ## from idlelib.idle_test.mock_tk import Var diff --git a/Lib/idlelib/idle_test/test_searchengine.py b/Lib/idlelib/idle_test/test_searchengine.py index edbd558133..7e6f8b71a8 100644 --- a/Lib/idlelib/idle_test/test_searchengine.py +++ b/Lib/idlelib/idle_test/test_searchengine.py @@ -1,4 +1,4 @@ -'''Test functions and SearchEngine class in SearchEngine.py.''' +'''Test functions and SearchEngine class in idlelib.searchengine.py.''' # With mock replacements, the module does not use any gui widgets. # The use of tk.Text is avoided (for now, until mock Text is improved) @@ -10,7 +10,7 @@ import unittest # from test.support import requires from tkinter import BooleanVar, StringVar, TclError # ,Tk, Text import tkinter.messagebox as tkMessageBox -from idlelib import SearchEngine as se +from idlelib import searchengine as se from idlelib.idle_test.mock_tk import Var, Mbox from idlelib.idle_test.mock_tk import Text as mockText diff --git a/Lib/idlelib/idle_test/test_textview.py b/Lib/idlelib/idle_test/test_textview.py index 02d1472240..764a1a5e1b 100644 --- a/Lib/idlelib/idle_test/test_textview.py +++ b/Lib/idlelib/idle_test/test_textview.py @@ -1,4 +1,4 @@ -'''Test idlelib.textView. +'''Test idlelib.textview. Since all methods and functions create (or destroy) a TextViewer, which is a widget containing multiple widgets, all tests must be gui tests. @@ -7,13 +7,13 @@ information about calls. The coverage is essentially 100%. ''' +from idlelib import textview as tv from test.support import requires requires('gui') import unittest import os from tkinter import Tk -from idlelib import textView as tv from idlelib.idle_test.mock_idle import Func from idlelib.idle_test.mock_tk import Mbox diff --git a/Lib/idlelib/idle_test/test_tree.py b/Lib/idlelib/idle_test/test_tree.py new file mode 100644 index 0000000000..09ba9641af --- /dev/null +++ b/Lib/idlelib/idle_test/test_tree.py @@ -0,0 +1,36 @@ +''' Test idlelib.tree. + +Coverage: 56% +''' +from idlelib import tree +from test.support import requires +requires('gui') +import os +import unittest +from tkinter import Tk + + +class TreeTest(unittest.TestCase): + + @classmethod + def setUpClass(cls): + cls.root = Tk() + cls.root.withdraw() + + @classmethod + def tearDownClass(cls): + cls.root.destroy() + del cls.root + + def test_init(self): + # Start with code slightly adapted from htest. + sc = tree.ScrolledCanvas( + self.root, bg="white", highlightthickness=0, takefocus=1) + sc.frame.pack(expand=1, fill="both", side='left') + item = tree.FileTreeItem(tree.ICONDIR) + node = tree.TreeNode(sc.canvas, None, item) + node.expand() + + +if __name__ == '__main__': + unittest.main(verbosity=2) diff --git a/Lib/idlelib/idle_test/test_undodelegator.py b/Lib/idlelib/idle_test/test_undo.py index 2b83c991e2..80f1b8071e 100644 --- a/Lib/idlelib/idle_test/test_undodelegator.py +++ b/Lib/idlelib/idle_test/test_undo.py @@ -1,4 +1,4 @@ -"""Unittest for UndoDelegator in idlelib.UndoDelegator. +"""Unittest for UndoDelegator in idlelib.undo.py. Coverage about 80% (retest). """ @@ -8,8 +8,8 @@ requires('gui') import unittest from unittest.mock import Mock from tkinter import Text, Tk -from idlelib.UndoDelegator import UndoDelegator -from idlelib.Percolator import Percolator +from idlelib.undo import UndoDelegator +from idlelib.percolator import Percolator class UndoDelegatorTest(unittest.TestCase): diff --git a/Lib/idlelib/idle_test/test_warning.py b/Lib/idlelib/idle_test/test_warning.py index 18627ddd23..f3269f195a 100644 --- a/Lib/idlelib/idle_test/test_warning.py +++ b/Lib/idlelib/idle_test/test_warning.py @@ -1,4 +1,4 @@ -'''Test warnings replacement in PyShell.py and run.py. +'''Test warnings replacement in pyshell.py and run.py. This file could be expanded to include traceback overrides (in same two modules). If so, change name. @@ -17,9 +17,9 @@ showwarning = warnings.showwarning running_in_idle = 'idle' in showwarning.__name__ from idlelib import run -from idlelib import PyShell as shell +from idlelib import pyshell as shell -# The following was generated from PyShell.idle_formatwarning +# The following was generated from pyshell.idle_formatwarning # and checked as matching expectation. idlemsg = ''' Warning (from warnings module): diff --git a/Lib/idlelib/idlever.py b/Lib/idlelib/idlever.py deleted file mode 100644 index 3e9f69a3e3..0000000000 --- a/Lib/idlelib/idlever.py +++ /dev/null @@ -1,12 +0,0 @@ -""" -The separate Idle version was eliminated years ago; -idlelib.idlever is no longer used by Idle -and will be removed in 3.6 or later. Use - from sys import version - IDLE_VERSION = version[:version.index(' ')] -""" -# Kept for now only for possible existing extension use -import warnings as w -w.warn(__doc__, DeprecationWarning, stacklevel=2) -from sys import version -IDLE_VERSION = version[:version.index(' ')] diff --git a/Lib/idlelib/IOBinding.py b/Lib/idlelib/iomenu.py index 84f39a2fee..f6a7f1489f 100644 --- a/Lib/idlelib/IOBinding.py +++ b/Lib/idlelib/iomenu.py @@ -10,7 +10,7 @@ import tkinter.filedialog as tkFileDialog import tkinter.messagebox as tkMessageBox from tkinter.simpledialog import askstring -from idlelib.configHandler import idleConf +from idlelib.config import idleConf # Try setting the locale, so that we can find out @@ -107,6 +107,9 @@ def coding_spec(data): class IOBinding: +# One instance per editor Window so methods know which to save, close. +# Open returns focus to self.editwin if aborted. +# EditorWindow.open_module, others, belong here. def __init__(self, editwin): self.editwin = editwin diff --git a/Lib/idlelib/macosxSupport.py b/Lib/idlelib/macosx.py index b96bae1d55..f9f558de18 100644 --- a/Lib/idlelib/macosxSupport.py +++ b/Lib/idlelib/macosx.py @@ -1,30 +1,24 @@ """ A number of functions that enhance IDLE on Mac OSX. """ -import sys +from sys import platform # Used in _init_tk_type, changed by test. import tkinter -from os import path import warnings -def runningAsOSXApp(): - warnings.warn("runningAsOSXApp() is deprecated, use isAquaTk()", - DeprecationWarning, stacklevel=2) - return isAquaTk() -def isCarbonAquaTk(root): - warnings.warn("isCarbonAquaTk(root) is deprecated, use isCarbonTk()", - DeprecationWarning, stacklevel=2) - return isCarbonTk() +## Define functions that query the Mac graphics type. +## _tk_type and its initializer are private to this section. _tk_type = None -def _initializeTkVariantTests(root): +def _init_tk_type(): """ Initializes OS X Tk variant values for isAquaTk(), isCarbonTk(), isCocoaTk(), and isXQuartz(). """ global _tk_type - if sys.platform == 'darwin': + if platform == 'darwin': + root = tkinter.Tk() ws = root.tk.call('tk', 'windowingsystem') if 'x11' in ws: _tk_type = "xquartz" @@ -34,6 +28,7 @@ def _initializeTkVariantTests(root): _tk_type = "cocoa" else: _tk_type = "carbon" + root.destroy() else: _tk_type = "other" @@ -41,7 +36,8 @@ def isAquaTk(): """ Returns True if IDLE is using a native OS X Tk (Cocoa or Carbon). """ - assert _tk_type is not None + if not _tk_type: + _init_tk_type() return _tk_type == "cocoa" or _tk_type == "carbon" def isCarbonTk(): @@ -49,23 +45,27 @@ def isCarbonTk(): Returns True if IDLE is using a Carbon Aqua Tk (instead of the newer Cocoa Aqua Tk). """ - assert _tk_type is not None + if not _tk_type: + _init_tk_type() return _tk_type == "carbon" def isCocoaTk(): """ Returns True if IDLE is using a Cocoa Aqua Tk. """ - assert _tk_type is not None + if not _tk_type: + _init_tk_type() return _tk_type == "cocoa" def isXQuartz(): """ Returns True if IDLE is using an OS X X11 Tk. """ - assert _tk_type is not None + if not _tk_type: + _init_tk_type() return _tk_type == "xquartz" + def tkVersionWarning(root): """ Returns a string warning message if the Tk version in use appears to @@ -86,6 +86,9 @@ def tkVersionWarning(root): else: return False + +## Fix the menu and related functions. + def addOpenEventSupport(root, flist): """ This ensures that the application will respond to open AppleEvents, which @@ -124,23 +127,23 @@ def overrideRootMenu(root, flist): # Due to a (mis-)feature of TkAqua the user will also see an empty Help # menu. from tkinter import Menu - from idlelib import Bindings - from idlelib import WindowList + from idlelib import mainmenu + from idlelib import windows - closeItem = Bindings.menudefs[0][1][-2] + closeItem = mainmenu.menudefs[0][1][-2] # Remove the last 3 items of the file menu: a separator, close window and # quit. Close window will be reinserted just above the save item, where # it should be according to the HIG. Quit is in the application menu. - del Bindings.menudefs[0][1][-3:] - Bindings.menudefs[0][1].insert(6, closeItem) + del mainmenu.menudefs[0][1][-3:] + mainmenu.menudefs[0][1].insert(6, closeItem) # Remove the 'About' entry from the help menu, it is in the application # menu - del Bindings.menudefs[-1][1][0:2] + del mainmenu.menudefs[-1][1][0:2] # Remove the 'Configure Idle' entry from the options menu, it is in the # application menu as 'Preferences' - del Bindings.menudefs[-2][1][0] + del mainmenu.menudefs[-2][1][0] menubar = Menu(root) root.configure(menu=menubar) menudict = {} @@ -155,30 +158,30 @@ def overrideRootMenu(root, flist): if end > 0: menu.delete(0, end) - WindowList.add_windows_to_menu(menu) - WindowList.register_callback(postwindowsmenu) + windows.add_windows_to_menu(menu) + windows.register_callback(postwindowsmenu) def about_dialog(event=None): "Handle Help 'About IDLE' event." - # Synchronize with EditorWindow.EditorWindow.about_dialog. - from idlelib import aboutDialog - aboutDialog.AboutDialog(root, 'About IDLE') + # Synchronize with editor.EditorWindow.about_dialog. + from idlelib import help_about + help_about.AboutDialog(root, 'About IDLE') def config_dialog(event=None): "Handle Options 'Configure IDLE' event." - # Synchronize with EditorWindow.EditorWindow.config_dialog. - from idlelib import configDialog + # Synchronize with editor.EditorWindow.config_dialog. + from idlelib import configdialog # Ensure that the root object has an instance_dict attribute, # mirrors code in EditorWindow (although that sets the attribute # on an EditorWindow instance that is then passed as the first # argument to ConfigDialog) root.instance_dict = flist.inversedict - configDialog.ConfigDialog(root, 'Settings') + configdialog.ConfigDialog(root, 'Settings') def help_dialog(event=None): "Handle Help 'IDLE Help' event." - # Synchronize with EditorWindow.EditorWindow.help_dialog. + # Synchronize with editor.EditorWindow.help_dialog. from idlelib import help help.show_idlehelp(root) @@ -198,29 +201,33 @@ def overrideRootMenu(root, flist): menudict['application'] = menu = Menu(menubar, name='apple', tearoff=0) menubar.add_cascade(label='IDLE', menu=menu) - Bindings.menudefs.insert(0, + mainmenu.menudefs.insert(0, ('application', [ ('About IDLE', '<<about-idle>>'), None, ])) - tkversion = root.tk.eval('info patchlevel') - if tuple(map(int, tkversion.split('.'))) < (8, 4, 14): - # for earlier AquaTk versions, supply a Preferences menu item - Bindings.menudefs[0][1].append( - ('_Preferences....', '<<open-config-dialog>>'), - ) if isCocoaTk(): # replace default About dialog with About IDLE one root.createcommand('tkAboutDialog', about_dialog) # replace default "Help" item in Help menu root.createcommand('::tk::mac::ShowHelp', help_dialog) # remove redundant "IDLE Help" from menu - del Bindings.menudefs[-1][1][0] + del mainmenu.menudefs[-1][1][0] + +def fixb2context(root): + '''Removed bad AquaTk Button-2 (right) and Paste bindings. + + They prevent context menu access and seem to be gone in AquaTk8.6. + See issue #24801. + ''' + root.unbind_class('Text', '<B2>') + root.unbind_class('Text', '<B2-Motion>') + root.unbind_class('Text', '<<PasteSelection>>') def setupApp(root, flist): """ Perform initial OS X customizations if needed. - Called from PyShell.main() after initial calls to Tk() + Called from pyshell.main() after initial calls to Tk() There are currently three major versions of Tk in use on OS X: 1. Aqua Cocoa Tk (native default since OS X 10.6) @@ -233,8 +240,13 @@ def setupApp(root, flist): isAquaTk(), isCarbonTk(), isCocoaTk(), isXQuartz() functions which are initialized here as well. """ - _initializeTkVariantTests(root) if isAquaTk(): hideTkConsole(root) overrideRootMenu(root, flist) addOpenEventSupport(root, flist) + fixb2context(root) + + +if __name__ == '__main__': + from unittest import main + main('idlelib.idle_test.test_macosx', verbosity=2) diff --git a/Lib/idlelib/Bindings.py b/Lib/idlelib/mainmenu.py index ab25ff18b6..965ada3081 100644 --- a/Lib/idlelib/Bindings.py +++ b/Lib/idlelib/mainmenu.py @@ -10,9 +10,9 @@ windows. """ from importlib.util import find_spec -from idlelib.configHandler import idleConf +from idlelib.config import idleConf -# Warning: menudefs is altered in macosxSupport.overrideRootMenu() +# Warning: menudefs is altered in macosx.overrideRootMenu() # after it is determined that an OS X Aqua Tk is in use, # which cannot be done until after Tk() is first called. # Do not alter the 'file', 'options', or 'help' cascades here diff --git a/Lib/idlelib/MultiCall.py b/Lib/idlelib/multicall.py index 8462854921..8462854921 100644 --- a/Lib/idlelib/MultiCall.py +++ b/Lib/idlelib/multicall.py diff --git a/Lib/idlelib/OutputWindow.py b/Lib/idlelib/outwin.py index e614f9b2bb..b3bc786151 100644 --- a/Lib/idlelib/OutputWindow.py +++ b/Lib/idlelib/outwin.py @@ -1,8 +1,8 @@ from tkinter import * -from idlelib.EditorWindow import EditorWindow +from idlelib.editor import EditorWindow import re import tkinter.messagebox as tkMessageBox -from idlelib import IOBinding +from idlelib import iomenu class OutputWindow(EditorWindow): @@ -36,7 +36,7 @@ class OutputWindow(EditorWindow): def write(self, s, tags=(), mark="insert"): if isinstance(s, (bytes, bytes)): - s = s.decode(IOBinding.encoding, "replace") + s = s.decode(iomenu.encoding, "replace") self.text.insert(mark, s, tags) self.text.see(mark) self.text.update() diff --git a/Lib/idlelib/FormatParagraph.py b/Lib/idlelib/paragraph.py index 7a9d185042..0323b53d86 100644 --- a/Lib/idlelib/FormatParagraph.py +++ b/Lib/idlelib/paragraph.py @@ -16,7 +16,7 @@ Known problems with comment reformatting: """ import re -from idlelib.configHandler import idleConf +from idlelib.config import idleConf class FormatParagraph: @@ -191,5 +191,5 @@ def get_comment_header(line): if __name__ == "__main__": import unittest - unittest.main('idlelib.idle_test.test_formatparagraph', + unittest.main('idlelib.idle_test.test_paragraph', verbosity=2, exit=False) diff --git a/Lib/idlelib/ParenMatch.py b/Lib/idlelib/parenmatch.py index 19bad8ce38..e98fac1952 100644 --- a/Lib/idlelib/ParenMatch.py +++ b/Lib/idlelib/parenmatch.py @@ -5,8 +5,8 @@ paren. Paren here is used generically; the matching applies to parentheses, square brackets, and curly braces. """ -from idlelib.HyperParser import HyperParser -from idlelib.configHandler import idleConf +from idlelib.hyperparser import HyperParser +from idlelib.config import idleConf _openers = {')':'(',']':'[','}':'{'} CHECK_DELAY = 100 # miliseconds diff --git a/Lib/idlelib/PathBrowser.py b/Lib/idlelib/pathbrowser.py index 9ab7632f4d..966af4b259 100644 --- a/Lib/idlelib/PathBrowser.py +++ b/Lib/idlelib/pathbrowser.py @@ -2,9 +2,9 @@ import os import sys import importlib.machinery -from idlelib.TreeWidget import TreeItem -from idlelib.ClassBrowser import ClassBrowser, ModuleBrowserTreeItem -from idlelib.PyShell import PyShellFileList +from idlelib.tree import TreeItem +from idlelib.browser import ClassBrowser, ModuleBrowserTreeItem +from idlelib.pyshell import PyShellFileList class PathBrowser(ClassBrowser): diff --git a/Lib/idlelib/Percolator.py b/Lib/idlelib/percolator.py index b8be2aa746..227144581b 100644 --- a/Lib/idlelib/Percolator.py +++ b/Lib/idlelib/percolator.py @@ -1,5 +1,5 @@ -from idlelib.WidgetRedirector import WidgetRedirector -from idlelib.Delegator import Delegator +from idlelib.redirector import WidgetRedirector +from idlelib.delegator import Delegator class Percolator: diff --git a/Lib/idlelib/PyParse.py b/Lib/idlelib/pyparse.py index 9ccbb25076..9ccbb25076 100644 --- a/Lib/idlelib/PyParse.py +++ b/Lib/idlelib/pyparse.py diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/pyshell.py index 5dec68e580..0f7a01d77b 100755 --- a/Lib/idlelib/PyShell.py +++ b/Lib/idlelib/pyshell.py @@ -1,5 +1,20 @@ #! /usr/bin/env python3 +try: + from tkinter import * +except ImportError: + print("** IDLE can't import Tkinter.\n" + "Your Python may not be configured for Tk. **", file=sys.__stderr__) + sys.exit(1) +import tkinter.messagebox as tkMessageBox +if TkVersion < 8.5: + root = Tk() # otherwise create root in main + root.withdraw() + tkMessageBox.showerror("Idle Cannot Start", + "Idle requires tcl/tk 8.5+, not $s." % TkVersion, + parent=root) + sys.exit(1) + import getopt import os import os.path @@ -16,24 +31,16 @@ import linecache from code import InteractiveInterpreter from platform import python_version, system -try: - from tkinter import * -except ImportError: - print("** IDLE can't import Tkinter.\n" - "Your Python may not be configured for Tk. **", file=sys.__stderr__) - sys.exit(1) -import tkinter.messagebox as tkMessageBox - -from idlelib.EditorWindow import EditorWindow, fixwordbreaks -from idlelib.FileList import FileList -from idlelib.ColorDelegator import ColorDelegator -from idlelib.UndoDelegator import UndoDelegator -from idlelib.OutputWindow import OutputWindow -from idlelib.configHandler import idleConf +from idlelib.editor import EditorWindow, fixwordbreaks +from idlelib.filelist import FileList +from idlelib.colorizer import ColorDelegator +from idlelib.undo import UndoDelegator +from idlelib.outwin import OutputWindow +from idlelib.config import idleConf from idlelib import rpc -from idlelib import Debugger -from idlelib import RemoteDebugger -from idlelib import macosxSupport +from idlelib import debugger +from idlelib import debugger_r +from idlelib import macosx HOST = '127.0.0.1' # python execution server on localhost loopback PORT = 0 # someday pass in host, port for remote debug capability @@ -410,7 +417,7 @@ class ModifiedInterpreter(InteractiveInterpreter): # run from the IDLE source directory. del_exitf = idleConf.GetOption('main', 'General', 'delete-exitfunc', default=False, type='bool') - if __name__ == 'idlelib.PyShell': + if __name__ == 'idlelib.pyshell': command = "__import__('idlelib.run').run.main(%r)" % (del_exitf,) else: command = "__import__('run').main(%r)" % (del_exitf,) @@ -468,7 +475,7 @@ class ModifiedInterpreter(InteractiveInterpreter): if debug: try: # Only close subprocess debugger, don't unregister gui_adap! - RemoteDebugger.close_subprocess_debugger(self.rpcclt) + debugger_r.close_subprocess_debugger(self.rpcclt) except: pass # Kill subprocess, spawn a new one, accept connection. @@ -497,7 +504,7 @@ class ModifiedInterpreter(InteractiveInterpreter): # restart subprocess debugger if debug: # Restarted debugger connects to current instance of debug GUI - RemoteDebugger.restart_subprocess_debugger(self.rpcclt) + debugger_r.restart_subprocess_debugger(self.rpcclt) # reload remote debugger breakpoints for all PyShellEditWindows debug.load_breakpoints() self.compile.compiler.flags = self.original_compiler_flags @@ -578,7 +585,7 @@ class ModifiedInterpreter(InteractiveInterpreter): if self.tkconsole.getvar("<<toggle-jit-stack-viewer>>"): self.remote_stack_viewer() elif how == "ERROR": - errmsg = "PyShell.ModifiedInterpreter: Subprocess ERROR:\n" + errmsg = "pyshell.ModifiedInterpreter: Subprocess ERROR:\n" print(errmsg, what, file=sys.__stderr__) print(errmsg, what, file=console) # we received a response to the currently active seq number: @@ -613,13 +620,13 @@ class ModifiedInterpreter(InteractiveInterpreter): return def remote_stack_viewer(self): - from idlelib import RemoteObjectBrowser + from idlelib import debugobj_r oid = self.rpcclt.remotequeue("exec", "stackviewer", ("flist",), {}) if oid is None: self.tkconsole.root.bell() return - item = RemoteObjectBrowser.StubObjectTreeItem(self.rpcclt, oid) - from idlelib.TreeWidget import ScrolledCanvas, TreeNode + item = debugobj_r.StubObjectTreeItem(self.rpcclt, oid) + from idlelib.tree import ScrolledCanvas, TreeNode top = Toplevel(self.tkconsole.root) theme = idleConf.CurrentTheme() background = idleConf.GetHighlight(theme, 'normal')['background'] @@ -662,9 +669,9 @@ class ModifiedInterpreter(InteractiveInterpreter): # at the moment, InteractiveInterpreter expects str assert isinstance(source, str) #if isinstance(source, str): - # from idlelib import IOBinding + # from idlelib import iomenu # try: - # source = source.encode(IOBinding.encoding) + # source = source.encode(iomenu.encoding) # except UnicodeError: # self.tkconsole.resetoutput() # self.write("Unsupported characters in input\n") @@ -850,7 +857,7 @@ class PyShell(OutputWindow): # New classes - from idlelib.IdleHistory import History + from idlelib.history import History def __init__(self, flist=None): if use_subprocess: @@ -888,11 +895,11 @@ class PyShell(OutputWindow): self.save_stdout = sys.stdout self.save_stderr = sys.stderr self.save_stdin = sys.stdin - from idlelib import IOBinding - self.stdin = PseudoInputFile(self, "stdin", IOBinding.encoding) - self.stdout = PseudoOutputFile(self, "stdout", IOBinding.encoding) - self.stderr = PseudoOutputFile(self, "stderr", IOBinding.encoding) - self.console = PseudoOutputFile(self, "console", IOBinding.encoding) + from idlelib import iomenu + self.stdin = PseudoInputFile(self, "stdin", iomenu.encoding) + self.stdout = PseudoOutputFile(self, "stdout", iomenu.encoding) + self.stderr = PseudoOutputFile(self, "stderr", iomenu.encoding) + self.console = PseudoOutputFile(self, "console", iomenu.encoding) if not use_subprocess: sys.stdout = self.stdout sys.stderr = self.stderr @@ -900,7 +907,7 @@ class PyShell(OutputWindow): try: # page help() text to shell. import pydoc # import must be done here to capture i/o rebinding. - # XXX KBK 27Dec07 use a textView someday, but must work w/o subproc + # XXX KBK 27Dec07 use TextViewer someday, but must work w/o subproc pydoc.pager = pydoc.plainpager except: sys.stderr = sys.__stderr__ @@ -954,7 +961,7 @@ class PyShell(OutputWindow): self.interp.setdebugger(None) db.close() if self.interp.rpcclt: - RemoteDebugger.close_remote_debugger(self.interp.rpcclt) + debugger_r.close_remote_debugger(self.interp.rpcclt) self.resetoutput() self.console.write("[DEBUG OFF]\n") sys.ps1 = ">>> " @@ -963,10 +970,10 @@ class PyShell(OutputWindow): def open_debugger(self): if self.interp.rpcclt: - dbg_gui = RemoteDebugger.start_remote_debugger(self.interp.rpcclt, + dbg_gui = debugger_r.start_remote_debugger(self.interp.rpcclt, self) else: - dbg_gui = Debugger.Debugger(self) + dbg_gui = debugger.Debugger(self) self.interp.setdebugger(dbg_gui) dbg_gui.load_breakpoints() sys.ps1 = "[DEBUG ON]\n>>> " @@ -1241,7 +1248,7 @@ class PyShell(OutputWindow): "(sys.last_traceback is not defined)", parent=self.text) return - from idlelib.StackViewer import StackBrowser + from idlelib.stackviewer import StackBrowser StackBrowser(self.root, self.flist) def view_restart_mark(self, event=None): @@ -1549,7 +1556,7 @@ def main(): if system() == 'Windows': iconfile = os.path.join(icondir, 'idle.ico') root.wm_iconbitmap(default=iconfile) - elif TkVersion >= 8.5: + else: ext = '.png' if TkVersion >= 8.6 else '.gif' iconfiles = [os.path.join(icondir, 'idle_%d%s' % (size, ext)) for size in (16, 32, 48)] @@ -1559,15 +1566,7 @@ def main(): fixwordbreaks(root) fix_x11_paste(root) flist = PyShellFileList(root) - macosxSupport.setupApp(root, flist) - - if macosxSupport.isAquaTk(): - # There are some screwed up <2> class bindings for text - # widgets defined in Tk which we need to do away with. - # See issue #24801. - root.unbind_class('Text', '<B2>') - root.unbind_class('Text', '<B2-Motion>') - root.unbind_class('Text', '<<PasteSelection>>') + macosx.setupApp(root, flist) if enable_edit: if not (cmd or script): @@ -1582,7 +1581,7 @@ def main(): shell = flist.open_shell() if not shell: return # couldn't open shell - if macosxSupport.isAquaTk() and flist.dict: + if macosx.isAquaTk() and flist.dict: # On OSX: when the user has double-clicked on a file that causes # IDLE to be launched the shell window will open just in front of # the file she wants to see. Lower the interpreter window when @@ -1616,7 +1615,7 @@ def main(): # check for problematic OS X Tk versions and print a warning # message in the IDLE shell window; this is less intrusive # than always opening a separate window. - tkversionwarning = macosxSupport.tkVersionWarning(root) + tkversionwarning = macosx.tkVersionWarning(root) if tkversionwarning: shell.interp.runcommand("print('%s')" % tkversionwarning) @@ -1626,7 +1625,7 @@ def main(): capture_warnings(False) if __name__ == "__main__": - sys.modules['PyShell'] = sys.modules['__main__'] + sys.modules['pyshell'] = sys.modules['__main__'] main() capture_warnings(False) # Make sure turned off; see issue 18081 diff --git a/Lib/idlelib/WidgetRedirector.py b/Lib/idlelib/redirector.py index b66be9e721..5ca7a2d5ff 100644 --- a/Lib/idlelib/WidgetRedirector.py +++ b/Lib/idlelib/redirector.py @@ -104,7 +104,7 @@ class WidgetRedirector: Note that if a registered function is called, the operation is not passed through to Tk. Apply the function returned by self.register() - to *args to accomplish that. For an example, see ColorDelegator.py. + to *args to accomplish that. For an example, see colorizer.py. ''' m = self._operations.get(operation) diff --git a/Lib/idlelib/ReplaceDialog.py b/Lib/idlelib/replace.py index f2ea22e7f7..589b814192 100644 --- a/Lib/idlelib/ReplaceDialog.py +++ b/Lib/idlelib/replace.py @@ -5,8 +5,8 @@ replace+find. """ from tkinter import * -from idlelib import SearchEngine -from idlelib.SearchDialogBase import SearchDialogBase +from idlelib import searchengine +from idlelib.searchbase import SearchDialogBase import re @@ -14,7 +14,7 @@ def replace(text): """Returns a singleton ReplaceDialog instance.The single dialog saves user entries and preferences across instances.""" root = text._root() - engine = SearchEngine.get(root) + engine = searchengine.get(root) if not hasattr(engine, "_replacedialog"): engine._replacedialog = ReplaceDialog(root, engine) dialog = engine._replacedialog @@ -164,7 +164,7 @@ class ReplaceDialog(SearchDialogBase): pos = None if not pos: first = last = pos = text.index("insert") - line, col = SearchEngine.get_line_col(pos) + line, col = searchengine.get_line_col(pos) chars = text.get("%d.0" % line, "%d.0" % (line+1)) m = prog.match(chars, col) if not prog: diff --git a/Lib/idlelib/RstripExtension.py b/Lib/idlelib/rstrip.py index 2ce3c7eafe..2ce3c7eafe 100644 --- a/Lib/idlelib/RstripExtension.py +++ b/Lib/idlelib/rstrip.py diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py index 595e7bc3aa..eb34944eb3 100644 --- a/Lib/idlelib/run.py +++ b/Lib/idlelib/run.py @@ -7,15 +7,15 @@ import threading import queue import tkinter -from idlelib import CallTips -from idlelib import AutoComplete +from idlelib import calltips +from idlelib import autocomplete -from idlelib import RemoteDebugger -from idlelib import RemoteObjectBrowser -from idlelib import StackViewer +from idlelib import debugger_r +from idlelib import debugobj_r +from idlelib import stackviewer from idlelib import rpc -from idlelib import PyShell -from idlelib import IOBinding +from idlelib import pyshell +from idlelib import iomenu import __main__ @@ -32,7 +32,7 @@ def idle_showwarning_subproc( if file is None: file = sys.stderr try: - file.write(PyShell.idle_formatwarning( + file.write(pyshell.idle_formatwarning( message, category, filename, lineno, line)) except IOError: pass # the file (probably stderr) is invalid - this warning gets lost. @@ -82,7 +82,7 @@ def main(del_exitfunc=False): MyHandler object. That reference is saved as attribute rpchandler of the Executive instance. The Executive methods have access to the reference and can pass it on to entities that they command - (e.g. RemoteDebugger.Debugger.start_debugger()). The latter, in turn, can + (e.g. debugger_r.Debugger.start_debugger()). The latter, in turn, can call MyHandler(SocketIO) register/unregister methods via the reference to register and unregister themselves. @@ -204,7 +204,7 @@ def print_exception(): tbe = traceback.extract_tb(tb) print('Traceback (most recent call last):', file=efile) exclude = ("run.py", "rpc.py", "threading.py", "queue.py", - "RemoteDebugger.py", "bdb.py") + "debugger_r.py", "bdb.py") cleanup_traceback(tbe, exclude) traceback.print_list(tbe, file=efile) lines = traceback.format_exception_only(typ, exc) @@ -298,12 +298,12 @@ class MyHandler(rpc.RPCHandler): executive = Executive(self) self.register("exec", executive) self.console = self.get_remote_proxy("console") - sys.stdin = PyShell.PseudoInputFile(self.console, "stdin", - IOBinding.encoding) - sys.stdout = PyShell.PseudoOutputFile(self.console, "stdout", - IOBinding.encoding) - sys.stderr = PyShell.PseudoOutputFile(self.console, "stderr", - IOBinding.encoding) + sys.stdin = pyshell.PseudoInputFile(self.console, "stdin", + iomenu.encoding) + sys.stdout = pyshell.PseudoOutputFile(self.console, "stdout", + iomenu.encoding) + sys.stderr = pyshell.PseudoOutputFile(self.console, "stderr", + iomenu.encoding) sys.displayhook = rpc.displayhook # page help() text to shell. @@ -339,8 +339,8 @@ class Executive(object): def __init__(self, rpchandler): self.rpchandler = rpchandler self.locals = __main__.__dict__ - self.calltip = CallTips.CallTips() - self.autocomplete = AutoComplete.AutoComplete() + self.calltip = calltips.CallTips() + self.autocomplete = autocomplete.AutoComplete() def runcode(self, code): global interruptable @@ -372,7 +372,7 @@ class Executive(object): thread.interrupt_main() def start_the_debugger(self, gui_adap_oid): - return RemoteDebugger.start_debugger(self.rpchandler, gui_adap_oid) + return debugger_r.start_debugger(self.rpchandler, gui_adap_oid) def stop_the_debugger(self, idb_adap_oid): "Unregister the Idb Adapter. Link objects and Idb then subject to GC" @@ -396,7 +396,7 @@ class Executive(object): tb = tb.tb_next sys.last_type = typ sys.last_value = val - item = StackViewer.StackTreeItem(flist, tb) - return RemoteObjectBrowser.remote_object_tree_item(item) + item = stackviewer.StackTreeItem(flist, tb) + return debugobj_r.remote_object_tree_item(item) capture_warnings(False) # Make sure turned off; see issue 18081 diff --git a/Lib/idlelib/ScriptBinding.py b/Lib/idlelib/runscript.py index 5cb818d833..7e7524a3c4 100644 --- a/Lib/idlelib/ScriptBinding.py +++ b/Lib/idlelib/runscript.py @@ -21,10 +21,10 @@ import os import tabnanny import tokenize import tkinter.messagebox as tkMessageBox -from idlelib import PyShell +from idlelib import pyshell -from idlelib.configHandler import idleConf -from idlelib import macosxSupport +from idlelib.config import idleConf +from idlelib import macosx indent_message = """Error: Inconsistent indentation detected! @@ -46,12 +46,12 @@ class ScriptBinding: def __init__(self, editwin): self.editwin = editwin - # Provide instance variables referenced by Debugger + # Provide instance variables referenced by debugger # XXX This should be done differently self.flist = self.editwin.flist self.root = self.editwin.root - if macosxSupport.isCocoaTk(): + if macosx.isCocoaTk(): self.editwin.text_frame.bind('<<run-module-event-2>>', self._run_module_event) def check_module_event(self, event): @@ -112,7 +112,7 @@ class ScriptBinding: shell.set_warning_stream(saved_stream) def run_module_event(self, event): - if macosxSupport.isCocoaTk(): + if macosx.isCocoaTk(): # Tk-Cocoa in MacOSX is broken until at least # Tk 8.5.9, and without this rather # crude workaround IDLE would hang when a user @@ -142,7 +142,7 @@ class ScriptBinding: if not self.tabnanny(filename): return 'break' interp = self.shell.interp - if PyShell.use_subprocess: + if pyshell.use_subprocess: interp.restart_subprocess(with_cwd=False, filename= self.editwin._filename_to_unicode(filename)) dirname = os.path.dirname(filename) @@ -161,7 +161,7 @@ class ScriptBinding: interp.prepend_syspath(filename) # XXX KBK 03Jul04 When run w/o subprocess, runtime warnings still # go to __stderr__. With subprocess, they go to the shell. - # Need to change streams in PyShell.ModifiedInterpreter. + # Need to change streams in pyshell.ModifiedInterpreter. interp.runcode(code) return 'break' diff --git a/Lib/idlelib/ScrolledList.py b/Lib/idlelib/scrolledlist.py index 53576b5f82..d0b66107ac 100644 --- a/Lib/idlelib/ScrolledList.py +++ b/Lib/idlelib/scrolledlist.py @@ -1,5 +1,6 @@ from tkinter import * -from idlelib import macosxSupport +from idlelib import macosx +from tkinter.ttk import Scrollbar class ScrolledList: @@ -23,7 +24,7 @@ class ScrolledList: # Bind events to the list box listbox.bind("<ButtonRelease-1>", self.click_event) listbox.bind("<Double-ButtonRelease-1>", self.double_click_event) - if macosxSupport.isAquaTk(): + if macosx.isAquaTk(): listbox.bind("<ButtonPress-2>", self.popup_event) listbox.bind("<Control-Button-1>", self.popup_event) else: @@ -124,22 +125,20 @@ class ScrolledList: pass -def _scrolled_list(parent): - root = Tk() - root.title("Test ScrolledList") +def _scrolled_list(parent): # htest # + top = Toplevel(parent) width, height, x, y = list(map(int, re.split('[x+]', parent.geometry()))) - root.geometry("+%d+%d"%(x, y + 150)) + top.geometry("+%d+%d"%(x+200, y + 175)) class MyScrolledList(ScrolledList): def fill_menu(self): self.menu.add_command(label="right click") def on_select(self, index): print("select", self.get(index)) def on_double(self, index): print("double", self.get(index)) - scrolled_list = MyScrolledList(root) + scrolled_list = MyScrolledList(top) for i in range(30): scrolled_list.append("Item %02d" % i) - root.mainloop() - if __name__ == '__main__': + # At the moment, test_scrolledlist merely creates instance, like htest. from idlelib.idle_test.htest import run run(_scrolled_list) diff --git a/Lib/idlelib/SearchDialog.py b/Lib/idlelib/search.py index 765d53fe92..a609fd9583 100644 --- a/Lib/idlelib/SearchDialog.py +++ b/Lib/idlelib/search.py @@ -1,12 +1,12 @@ from tkinter import * -from idlelib import SearchEngine -from idlelib.SearchDialogBase import SearchDialogBase +from idlelib import searchengine +from idlelib.searchbase import SearchDialogBase def _setup(text): "Create or find the singleton SearchDialog instance." root = text._root() - engine = SearchEngine.get(root) + engine = searchengine.get(root) if not hasattr(engine, "_searchdialog"): engine._searchdialog = SearchDialog(root, engine) return engine._searchdialog diff --git a/Lib/idlelib/SearchDialogBase.py b/Lib/idlelib/searchbase.py index 5fa84e238b..9206bf5051 100644 --- a/Lib/idlelib/SearchDialogBase.py +++ b/Lib/idlelib/searchbase.py @@ -125,7 +125,7 @@ class SearchDialogBase: def create_option_buttons(self): '''Return (filled frame, options) for testing. - Options is a list of SearchEngine booleanvar, label pairs. + Options is a list of searchengine booleanvar, label pairs. A gridded frame from make_frame is filled with a Checkbutton for each pair, bound to the var, with the corresponding label. ''' diff --git a/Lib/idlelib/SearchEngine.py b/Lib/idlelib/searchengine.py index 37883bf687..2e3700ece3 100644 --- a/Lib/idlelib/SearchEngine.py +++ b/Lib/idlelib/searchengine.py @@ -57,7 +57,7 @@ class SearchEngine: def setcookedpat(self, pat): "Set pattern after escaping if re." - # called only in SearchDialog.py: 66 + # called only in search.py: 66 if self.isre(): pat = re.escape(pat) self.setpat(pat) diff --git a/Lib/idlelib/StackViewer.py b/Lib/idlelib/stackviewer.py index ccc755ce31..87c964e7af 100644 --- a/Lib/idlelib/StackViewer.py +++ b/Lib/idlelib/stackviewer.py @@ -4,9 +4,9 @@ import linecache import re import tkinter as tk -from idlelib.TreeWidget import TreeNode, TreeItem, ScrolledCanvas -from idlelib.ObjectBrowser import ObjectTreeItem, make_objecttreeitem -from idlelib.PyShell import PyShellFileList +from idlelib.tree import TreeNode, TreeItem, ScrolledCanvas +from idlelib.debugobj import ObjectTreeItem, make_objecttreeitem +from idlelib.pyshell import PyShellFileList def StackBrowser(root, flist=None, tb=None, top=None): if top is None: @@ -120,9 +120,6 @@ class VariablesTreeItem(ObjectTreeItem): sublist.append(item) return sublist - def keys(self): # unused, left for possible 3rd party use - return list(self.object.keys()) - def _stack_viewer(parent): root = tk.Tk() root.title("Test StackViewer") diff --git a/Lib/idlelib/MultiStatusBar.py b/Lib/idlelib/statusbar.py index e82ba9ab2f..e82ba9ab2f 100644 --- a/Lib/idlelib/MultiStatusBar.py +++ b/Lib/idlelib/statusbar.py diff --git a/Lib/idlelib/textView.py b/Lib/idlelib/textview.py index 01b2d8f4ab..9dc83574ee 100644 --- a/Lib/idlelib/textView.py +++ b/Lib/idlelib/textview.py @@ -3,6 +3,7 @@ """ from tkinter import * +from tkinter.ttk import Scrollbar import tkinter.messagebox as tkMessageBox class TextViewer(Toplevel): @@ -50,7 +51,7 @@ class TextViewer(Toplevel): self.buttonOk = Button(frameButtons, text='Close', command=self.Ok, takefocus=FALSE) self.scrollbarView = Scrollbar(frameText, orient=VERTICAL, - takefocus=FALSE, highlightthickness=0) + takefocus=FALSE) self.textView = Text(frameText, wrap=WORD, highlightthickness=0, fg=self.fg, bg=self.bg) self.scrollbarView.config(command=self.textView.yview) diff --git a/Lib/idlelib/ToolTip.py b/Lib/idlelib/tooltip.py index 964107e117..c3eafed9d5 100644 --- a/Lib/idlelib/ToolTip.py +++ b/Lib/idlelib/tooltip.py @@ -1,4 +1,4 @@ -# general purpose 'tooltip' routines - currently unused in idlefork +# general purpose 'tooltip' routines - currently unused in idlelib # (although the 'calltips' extension is partly based on this code) # may be useful for some purposes in (or almost in ;) the current project scope # Ideas gleaned from PySol @@ -76,7 +76,7 @@ class ListboxToolTip(ToolTipBase): for item in self.items: listbox.insert(END, item) -def _tooltip(parent): +def _tooltip(parent): # htest # root = Tk() root.title("Test tooltip") width, height, x, y = list(map(int, re.split('[x+]', parent.geometry()))) diff --git a/Lib/idlelib/TreeWidget.py b/Lib/idlelib/tree.py index a19578fdcb..cb7f9ae4b4 100644 --- a/Lib/idlelib/TreeWidget.py +++ b/Lib/idlelib/tree.py @@ -16,9 +16,9 @@ import os from tkinter import * - -from idlelib import ZoomHeight -from idlelib.configHandler import idleConf +from tkinter.ttk import Scrollbar +from idlelib import zoomheight +from idlelib.config import idleConf ICONDIR = "Icons" @@ -445,22 +445,21 @@ class ScrolledCanvas: self.canvas.yview_scroll(1, "unit") return "break" def zoom_height(self, event): - ZoomHeight.zoom_height(self.master) + zoomheight.zoom_height(self.master) return "break" -def _tree_widget(parent): - root = Tk() - root.title("Test TreeWidget") +def _tree_widget(parent): # htest # + top = Toplevel(parent) width, height, x, y = list(map(int, re.split('[x+]', parent.geometry()))) - root.geometry("+%d+%d"%(x, y + 150)) - sc = ScrolledCanvas(root, bg="white", highlightthickness=0, takefocus=1) + top.geometry("+%d+%d"%(x+50, y+175)) + sc = ScrolledCanvas(top, bg="white", highlightthickness=0, takefocus=1) sc.frame.pack(expand=1, fill="both", side=LEFT) - item = FileTreeItem(os.getcwd()) + item = FileTreeItem(ICONDIR) node = TreeNode(sc.canvas, None, item) node.expand() - root.mainloop() if __name__ == '__main__': + # test_tree is currently a copy of this from idlelib.idle_test.htest import run run(_tree_widget) diff --git a/Lib/idlelib/UndoDelegator.py b/Lib/idlelib/undo.py index 1c2502d818..3e94b69bbe 100644 --- a/Lib/idlelib/UndoDelegator.py +++ b/Lib/idlelib/undo.py @@ -1,7 +1,7 @@ import string from tkinter import * -from idlelib.Delegator import Delegator +from idlelib.delegator import Delegator #$ event <<redo>> #$ win <Control-y> @@ -340,7 +340,7 @@ class CommandSequence(Command): def _undo_delegator(parent): # htest # import re import tkinter as tk - from idlelib.Percolator import Percolator + from idlelib.percolator import Percolator undowin = tk.Toplevel() undowin.title("Test UndoDelegator") width, height, x, y = list(map(int, re.split('[x+]', parent.geometry()))) diff --git a/Lib/idlelib/WindowList.py b/Lib/idlelib/windows.py index bc74348f56..bc74348f56 100644 --- a/Lib/idlelib/WindowList.py +++ b/Lib/idlelib/windows.py diff --git a/Lib/idlelib/ZoomHeight.py b/Lib/idlelib/zoomheight.py index a5d679e499..0016e9de5f 100644 --- a/Lib/idlelib/ZoomHeight.py +++ b/Lib/idlelib/zoomheight.py @@ -3,7 +3,7 @@ import re import sys -from idlelib import macosxSupport +from idlelib import macosx class ZoomHeight: @@ -32,7 +32,7 @@ def zoom_height(top): newy = 0 newheight = newheight - 72 - elif macosxSupport.isAquaTk(): + elif macosx.isAquaTk(): # The '88' below is a magic number that avoids placing the bottom # of the window below the panel on my machine. I don't know how # to calculate the correct value for this with tkinter. |