Tutorial: Introduction to the Editor
Now that you have set up your project, Wing will have found and analyzed the tutorial examples, and all the modules that are imported and used by them. This analysis process runs in the background and is used for auto-completion, call tips, and other features. With larger code bases, you may notice the CPU load from this process, and Wing will indicate that processing is active by displaying Analyzing Files in the status area at the bottom left of the main IDE window:
However, with this tutorial analysis will have happened instantaneously after the project was configured.
Editing with Wing
Let's start by trying out a subset of Wing's editor features, focusing on the auto-completer, Source Assistant, and some of Wing's auto-editing operations.
Open the file example1.py from the Project tool. Then bring up the Source Assistant tool the Tools menu or by clicking on its tab. This is where Wing shows documentation, call signature, and other information as you move around in your source code or work with other tools.
Scroll down to the bottom of example1.py and enter the following code by typing (not pasting) it into the file:
news = Rea
Wing displays a context-sensitive auto-completer as you type. You can scroll around in the list with the arrow keys, type Esc or Ctrl-G to abort completion, or Tab to enter the currently selected completion.
If you are used to using the Enter key for auto-completion, add it to the Editor > Auto-Completion > Completion Keys preference now.
When you first typed "news" this completer wasn't helpful because you had not yet defined news as a symbol in your source. However, once you move on to type = Re, Wing displays another completion list with ReadPythonNews highlighted. Notice that the Source Assistant updates to show call information for that function, or for whatever value is selected in the auto-completer:
Next, press Tab to enter the completion of ReadPythonNews and type ( (left parenthesis). In Wing Pro, you should now see the following code in your editor because Wing auto-enters the argument list and closing parenthesis:
Notice that when Wing Pro auto-enters arguments, it starts with all arguments selected so you have the option of simply typing over them. Alternatively, the Tab key can be used to move between and replace arguments or just the default value in keyword arguments (like force in this example). When argument entry is completed by pressing ) at the end of the list or by moving the caret out of the list, Wing automatically removes any keyword arguments with unaltered defaults.
Try this a few times now to get a feel for how the tab order works. Undo can be used to easily undo all changes made during argument entry. If you prefer not to use this feature, it can be turned off with the Editor > Auto-Editing > Auto-Enter Invocation Args preference. The same preferences page can be used to disable auto-editing entirely or to enabled and disable other operations. The default set of enabled auto-editing operations are those that should not interfere significantly with finger memory. The other operations will be described later.
Now edit the code you have entered so it reads as follows and the caret is inside the ():
news = ReadPythonNews()
Now type Get to start entering arguments for your invocation of ReadPythonNews. You will see the Source Assistant alter its display to highlight the first argument in the call signature for ReadPythonNews and add information on the argument's completion value:
The docstring for ReadPythonNews is temporarily hidden to conserve screen space. This behavior can be toggled with the Show docstring during completion option in the Source Assistant's context menu.
Now continue entering the rest of the source line so you have the following complete line of source code:
news = ReadPythonNews(GetItemCount())
Notice that typing a close parenthesis at the end of the invocation in Wing Pro skips over the close parenthesis that was previously auto-entered.
To play around with the editor a bit more, enter the following additional lines of code:
PrintAsText(news) PromptToContinue() PrintAsHTML(news)
At this point you have a complete program that can be run in the debugger. Don't try it yet, however. It contains some deliberate bugs and first we should take a look at some of Wing's code navigation features.