Monday, April 29, 2019

Wingware Blog: Overlaying Debug Data onto Wing Pro 7's Editor

Wing 7 has been released, so in this issue of Wing Tips we take a look at one of the new debugger features in Wing Pro 7: The ability to press and hold Shift-Space to display the value of all visible symbols, using an overlay on top of the editor.

This is what it looks like:

/images/blog/debug-value-tips/debug-value-tips.gif

Notice that values are shown for any variable and also for dotted names like self.args.config_vars. When Shift-Space is released, the values are hidden.

Try it Yourself

To try this out, paste the following into a new file in Wing and save it to disk with name testtips.py:

import random
x = 3.14 ** 2
y = 'test ' * 8
z = random.randint(0, 1000000)
print("<-- Set breakpoint here by clicking on leftmost margin")

Then set a breakpoint on the last line by clicking on the margin to the left, or by moving the editor caret to that line and using Add Breakpoint in the Debug menu.

Next start debug with Debug Current File in the Debug menu and let Wing run to the breakpoint.

Finally, press and hold Shift-Space and you should see the value of x, y, and z overlaid onto the editor as follows:

/images/blog/debug-value-tips/testtips.gif

When you release Shift-Space the overlay is removed.

Binding Alternative Keys

If you don't like having to hold down the keys, another option is to bind different keys to the commands debug-show-value-tips and debug-hide-value-tips. This is done with the User Interface > Keyboard > Custom Key Bindings preference in Wing.

For example, you might bind the single key Ctrl-' to the command sequence debug-show-value-tips, debug-hide-value-tips. Wing executes the first available command in a comma-separated list, so pressing Ctrl-' the first time will show the values and pressing it again will hide them.

If you also want to override the default binding for Shift-Space, so Wing inserts a space even when the debugger is active, use the command send-keys(keys=" ")



That's it for now! In the next Wing Tip we'll take a look at using multiple selections to more easily complete some types of edits.



from Planet Python
via read more

No comments:

Post a Comment

TestDriven.io: Working with Static and Media Files in Django

This article looks at how to work with static and media files in a Django project, locally and in production. from Planet Python via read...