Using Wing IDE with PyQt
Wing IDE is an integrated development environment that can be used to write, test, and debug Python code that is written for the PyQt cross-platform GUI development toolkit. Wing provides auto-completion, call tips, a powerful debugger, and many other features that help you write, navigate, and understand Python code.
To get started using Wing, refer to the tutorial in the Help menu in Wing and/or the Wing IDE Quickstart Guide.
PyQt is a commercial GUI development environment that runs with native look and feel on Windows, Linux/Unix, Mac OS, and mobile devices. While Wing IDE does not include a GUI builder for PyQt, it does provide the most advanced capabilities available for the Python programming language and it can be used with other available GUI builders, as described below.
Installation and Configuration
Take the following steps to set up and configure Wing IDE for use with PyQt:
- Install Python, PyQt, and Wing. The Wing IDE Quickstart Guide provides installation instructions for Wing.
- Start Wing from the Start menu on Windows, the Finder on OS X, or by typing wing6.0 on the command line on Linux other Posix systems. Once Wing has started, you may want to switch to reading this How-To from the Help menu. This will add links to the functionality of the application.
- Select Show Python Environment from the Source menu and 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 use the Python Executable field to select the correct Python version.
- Open examples/demos/qtdemo/qtdemo.py into Wing IDE (located within your Python installation) and select Add Current File from the Project menu.
- Set qtdemo.py as main entry point for debugging with Set Main Debug File 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. To do this:
- 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. You can visit this dialog again later by right clicking on qtdemo.py in the Project view and selecting File Properties or by right clicking on the editor.
- 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 open menumanager.py from the examples/demos/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.
- Use the Stack Data tool in the Tools menu to look around the stack and the locals and globals for the selected stack frame.
- Select Debug Probe (Wing Pro only) from the Tools menu. This is an interactive command prompt that lets you type expressions or even change values in the context of the stack frame that is selected on the Debugger window when your program is paused or stopped at an exception. It is a very powerful debugging tool and also useful for writing new code in the context of the live runtime environment.
- Notice also that when the debugger is active, typing in code that is on the stack (such as in itemSelected) shows auto-completion in the editor and calltips and documentation in the Source Assistant tool that is sourced from the live runtime state of your application.
Using a GUI Builder
Wing IDE doesn't currently include a GUI builder for PyQt but it can be used with an external GUI builder. Wing will automatically reload files that are written by the GUI builder, making for a fairly seamless integration.
A Caveat: Because Python lends itself so well to writing data-driven code, you may want to reconsider using a GUI builder for some tasks. In many cases, Python's introspection features make it possible to write generic GUI code that you can use to build user interfaces on the fly based on models of your data and your application. This can be much more efficient than using a GUI builder to craft individual menus and dialogs by hand. In general model-driven GUIs also tend to be more maintainable, and the Qt widget set was designed specifically to make hand-coding easy.
Wing IDE provides many other options and tools. For more information: