Using Wing with PyQt

Index of All Documentation » How-Tos » How-Tos for GUI Development »


Wing Pro Screenshot

Wing is a Python IDE that can be used to develop, test, and debug Python code written for the PyQt cross-platform GUI development toolkit.

Two versions of Wing are appropriate for use with this document: Wing Pro is the full-featured Python IDE for professional developers, and Wing Personal is a free alternative with reduced feature set.

If you do not already have Wing installed, download it now.

This document describes how to configure Wing for PyQt. To get started using Wing as your Python IDE, please refer to the tutorial in Wing's Help menu or read the Quickstart Guide.

Introduction

PyQt is a commercial GUI development environment that runs with native look and feel on Windows, Linux, Mac OS, and mobile devices.

While Wing does not provide a GUI builder for PyQt, it does provide advanced editing, debugging, testing, and code inspection capabilities for Python, and it can be used with other available GUI builders, as described below.

These instructions should also work with PySide, which are roughly comparable non-commercial open source bindings for Qt.

Installation and Configuration

Take the following steps to set up and configure Wing for use with PyQt:

  • Install PyQt as described in Installing PyQt5. Be sure to install also the qtdemo.
  • Install Wing if you don't already have it.
  • Start Wing from the Start menu on Windows, the Finder or OS X, or by typing wing7.1 on the command line on Linux.
  • Select Show Python Environment from the Source menu. If the Python version reported there doesn't match the one you're using with PyQt, then select Project Properties from the Project menu and set Python Executable to the full path of Python interpreter into which you installed PyQt. This value can be found by running Python outside of Wing and executing the following commands interactively:
import sys
sys.executable
  • Locate and open qtdemo.py into Wing and then select Add Current File from the Project menu to add it to your project. If you can't find qtdemo.py but have other PyQt code that works, you can just use that. However, you'll need to adapt the instructions in the rest accordingly.
  • Set qtdemo.py as main entry point for debugging with Set Current as Main Entry Point in the Debug menu.
  • Save your project to disk. Use a name ending in .wpr.

Test Driving the Debugger

Now you're ready to try out the debugger:

Start debugging with the Start / Continue item in the Debug menu. Uncheck the Show this dialog before each run checkbox at the bottom of the dialog that appears and select OK.

The demo application will start up. If its main window doesn't come to front, bring it to front from your task bar or window manager.

Next locate and open menumanager.py in the qtdemo directory and set a breakpoint on the first line of the method itemSelection. Once set, this breakpoint should be reached whenever you click on a button in the qtdemo application.

From here, you can step through code or inspect the program state with Stack Data and other tools. In Wing Pro, the Debug Console provides a command line that allows you to interact with the current stack frame in your debug process. All the debugging tools are available from the Tools menu.

See the Wing Tutorial and Quick start for more information.

Using a GUI Builder

Wing doesn't include a GUI builder for PyQt but it can be used with an external GUI builder like Qt Designer. Wing will automatically reload files that are generated by the GUI builder.

Related Documents

For more information see: