Using PythonWorks. Copyright by Secret Labs AB

Using PythonWorks Copyright © 1998-2002 by Secret Labs AB. Using PythonWorks Using PythonWorks Copyright © 1998-2002 by Secret Labs AB. All rights ...
Author: Adela Holmes
0 downloads 3 Views 383KB Size
Using PythonWorks

Copyright © 1998-2002 by Secret Labs AB.

Using PythonWorks Using PythonWorks Copyright © 1998-2002 by Secret Labs AB. All rights reserved. PythonWorks 1.3 edition, December 2001. Last updated November 2002.

Using PythonWorks

Page 2 of 87

Using PythonWorks

Table of Contents Using PythonWorks...........................................................................1 Introduction.....................................................................................6 New features in version 1.3.............................................................6 Overview......................................................................................7 What is PythonWorks?.......................................................................8 The PythonWorks Main Window...........................................................9 Concepts.......................................................................................10 Projects.........................................................................................11 Playing with Scratch Pads..............................................................12 Opening an Existing Project...........................................................12 Creating a New Project.................................................................13 Resources......................................................................................15 Editing Existing Resources.............................................................15 Creating a New Resource..............................................................15 Renaming, Moving, and Deleting Resources......................................16 Viewing Images and Other Resources..............................................17 Printing Resources.......................................................................18 Working with Multiple Pads...............................................................19 Importing Resources Into a Project....................................................20 Cut and Paste..............................................................................20 Importing a Single File..................................................................20 Importing a Group of Files.............................................................21 Exporting Resources from a Project....................................................22 Exporting a Group of Files.............................................................22 Running Programs...........................................................................23 Running a Script..........................................................................23 Running an Application.................................................................23 Stopping a Program.....................................................................23 Defining what Python Interpreter to Use..........................................23 Tracing Programs............................................................................24 Deploying Applications.....................................................................25 The Workspace Browser...................................................................26 The Icon Bar...................................................................................27 The Pad Window.............................................................................28 Pad Working Area........................................................................29 The Quick Info Panel........................................................................30 More About Projects.........................................................................32 More About Plug-ins.........................................................................34 More About the Text Editor...............................................................36 More About the Layout Editor............................................................37 Introduction................................................................................37 Layout Editor Components............................................................37 Layout Toolbar............................................................................37 The Widget Icon Bar.....................................................................39 The Property Panel.......................................................................39 Undo/Redo.................................................................................39 Using PythonWorks

Page 3 of 87

Using PythonWorks Inspect the Layout.......................................................................39 Grouping....................................................................................39 Interfacing Your Layout.................................................................40 More About the Tracer......................................................................42 More About Deploying Applications.....................................................44 Redistributables...........................................................................44 Deployment Details......................................................................45 Run Environments...........................................................................48 The Home Page...............................................................................51 The Project Home Page....................................................................52 The Import Toolbox.........................................................................53 The Export Toolbox..........................................................................53 The Print Toolbox............................................................................53 Searching......................................................................................54 More About Directory Workspaces......................................................55 The Directory Workspace..............................................................55 Connecting to a Directory Workspace..............................................55 More About Perforce Workspaces.......................................................56 Perforce workspace......................................................................56 Terminology................................................................................56 Connecting to a Perforce Workspace...............................................56 Available Perforce Operations.........................................................57 Plugins Reference............................................................................60 Action Plugins..............................................................................60 Autotranslate Plugins....................................................................60 Bindings Plugins..........................................................................61 Bookmark Plugins........................................................................61 Editprefs Plugins..........................................................................62 Extension Plugins.........................................................................63 Iconbar Plugins............................................................................64 Importer Plugins..........................................................................64 Layout Plugins.............................................................................64 Package-Doc Plugins....................................................................65 Package-Ico Plugins.....................................................................65 Package-Kit Plugins......................................................................65 Package-Src Plugins.....................................................................65 Package-Sys Plugins.....................................................................65 Resource Plugins..........................................................................66 Resource-Editor Plugins................................................................66 Resource-Viewer Plugins...............................................................67 Runenv Plugins............................................................................67 Search-Uri Plugins.......................................................................67 Template Plugins.........................................................................68 Translate Plugins.........................................................................68 Workspace Plugins.......................................................................69 Editor Details..................................................................................70 Text Editor, Notepad Bindings...........................................................71 Mouse Bindings...........................................................................71 Keyboard Bindings.......................................................................71 Python Editor, Notepad Bindings........................................................74 Mouse bindings............................................................................74 Using PythonWorks

Page 4 of 87

Using PythonWorks Keyboard bindings.......................................................................74 Text Editor, Emacs Bindings..............................................................75 Mouse bindings............................................................................75 Keyboard bindings.......................................................................75 Python Editor, Emacs Bindings..........................................................78 Mouse bindings............................................................................78 Keyboard bindings.......................................................................78 Changes From Earlier Versions..........................................................79 Changes in 1.2............................................................................79 Changes in 1.3............................................................................80 PythonWorks License Agreement........................................................81 Index............................................................................................85

Using PythonWorks

Page 5 of 87

Introduction

Introduction Thank you for choosing PythonWorks!

New features in version 1.3 • • • • • • • • • • • •



Jython support. You can develop, run, and debug programs written for Jython/JPython 1.0, 1,1, 2.0, 2.1, and later. Improved support for newer Python versions. 2.1, 2.2 etc. This release uses Python 2.1.1 internally. Much improved graphic user interface builder (layout editor) for Tkinter/uiToolkit. The main editor pad can be split, with subpads either on top of each other, or side by side. New functions such as built-in PyChecker, diff, etc. Much improved Emacs/Notepad-style editor bindings. The editor now highlights matching parentheses. Show line/column and selected editor mode in status line. New project settings panel. Speed improvements, most notable to the tracer and editor. New and improved menus. A rich set of predefined run environments for common Python distributions, plus automatic generation of run environments for Jython and others. An on-line version of Fredrik Lundh's book Python Standard Library is available as part of the help system.

See the reference section for changes from earlier versions.

Using PythonWorks

Page 6 of 87

Introduction

Overview

Using PythonWorks

Page 7 of 87

What is PythonWorks?

What is PythonWorks? PythonWorks is an integrated development environment specially designed to make it easier and faster for Python developers to create Python scripts and applications. The design goal behind PythonWorks has been to create an environment that reflects the philosophy of the underlying Python language, i.e. a clean and easy to use implementation without a lot of incidental complexity. Alternatively, PythonWorks can be described as a framework with a number of built-in services. This framework is populated with the components needed to write, develop, verify, test and deploy Python scripts and applications. All this taken together gives a dynamic extensible IDE for Python developers to use.

Using PythonWorks

Page 8 of 87

The PythonWorks Main Window

The PythonWorks Main Window When you start PythonWorks, it displays a single main application window:

The workspace browser contains a list of all resources in a PythonWorks workspace. Resources are the different files that make up a project, such as Python files, text files, layout descriptions, images, etc. The icon bar contains tool buttons that you can use to quickly create new resources, or to run predefined commands (so-called actions). The main working area (the pad) is located in the middle of the window. It is used to view and edit resources. You can split the pad into multiple work areas, and also create additional pad windows. Finally, the document browser panel (also called quick info panel) to the right provides access to documentation and search facilities.

Using PythonWorks

Page 9 of 87

Concepts

Concepts Projects In PythonWorks, your code is organized in projects. A project can be an application, a library, a collection of scripts, or whatever else you might use PythonWorks for. A project consists of a workspace and a link to a repository.

Resources Resources are the files that make up your project. PythonWorks lets you edit Python scripts, text files, XML files, and layouts. In addition, PythonWorks knows about other resource types, such as images, sound snippets, etc. You can for example view images and play sounds from inside PythonWorks.

Workspaces The resources that make up a project are stored in a workspace directory. The workspace is usually linked to a separate repository. PythonWorks Pro 1.3 provides three kinds of workspaces: standard workspace, perforce workspace and external directory workspace. You can undo and redo changes made to a workspace, until they're committed to the repository. (You can access the undo/redo commands from the project menu at the top of the workspace browser window.)

Using PythonWorks

Page 10 of 87

Projects

Projects A project consists of a workspace (usually an ordinary directory on your local disk) and a link to a repository. A PythonWorks repository is meant to be used as a link to various standard types of project storage. If you for example connect using a perforce repository, you will get a repository using the version control system Perforce. This separation allows you to work in a workspace without disturbing anybody else prior to committal of your changes to project storage. When committed, the changes will be available to others. The repository can also be seen as a synchronisation/backup point you can safely return to, if you want to scrap some new changes. The forms of project storage available depends on which PythonWorks workspace plugins you have installed. In PythonWorks Pro 1.3, the available workspaces are standard workspace, perforce workspace and directory workspace. The standard workspace is a simple one that uses another directory on your local disk as the repository. When you create a new project, PythonWorks will automatically create both the workspace directory and the repository directory. The directory workspace allows you to use any existing directory as the workspace. Directory workspaces don't have repositories. The perforce workspace connects a project to a Perforce server. Support for other version control systems is under way. In PythonWorks it is possible to undo the changes made to a project. You can access the undo/redo commands from the project menu at the top of the workspace browser window. Actions such as move, rename, delete, create etc can be undone or redone. Note: When you exit PythonWorks or leave the project this undo information is lost. PythonWorks keep tracks of the structural changes you apply to the project so that the repository can be updated to reflect your changes when you are ready to commit. See the Workspace Browser and Project Homepage reference sections for related information. Using PythonWorks

Page 11 of 87

Projects

Playing with Scratch Pads When you open up PythonWorks for the first time, it opens a "scratch" project. While in the scratch project, you can use the interpreter window, and write throw-away scripts. However, you cannot save such scripts between runs. If you have used PythonWorks before, it opens up the project you worked with the last time you ran PythonWorks. To get back to the scratch project, close the current project.

Opening an Existing Project PythonWorks maintains a list of available projects on the home page. To open an existing project: 1. Close the current project, if any. See below for details. 2. Click on the home button. 3. Click on the name of the project you want to open. PythonWorks remembers the current project between runs. If you have selected a project, that project is automatically opened the next time you start PythonWorks. To close the current project: 1. Click on the home button. This brings you back to the project home page. 2. Click on the close project action link. or: 1. Click on the close button (a cross) in the workspace browser.

Using PythonWorks

Page 12 of 87

Projects

Creating a New Project To create a new project: 1. Close the current project, if any. See below for details. 2. Click on the home button. 3. Click on the create project action link. 4. Fill in the project name. You can use any valid directory name, but it is a good idea to avoid spaces and punctuation characters. 5. Select what kind of workspace type you want to use for this project. If this is your first project, select standard, or just skip this field. For more information on different workspaces, see below. 6. Click OK. 7. If you selected a non-standard workspace, fill in the workspace configuration dialogue, and click OK.

More About Standard Workspaces The standard workspace uses a local directory to hold the resources in the workspace, and a separate repository directory to hold final versions of the files. The commit action copies resources to the repository. The revert action copies resources to the workspace.

More About Directory Workspaces The directory workspace allows you to use any existing local directory, as is. This workspace does not provide commit and revert functionality.

Using PythonWorks

Page 13 of 87

Projects

More About The Perforce Workspace The perforce workspace connects a workspace to a Perforce version management server. To synchronize the workspace, use the update resources action link on the project home page. (This corresponds to the p4 sync command.) When you use this workspace, resources are marked as readonly. To modify such a resource, use the edit command in the resource popup to check it out (p4 edit). To commit your changes back to the repository, use the commit resources action link on the project home page. This brings up a commit dialogue. Type in a short description of what you have changed, and click OK (p4 submit). Note: The perforce workspace uses a locking scheme for multi-user projects (p4 lock). In this release of PythonWorks, locking is mandatory. To learn more about the Perforce workspace, read the Perforce Workspace Plugin section in the reference section.

Using PythonWorks

Page 14 of 87

Resources

Resources Resources are the files that make up your project. PythonWorks lets you edit Python scripts, text files, XML files, and layouts. In addition, PythonWorks knows about other resource types, such as images, sound snippets, etc. You can for example view images and play sounds from inside PythonWorks. You can also add handlers for custom resource types. PythonWorks can automatically translate some resources to Python objects. For example, if you place an image in the images directory, you may then import it into your application as a Python Imaging Library Image object.

Editing Existing Resources To edit an existing resource: •

Click on the resource name in the workspace browser.



If the resource is already loaded into the editor pad, click on its tab.

Or:

Creating a New Resource To create a new resource: •

Click on one of the resource icons in the icon bar.



Click on one of the resource icons, keep the mouse button pressed, and drag the icon onto the editor pad.



Click on the dog ear. This only works for Python scripts and text resources.

Or:

Or:

Using PythonWorks

Page 15 of 87

Resources

Renaming, Moving, and Deleting Resources PythonWorks allows you to rename existing resources. You can also move a resource around by renaming it. To rename a resource: Highlight the resource in the workspace browser, to make it appear in the editor pad. • Click in the title field, and type in the new resource name. •

Note: You cannot change the name of read-only or otherwise protected resources. PythonWorks indicates that the name can be changed by drawing a white line around the title in the title bar. To move a resource: Highlight the resource in the workspace browser. • Keeping the mouse button down, drag the resource to the new location. •

Or: •

Click in the title field, and type in the new resource name.

Note: Resources in a directory are always sorted in alphabetical (lexical) order, with subdirectories shown before other resources. You cannot change the order inside the directory. To delete a resource:



Highlight the resource in the workspace browser Select Delete in the resource menu.



Right-click on the resource and select Delete in the popup menu.



Or:

Using PythonWorks

Page 16 of 87

Resources

Viewing Images and Other Resources PythonWorks provides read-only (or listen-only) viewers for images, sounds, and certain other resource types. To view a resource: •

Click on the resource name in the workspace browser.



If the resource is already loaded into the editor pad, click on its tab.

Or:

If PythonWorks cannot find a suitable viewer, it displays a hex dump. Click on the text tab to show the resource contents as a text file instead.

Using PythonWorks

Page 17 of 87

Resources

Printing Resources PythonWorks can print text resources, Python scripts, and any other textstyle resources to the default printer. On Windows, you can also print images.

Printing a Single Resource To print a single resource: 1. Highlight the resource in the workspace browser. 2. Click the right button to bring up the resource popup menu, and select print resource.

Printing Multiple Resources PythonWorks provides a print toolbox in which you can select multiple resources, either by resource type or resource name. To display the print toolbox: 1. Click on the home button. This brings you back to the project home page. 2. Click on the print resources action link. or: 1. Click on the print resources icon (a typewriter) in the icon bar. To select and print resources: 1. Select the resource types you want to print by clicking on the type names. 2. Click on the print button to print selected resources. 3. Click on the close button to remove the toolbox. or: 1. Select select >> list names in the toolbox menu. 2. Select the resources you want to print by clicking on the resource names. You can select a range of resources by dragging the mouse from the first resource to the last. 3. Click on the print button to print selected resources. 4. Click on the close button to remove the toolbox.

Using PythonWorks

Page 18 of 87

Working with Multiple Pads

Working with Multiple Pads To create an additional pad window: 1. Click on the menu bar just above the editor title bar. 2. Keep the mouse button pressed, and drag the pointer outside the bar. When you release the button, a new pad window appears. or: 1. Select pads >> new windows Note: The new window usually provides another view of the resources shown in the original pad. However, not all editors support multiple views. In that case, the original pad will be emptied. To split the pad window: 1. Select pads >> split to split the current pad into two separate views, placed on top of each other. or: 1. Select pads >> split side by side to split the current pad into two separate views, placed side by side.

Using PythonWorks

Page 19 of 87

Importing Resources Into a Project

Importing Resources Into a Project Cut and Paste To copy text or images from another program: 1. Switch to the program you want to copy from, select the text or image you want to copy, and copy it to the clipboard. 2. Switch to PythonWorks, and click on the dogear to clear the pad. 3. In the pad menu, select edit >> paste. 4. Click in the title field, and type in the resource name. You can use the keyboard instead of the menu. Make sure the pad has focus, and press the paste key. In Notepad mode, that's Control-V. Note: PythonWorks only supports image cut and paste on Windows.

Importing a Single File To import a single file into your workspace: 1. Highlight the target directory in the workspace browser. 2. Click the right button to bring up the resource popup menu, and select import from file. 3. In the file dialogue, select the file you want to import. 4. Click open to load the file into your workspace.

Using PythonWorks

Page 20 of 87

Importing Resources Into a Project

Importing a Group of Files To display the import toolbox: 1. Click on the home button. This brings you back to the project home page. 2. Click on the import resources action link. or: 1. Click on the import resources icon (a box with an inward arrow) in the icon bar. To select and import resources: 1. Select the directory you want to import from in the directory browser to the left. 2. Select the types you want to import by clicking on the type names. 3. Click on the import button to import the selected resources. 4. Click on the close button to remove the toolbox.

Using PythonWorks

Page 21 of 87

Exporting Resources from a Project

Exporting Resources from a Project Exporting a Group of Files To display the export toolbox: 1. Click on the home button. This brings you back to the project home page. 2. Click on the export resources action link. or: 1. Click on the export resources icon (a box with an outward arrow) in the icon bar. To select and export resources: 1. Select the resource types you want to export by clicking on the type names. 2. Click on the export button to export selected resources. 3. Click on the close button to remove the toolbox. or: 1. Select select >> list names in the toolbox menu. 2. Select the resources you want to export by clicking on the resource names. You can select a range of resources by dragging the mouse from the first resource to the last. 3. Click on the export button to export selected resources. 4. Click on the close button to remove the toolbox.

Using PythonWorks

Page 22 of 87

Running Programs

Running Programs PythonWorks lets you run applications from inside the development environment. Output from your program is displayed in a console view.

Running a Script To run a script: 1. Make sure the script is loaded into the active editor pad. 2. Click the play button.

Running an Application If you develop larger applications, it can become tedious having to switch back to the main script every time you want to start the application. To solve this, you can tell PythonWorks which script it should run to start the application. To tell PythonWorks which script to run: 1. Look for a run.wpy resource in the top level of your workspace. If it doesn't exist, click the run application button in the icon toolbar to create it. 2. Open the run.wpy resource, and change the STARTSCRIPT to the name of your application script. 3. Click the right button in the browser panel, and select Reload actions. To run the application script: 1. Click the run application button in the icon toolbar.

Stopping a Program To stop a running program: 1. Click the stop running program button

Defining what Python Interpreter to Use You can select which Python interpreter to use for running your program in the project settings dialogue.

Using PythonWorks

Page 23 of 87

Running Programs For more information on run environments, see Runenv Plugins reference section.

Tracing Programs The PythonWorks tracer lets you monitor and debug Python programs. You can use the tracer to inspect a running program or single-step through your program to verify the function. To trace a script: 1. Make sure the script is loaded into the active editor pad. 2. Click the trace button. For more information, see the Tracer reference section.

Using PythonWorks

Page 24 of 87

Deploying Applications

Deploying Applications PythonWorks includes tools to package your application in different ways for distribution. To do this, PythonWorks uses deployment scripts. You can deploy your application in the following ways: • • • • •

• •

As source files As compiled PYC files As a single file, in an executable Python archive (Windows) As an EXE-file without the Python runtime. To run the application, the user needs to install Python separately. (Windows) As an EXE-file, along with a complete Python runtime deployed in a directory. This allows you to have a complete standalone kit for your application, which can be installed with a standard installation tool (e.g. InstallShield) (Linux) As an RPM-package. (Linux) As a stand-alone distibution together with an archive containing the program.

To tell PythonWorks how to deploy the application: 1. Look for a deploy.wpy resource in the top level of your workspace. If it doesn't exist, click the deploy application button in the icon toolbar to create it. 2. Open the deploy.wpy resource, and modify the script if necessary, according to the instructions in the script.

To deploy the application: 1. Click the deploy application button in the icon toolbar.

Using PythonWorks

Page 25 of 87

The Workspace Browser

The Workspace Browser What you see in this window is a view of your project workspace. The view reflects the resources you have placed in the project. This window is empty if no project is selected. If a resource is marked using a bold font it means that the resource was modified since the last commit to the repository. If the project is connected to a version control system you may also see other color-coded names here to indicate the status of the resources (locked, updated, modified etc.).

Available operations in the workspace browser: Show (open in pad). Click with mouse on a resource. Opens the selected resource in the pad window. • Show (open in pad) 'alternative'. Drag resource into pad. Opens the selected resource in the pad window. • Move a resource within the project by dragging it with the mouse. •

Right click popup menu. • • • • • • • • • • • • •

Show (open in pad). Open the selected resource in the pad window. Edit. Make the file editable. (Used when using versioned controlled repository). Clone (make copy). A copy of the resource is created and "_new" appended to its original name. Create Folder. Create a subfolder in the project. Revert Changes. Replace the selected resource with the latest saved version from the repository. Reload Actions. Update or add a plugin definition to the PythonWorks registry. Run. Run the selected resource PyChecker. Run the PyChecker utility on this resource. Diff. Shows a diff between this resource and the last committed version. Summary view. Display an overview of the classes and methods in a python resource. Import from file. Import a single resource into the project. Print resource. Print the selected resource. Delete. Delete the selected resource from the project.

Note: These actions are also available from the resource menu located above the workspace browser. See the About Projects and Project Homepage reference sections for related information. Using PythonWorks

Page 26 of 87

The Icon Bar

The Icon Bar Between the workspace browser and the pad is a column containing a number of icons. The topmost icons represent available resource types. Clicking on an icon or dragging it into the pad creates a new resource of the selected type. Below the resources is a list of action icons. Actions like import, export, print, deploy, python interpreter, and run are installed by default. You can add your own actions by defining a special PythonWorks plug-in. See the Action Plugin reference section for more information. • • • • •



Import. Displays a dialog where you can select files to import into the current project. Export. Displays a dialog where you select which files in the current project to export. Print. Displays a dialog where you can select files to print. Python Interpreter. This action will start an interactive python interpreter. Deploy. This action will run the default deployment script deploy.wpy if it is available. If it is not already available PythonWorks will ask you to select a deployment scheme and a generic deploy.wpy script will be created for you. Modify the file to suit your needs. Run. This action executes a pre-defined python resource in your project. If the resource has yet to be defined, PythonWorks will create a default run.wpy file where you can specify the name of the resource to be executed.

Using PythonWorks

Page 27 of 87

The Pad Window

The Pad Window The pad consists of a header at the top and a large working area below. The header contains an interface similar to a web-browser, including back, home and forward buttons. They work as you would expect, and allow you to move backwards and forwards in the history of the pad. Press home to get to the current home page. Next to these buttons you can see a title field. Here is the place to change the name of such things as projects and resources or assign names to untitled ones. Just click on the title to change the name. Note: If you have not yet given a resource a name, the title will reflect this by appearing as an entry field to get you to name the resource. When named, a box around the title indicates the possibility of changing the name. If there is no box you will not be able to change the name, e.g. the PythonWorks homepage. To the right of the title field are the stop, trace and execute buttons. They will act on the resource currently in the pad. Stop will stop any running scripts, trace will start the debugger on the currently selected script, and execute will run your current resource. In version 1.3 of PythonWorks Pro multiple pads can be used simultaneously, (e.g. Edit a resource in one pad, run a resource in another pad and view documentation in a third pad). To open a new pad use the pads menu or click and drag the grey menu bar. At the top of the pad there is a tab strip which displays recently selected resources. The tabs allow you to quickly select resources you have already opened. A unique tab strip accompanies each pad you open. At the bottom right corner you can see a "dog ear". Press this to create a new empty (untyped) resource in the pad. Note: Here, "untyped" means that the resource type is not yet defined. If you start typing you will get a Python buffer. If you use your clipboard to paste an image into an empty buffer, the resource will become an image resource etc. (Don't forget to name your resource as soon as possible.) At the bottom of the pad there is a status bar showing some information depending on what you do.

Using PythonWorks

Page 28 of 87

The Pad Window

Pad Working Area The pad working area is used to view and edit resources. To select a resource to view or edit just click on it in the workspace browser or on a link in a help window. If PythonWorks has a suitable editor or viewer installed for that resource type, it opens it in the pad. PythonWorks includes standard editors and viewers for the following basic resource types: • • • • • • •

text files (.txt files) python source files (.py files and .wpy files) documentation files (XHTML) (.wxl files) xml text-files (.xml files) image files sound files layout files (.wui files)

You can add your own resource-handlers, viewers, and editors for other resource types. See the Resource Plugin reference section for details. Note: See the More About Perforce Workspaces reference section for an explanation of how to view and edit resources when the workspace is connected to a versioning system

Using PythonWorks

Page 29 of 87

The Quick Info Panel

The Quick Info Panel The quickinfo panel provides an integrated online information and help system. The quickinfo panel uses an interface similar to a web-browser with back, forward and home buttons. Quickinfo links are shown in the same window. (Click on the home icon in the quickinfo panel to return to the quickinfo homepage.) If you read the reference documentation the pages will be presented in the pad window instead, since they need more space to display the information. In the quickinfo system you can see a list of all available reference documents, a list of bookmarks, and some general documentation for Python. (The show and hide links can be used to show or hide parts of the content.) The following reference documentation is included in the full version of PythonWorks:

Using PythonWorks

Page 30 of 87

The Quick Info Panel Note: If the document you are browsing contains navigation data, the arrows at the bottom of the screen can be used to move between pages in a "logical" order. The bookmark list can contain bookmarks to the documentation, PythonWorks commands, and other actions. You can add your own bookmarks. See the Bookmarks reference section for details.

Using PythonWorks

Page 31 of 87

More About Projects

More About Projects

A Project is implemented as a workspace (an ordinary local directory) and an interface to a repository. A PythonWorks repository is meant to be used as a link to various standard types of project storage. If you connect using a P4workspace you will get a repository using the version control system Perforce. This separation allows you to work in a workspace without disturbing anybody else prior to committal of your changes to project storage. When commited, the changes will be available to others. The project storage can also be seen as a synchronisation/backup point you can safely return to, if you want to scrap some new changes. The forms of project storage available depends on which PythonWorks workspace plugins you have installed. PythonWorks Pro 1.3. provides three standard plugins: StandardWorkspace (TransactionWorkspace), P4Workspace and DirectoryWorkspace. The standard workspace is the default one that uses another local directory as the repository. The directory workspace allows you to connect a project to any directory in the filesystem. The perforce workspace connects a project to a Perforce server. Support for other version control systems is under way. In PythonWorks it is possible to undo the changes made to a project. You can access the undo/redo commands from the project menu at the top of the Project browser window. Actions such as move, rename, delete, create etc can be undone or redone. Using PythonWorks

Page 32 of 87

More About Projects Note: When you exit PythonWorks or leave the project this undo information is lost. PythonWorks keep tracks of the structural changes you apply to the project so that the repository can be updated to reflect your changes when you are ready to commit. See the Workspace Browser and Project Homepage reference sections for related information.

Using PythonWorks

Page 33 of 87

More About Plug-ins

More About Plug-ins Plug-ins are extensions to PythonWorks that enhance its capabilities. Many of PythonWorks functions are implemented as pre-installed plug-ins. You can also install your own plug-ins. There are plug-ins for documentation packages, run environment profiles, editor bindings, entries in bookmark lists, editor preferences (fonts, colours), PythonWorks actions etc.

If you want to extend or modify PythonWorks, write a script that defines and registers the functions according to the guidelines and place that script in the correct location for PythonWorks to recognize it. There are three different types of extension plug-ins: Action script (.wpy). This is the most lightweight type. Used for such things as deployment/build scripts, bookmarks, setting editor preferences and setting up run environment profiles. You can run action scripts by selecting them in the workspace browser, and then clicking on the run button. • Plug-in script ("*-Plugin.py"). This is the normal plug-in type. Plugin scripts register themselves when a project is opened (or when you •

Using PythonWorks

Page 34 of 87

More About Plug-ins use reload actions). They can provide all kinds of extensions, including PythonWorks action scripts. • Package file. This is a plug-in distribution format which contains a collection of plug-ins, files, and other resources. Used for documentation packages, preinstalled plug-ins, and PythonWorks updates. PythonWorks searches the following four locations for plug-ins to scan and install: The installation directory. (Only for preinstalled plug-ins) The SYSTEM project. (Globally installed plug-ins. Active in all projects.) • The current project. (Locally installed plug-ins. Only active/visible in this project.) • The users home directory under subdirectory pythonworks. (Normally for user preferences. This only affects the user in question.) • •

Note: A new occurrence of a previously installed plug-in replaces the original. This means that plug-ins registered in the current project override plug-ins in the SYSTEM project and so on. Note: Be careful if you override preinstalled plug-ins as some things may stop working. Example: Things you want to affect all projects can be placed in the SYSTEM project. Things that you only want for certain projects can be placed in that project instead. This means that you can customize PythonWorks on a project-by-project basis.

Unregister Plug-ins Use unregister to disable/hide a plug-in. Example: Remove the print icon in the iconbar. Just place this line in a .wpy file in your project. (Effective after the next reload.) unregister("iconbar", "print-assistant")

You can use the show packages action to get a list of all installed plug-ins.

Using PythonWorks

Page 35 of 87

More About the Text Editor

More About the Text Editor The editor consists of a margin and a normal writing area. Normally you just type text into the writing area. The editor supports notepad and emacs-style keyboard bindings. If you are familiar with one of them you should not have any problem getting started. If not, see the keyboard bindings chapter that lists the functions and what keys are used to reach them. PythonWorks handles the saving of data so you don't have to worry about it. The editor can display both proportional and fixed fonts with user-defined colors and sizes. (See the Editprefs reference section for details.) The editor supports different language modes:

In Python mode the source code is colored based on syntax, and the keyboard bindings are Python aware. This means that there are functions available such as autoindent, selecting a Python block, commenting out a section etc. The Python mode uses tabs for indentation, and does not allow you to put spaces in the indentation. PythonWorks also provides basic syntax coloring for XML and HTML documents.

Using PythonWorks

Page 36 of 87

More About the Layout Editor

More About the Layout Editor Introduction The layout editor allows you to design user interfaces using Tkinter and Secret Labs' uiToolkit for Tkinter. To create a layout, you first design it in the layout editor. You then create a Python module that forms an interface to your layout. Your program can add functionality or modify the layout appearance. See Interfacing your layout below.

Layout Editor Components The layout editor consists of a toolbar at the top, a widget iconbar to the left, a drawing grid in the middle, and a widget property panel at the bottom.

Layout Toolbar Tabs The toolbar contains three tabs. Design, XML and Source. When you are designing, adding and moving widgets you are using the design view. To inspect the internal XML-representation click the XML tab. To view the generated Python code, choose the Source tab.

Tools The toolbar contains three design tools: The Pencil • The Eraser • The Rubber band •

You use these to edit the layout you are designing. Use the pencil to draw new widgets, select, move and resize widgets, the eraser to erase/remove widgets and the rubber band to group widgets together.

How to use the tools. To create a new widget:

Using PythonWorks

Page 37 of 87

More About the Layout Editor 1. Click in the iconbar on a widget icon 2. Click in the design grid, or drag a rectangle in the grid. 3. You can create more widgets just by repeating step 2. or 1. Click on the widget icon, keep the mouse button pressed, and drag the icon to the design grid. To duplicate an existing widget: 1. Press and hold down the Control key. Click on an existing widget, keep the mouse button down, and drag it to the design grid. To move an existing widget: 1. Select the pencil tool. 2. Click on a widget, and move the mouse while holding the mouse button pressed. To resize an existing widget: 1. Click on a widget to select it when you have the pencil tool selected. 2. Click on a widget corner, hold the mouse button down, and move the mouse to resize the widget. To remove existing widgets: 1. Select the eraser tool. 2. Click on the widget to erase, or click and drag over a group of widgets to erase all of them. To assign a geometry manager to a group of widgets: 1. Select the rubberband tool. 2. Click just outside the group, keep the mouse button down, and move the mouse to group the widgets. To modify the properties of a widget: 1. Click on an widget to select it when you have the pencil tool selected. 2. Click on the field to the right of the property name you want to modify. (Information about the property will appear in the quickinfo window, if you select the property name). 3. Fill in the field or choose values from the comboboxes that appear. 4. Press enter or go to another property and to set the values.

Using PythonWorks

Page 38 of 87

More About the Layout Editor

The Widget Icon Bar The widget iconbar contains a palette of base widget types. Not all widget types that are available are shown in the iconbar. To use a widget other than those shown just create a similar widget, then click on the right column next to type in the widget property panel and select the widget you want from the combobox. Note: If you want to include a widget that is not included in the list you can add a custom widget (a frame) as a placeholder. You can then replace that widget in your layout from your program interface later on.

The Property Panel The widget property panel is used to modify/set the properties for the widgets. The property panel contains a list of available properties for the selected widget. The name is in the left column and the current value is shown in the right column. To change a property click in the right column. You will get an entry field or some combo boxes to help you fill in the property value. If you click in the left column for a generic widget (toolkit independent) a short description of its usage is displayed in the quickinfo panel. For toolkit specific properties refer to the Tkinter and uiToolkit handbooks.

Undo/Redo Undo is available to regret the last commands. Use Control-z on the keyboard to undo, Control-y to redo what you have undone.

Inspect the Layout When you want to see how the user interface looks, press the execute/run button (in the pad title field). Events and commands generated when you use this "live layout" feature are shown in the console window.

Grouping Adding geometry managers You group widgets together using the rubber band tool. Performing this operation will create a group item in the layout. You can set properties for group items in a similar way to normal widgets. However, they have some Using PythonWorks

Page 39 of 87

More About the Layout Editor new interesting properties. For example the manager field. This defines which geometry manager should be used for the group. When you first group some widgets, PythonWorks attempts to guess the most appropriate manager (hpack, vpack or grid). If the widgets are placed in a row then hpack is chosen etc. You can always change the manager type if it is not appropriate.

Controlling layout resizing The layout editor supports Tkinter's place and grid geometry managers. This means that you can create layouts that behave appropriately when the user resizes them. If you don't group the widgets then a place manager is used and the layouts cannot be resized. However, if you use the grid manager the layout can be resized. To control the response to size adjustments and how the group designates space to its component widgets, the following fields in the options of a group are used: xweight, yweight and sticky. xweight is a list of numbers describing which columns should be resized (The first number is for the first column, etc.). The allocation of space is proportional to the values supplied. Use zeros to disable resizing of a specific column. yweight works in a similar way for rows. sticky is used to define if the group should be anchored to a certain side or stretch its contents when resized.

Interfacing Your Layout An interface object can be used to connect to the layout just created. It is an ordinary object instance where you add a method for each of the events coming from the layout component. When you later instantiate the layout in your program you supply the UI with the master widget and the interface object. See example below or look up the example in the demo project. You can also use the Get example code snippet link on the project page to load an example layout interface inot your project.

Automatic translation to a python module. By placing your layouts in the layouts folder, PythonWorks will automatically translate them into Python modules. To use them in your program, just import them from the layouts package.

Using PythonWorks

Page 40 of 87

More About the Layout Editor

Example of an interface module Example: testmylayout.py # File: testmylayout.py from Tkinter import * from layouts import mylayout # Interface class class Target: def ok(self): print "OK" def cancel(self): print "CANCEL" # target object is called from the ui-layout target = Target() root = Tk() ui = mylayout.UI(root, target) ui.pack() root.mainloop()

Description of example above. The first line imports Tkinter. We then import the layout (layouts/mylayout.wui). Since the layout is placed in the layouts directory, it will be automatically converted into a Python module by PythonWorks. We then create an interface class called Target. If you have defined commands or callbacks in your layout you must define methods in this class to handle them. In this case we have two buttons that we defined commands for. (ok, cancel) Next, we create an instance of Target called target. Then we instantiate the layout object we have created. This is an ordinary Tkinter widget so you can use it, as any other widget, to bring up the user interface. Finally, the layout is packed, and the script enters the Tkinter main loop.

Using PythonWorks

Page 41 of 87

More About the Tracer

More About the Tracer The PythonWorks tracer lets you monitor and debug Python programs. You can use the tracer to inspect a running program or single-step through your program to verify the function. It's emphasis is on allowing you to understand the program by watching it run rather than having all possible debugging features available. The tracer is started by first selecting the script you want to trace and pressing the trace this resource button. A tracer window is then displayed where you can control your program.

• • • • • • • •

The following commands are available: Run: Run through the program. Stops at breakpoints (F5). Fast: Run the program at full speed, ignoring breakpoint (Shift-F5). Slow: Starts the program in slow motion. The tracer steps through your program very slowly, so you can see the program flow (F6). Stop: Stops the running program (F7). Step-in: Step through the program one line at a time, stepping into user-defined functions and methods (F8). Step-Over: Step through the program one line at a time. This command steps over all user-defined functions and methods (F9). Return: Run the program until it leaves the current function or method (Shift-F9). Quit: Stop the program, and remove the tracer window (ControlF5).

Breakpoints You can set a breakpoint by double clicking in the margin in a source code view. More advanced uses of brakpoints. You can also set an explicit code breakpoint, which hands control over to the tracer at a given point. This allows you to run at full speed (Fast) and start debugging where you like. To insert an explicit code breakpoint, add these lines to your program. try: import sys sys.modules["__main__"].starttracer() except: pass

(Note that the program only stops when you are running the program under the tracer.) Using PythonWorks

Page 42 of 87

More About the Tracer You can choose what you want to inspect by clicking on the tabs at the top of the window. • • • • •

Console: Displays the input and output from your program. Local variables: Displays the local namespace. Global variables: Displays the global namespace. Info: Displays information about the latest exception. Stack frame: Displays the stack frames. It tells you how the program ended up in this function/method.

When the tracer is running, the background of the source files you see in the pad is pink. The files are shown in a read-only mode and you can set break-points by double clicking in the margin. You can also see a marker in the file; the current line is highlighted in the source buffer.

• • • • •

The colors mean: Yellow: It means that this is the next line to execute. Gold: It means the program has stopped at a breakpoint. Red: The program has stopped with an error (exception). Green: The program has successfully ended and this was the last line executed. Light Green: The program is running and this was the point it was continued from.

Note: The tracer uses the currently selected run environment which defines the python interpreter and modules to use when running user programs. (See the Runenv reference section)

Using PythonWorks

Page 43 of 87

More About Deploying Applications

More About Deploying Applications PythonWorks includes tools that allows you to package your application in different ways for distribution and testing etc. A deployment script can be seen as a makefile for distribution. These are the default ways to package your python application: • • • •



• •

As source files. (*.py) As compiled files. (*.pyc) As a compressed archive. (*.py) As an exe-file without the Python runtime. (Windows) This means that you will need to have an installed Python interpreter and libraries to run this executable As an exe-file along with a complete Python runtime deployed in a directory.(Windows) This allows you to have a complete standalone kit for your application. As a standard rpm-package. (UNIX) As a standalone distibution together with an archive containing the program. (UNIX)

You can however package your application in any configuration you want by customizing the deployment script. See the list of translators in the show packages page on the project homepage. In the iconbar you can see an icon for deployment. When you want to package your program just click on this icon. If you don't have a default deployment script deploy.wpy in your project then PythonWorks will ask you to select a deployment scheme and a generic script will be created for you. You can then customize that script to fit your deployment needs. See the Deployment Details reference section for more information.

Redistributables The modules and components listed below are REDISTRIBUTABLES, and accordingly excepted from clause 2b in Secret Labs' license agreement, which means that you may redistribute these modules and components together with your applications. • • • • • •

Python interpreter and standard libraries. Secret Labs' Python Imaging Library (PIL) PythonWare Sound Toolkit (PST) PythonWare XMLRPC PythonWare SOAPLIB PythonWare uiToolkit, in binary format only. (Note: Not as source code!)

Using PythonWorks

Page 44 of 87

More About Deploying Applications Note: You may not distribute uiToolkit as part of a generic Python distribution. If you want others to be able to develop programs using uiToolkit, they need to get a separate license from Secret Labs AB.

Deployment Details Create a .wpy script or let PythonWorks do that for you. This script should implement a method called action, which takes one argument (as shown below). The first example below builds a windows EXE file from all .py files. All other data files are just placed next to the executable. The second example shows you more ways to package your project. Note: getStandardCollections() also includes the auto-translated images, layouts, and sound modules in the py collection. Example 1 (File: build.wpy): # File: build.wpy STARTSCRIPT = "main" def action(context): name = context.getProjectName() py, dat = context.getStandardCollections() out = ResourceCollection(context, dat) out.add(MakeExecutable(py, name, start=STARTSCRIPT, console=1, runenv="py20")) SaveToDir(out, "c:/deploy") return "Build was a success!"

Example 2 (File: build.wpy): # File: build.wpy # # More verbose and advanced example. #SELECT ONE DEPLOY MODE BELOW. #mode = "SOURCE" #mode = "COMPILED" mode = "ARCHIVE" #mode = "EXECUTABLE" #mode = "SELFCONTAINED"

Using PythonWorks

Page 45 of 87

More About Deploying Applications def action(context): name = context.getProjectName() # include all python files except the project plugins. py = ResourceCollection(context, "*.py") py.remove("*-Plugin.py") original_files = py.add_autotranslated() # Add all the rest except py, wpy and autotranslated files dat = ResourceCollection(context, "*.*") dat.remove("*.py", "*.wpy", original_files) dat.add("example*.py", depth=0) out = ResourceCollection(context) if mode == "SOURCE": # as source code files out.add(py) elif mode == "COMPILED": # as compiled pyc files out.add(Compile(py)) elif mode == "ARCHIVE": # as squeezed py-file out.add(MakeArchive(py, name, start=STARTSCRIPT, console=1)) elif mode == "EXECUTABLE": # as windows exe-file out.add(MakeExecutable(py, name, start=STARTSCRIPT, console=1, runenv="pythonware_py20_win")) elif mode == "SELFCONTAINED": # include python in result out.add(MakeStandaloneDistribution(py, name, start=STARTSCRIPT, console=1, runenv="pythonware_py20_win")) out.add(dat) SaveToDir(out, "c:/deploy") return "Build was a success!"

Explanation: You first create a ResourceCollection and add and remove individual files or multiple files using wild cards. The add_autotranslated method means that the autotranslated files are also added to the collection. (See Autotranslate.) As you can see in the first example there are some convenience methods. getStandardCollections() gives you two ResourceCollections. One holding all source code and the other hold the remaining data resources. getProjectName() returns the name of the project. This is a good default name for the deployed resource. You can adjust the collections by adding and removing resources. The runenv argument to a translator tells PythonWorks which run environment to use for deployment. It can be any registered run environment. If you leave out the runenv argument to the translator then PythonWorks internal run environment will be used. You can repeat the procedure above for more advanced deployments. You can for example add txt-files to be output as-is or ship the test-script files as compiled python files etc.

Using PythonWorks

Page 46 of 87

More About Deploying Applications If the set of installed translators is not sufficient for your needs, you can write your own translator. For more information, see the Translate reference section. When you have populated a ResourceCollection, use the SavetoDir translator to output the result to a defined directory. You can replace SaveDir with you own functions to manipulate the resource collections in some other way e.g. ftp the files to a certain server. Example to save a ResourceCollection to disk. def DemoSaveToDir(resources, savedirectory, createdir=1, cleanupfirst=0): # if we use a resource collection, we need to # get its dictionary of resources if type(resources) != type({}): # the getresources method returns a dict # with resourcenames as keys and strings of # resourcecontents as values. resources = resources.getresources() for path in resources.keys(): data = resources[path] filename = os.path.join(savedirectory, path) savepath = os.path.split(filename)[0] if not os.path.exists(savepath): try: os.makedirs(savepath) except IOError: print "IOError", savepath file = open(filename, "wb") file.write(data) file.flush() file.close() register("translate", "DemoSaveToDir", DemoSaveToDir)

Using PythonWorks

Page 47 of 87

Run Environments

Run Environments A run environment is a description of which python interpreter, settings, and environment should be used when running user programs. The user can choose which one to use. The programs you run or trace will execute in a separate process to make a water-tight separation between your program and PythonWorks. This means if you are in the process of debugging your program and the program crashes, it won't affect PythonWorks. You can define multiple run environments. There is one prefined environment called internal, which is used as a default. In addition, PythonWorks provides a rich set of predefined run environments for common Python distributions, plus automatic generation of run environments for Jython and others:

The internal environment executes the program you run using the Python interpreter and libraries that PythonWorks installed (the same interpreter as PythonWorks itself uses). In PythonWorks Pro 1.3, this is a standard 2.1.1 interpreter with some extra libraries such as Tkinter, PIL, PST, SOAPLIB, and XMLRPC included. If you want to distribute your application and want to have a known and well defined python installation to go with your application, you can make a Using PythonWorks

Page 48 of 87

Run Environments StandAloneDistribution using PythonWorks deploy functions, or you can use a PythonWare Python kit from www.pythonware.com. The PythonWare kits are non-intrusive under Windows and do not modify the Windows registry. This means that you can have multiple Python installations and are able to select which one to use. You just run the setup script to setup the path to run Python. If you want to use another interpreter or include a number of other libraries or directories you can define your own run environment. See below. To create your own environment define a class similar to the one below and put it in a plugin file in your project (or in the SYSTEM project). PythonWorks method of storing environments as scripts has the advantage of being very dynamic. You can include code to be executed at runtime, automatically tayloring your setup to the current situation. class myRunenv: mode = "external" version = "21" command = "python -u" inheritenv = 1 env = {"PATH" : "c:\\py21\\", "PYTHONPATH" : "...", # fill in these if needed "TCL_LIBRARY":"...", ...} pyfiles = [ ("C:/py21", "lib/*.py"), ("C:/py21", "lib/lib-tk/*.py"), ("C:/py21", "lib/plat-win/*.py"), ("C:/py21", "PIL/*.py"), ("C:/py21", "PST/*.py"), ] sysfiles = [ ("C:/py21", "*.dll"), ("C:/py21", "DLLs/*"), ("C:/py21", "*.pth"), ("C:/py21", "tk8.3/library/*"), ("C:/py21", "tcl8.3/library/*"), ("C:/py21", "setup.bat"), ] register("runenv", "my env", myRunenv)

Set the mode, version, command, inheritenv, and env attributes to define your own run environment. To be able to deploy a standalone application kit you also must define the dllfile, pyfiles and sysfiles attributes (see example above). This allows the deployment script to find and build a kit, ready for shipping. You can select which profile to use to run/trace in the project settings dialogue (which can be accessed from the project homepage). Using PythonWorks

Page 49 of 87

Run Environments

Attribute Reference •

• •

• • •



• •

mode defines the type of run environment. It can be one of "internal", "external" or "remote". Internal is the default and uses the same setup as PythonWorks itself. External is used when you want to define your own custom profile. Remote is as of PythonWorks 1.3 not yet available, but defines an environment running on a remote machine, accessed over the network. version denotes version of the python interpreter used, without delimiting dots (for example "152" or "21") command specifies how to run the interpreter binary. Remember to specify full path if your Python directory isn't included in the profile path. Examples: r"c:\my_python\pythonw.exe -u", "/usr/local/bin/funkypython -ix -O", "pyth206f -i". args is a string containing arguments to be appended after the script name. None by default. inheritenv decides if you want to inherit the environment variables from the system. env is a tuple containing tuples with environment variable pairs (names, value). As default, no variables are added to the environment. dllfile specifies where to find the Python DLL (where applicable). Remember to specify full path if the directory isn't included in the profile path. pyfiles. Python scripts to include when deploying, given as a list of (root directory, subpath) tuples. sysfiles. Other files to include when deploying.

Using PythonWorks

Page 50 of 87

The Home Page

The Home Page The PythonWorks home page is the place where projects can be created or selected. To get there, just click the Home button. (If you have a project selected already, PythonWorks shows the project homepage instead. Select 'close project' to get back to the PythonWorks homepage.) Click on the name of an existing project to open that project. • Click on 'create project' to create a new one and open it. •

To change the name, click in the Title field and type in the new name. •

• •



• •

Use Set path to working area if you want to point your working area containing projects and user files to another location than the default position. This is normally a choice only done once before you start working with PythonWorks. The projects and files in the current location will not be moved or removed and you can return to them by redirecting the working area to the previous location. If you move the working area you need to execute the action loadsystem to get all the default system plugins installed in the new system project. Type works:loadsystem into the status field below the pad and press return. Use load license ticket to fully enable PythonWorks or to enable a new license. Use load sample projects to unpack the sample package in this working area. A few new projects will be created containing the demo-code. Click on show configuration to see a summary depicting the current status of PythonWorks. This includes information about host and platform, modules installed and their versions, current state, and the Python path. Clink on show packages for information about all installed packages and plugins. Click PythonWorks online to surf to the PythonWorks online web-page (from this point, you can also look at other web pages. However, the built-in browser is rather limited, so don't expect too much.)

Note that a few folders are created by default when you create a new project: images, layouts and sounds. These are used by PythonWorks' default auto translators. All image resources in the images subfolder will be translated into importable python modules. The same applies to sound and layout resources. The requirement is that the image and sound files are supported by the Python Imaging Library or PythonWare Sound Toolkit. See separate documentation for supported filetypes.

Using PythonWorks

Page 51 of 87

The Home Page You can also create your own translators. See the Autotranslations reference section for more information.

The Project Home Page If you press the home button in the pad window when you are within a project, the project homepage will be displayed. Here you can: • • • •

• • • • • • • • • •

Close project. Go to the PythonWorks homepage. Update resources. Update the workspace with the changes made by others. Commit resources. Save the changes made to the repository since the last commit. Project settings. Shows a dialog where you can set arguments to send to the program you run, options to the Python interpreter, which run environment to use, editor appearance and editor mode. Note: If you set these setting in the SYSTEM project they will be the default values for all projects. Just override the one you want to change locally in the project. Import. Shows a dialog where you can select files to import into the current project. Export. Shows a dialog where you select what files in the current project to export. Print. Shows a dialog where you can select files to print. Delete project. If you want to remove this project. Get example snippets. If you want to get an example or template. Show configuration to get information on the current configuration. Show active plugins to get information on the currently installed packages and plugins. PythonWorks online to surf to the PythonWorks online website. Set which python run environment to use to select a run environment profile. Set argument for program to send arguments to your programs.

Note: When working within a project these actions are also available from the project menu located above the project browser. See the About Projects and Workspace Browser reference sections for related information.

Using PythonWorks

Page 52 of 87

The Import Toolbox

The Import Toolbox Shows a dialog where you can select files that you want to import into the current project. You can select resource types based on extensions (group) or specify files by name. Use 'import to' if you want to import files to a subfolder in the project. Note: When you import a Python source file into PythonWorks it is tabbified and the indentation is normalized.

The Export Toolbox Shows a dialog where you select which files to export, and the directory they should be exported to (Copy from PythonWorks to the filesystem). You can select resource types based on extensions (group) or specify files by name. To create a new empty directory. Enter the name in the new dir entry field and press the button New dir:. The directory will be created as a subdirectory under the currently selected folder in the tree view to the left. Make sure that the directory you want to export to is selected before pressing the export button.

The Print Toolbox Shows a dialog where you can select files that you want to print. You can select resource types based on extensions (group) or specify files by name.

Using PythonWorks

Page 53 of 87

Searching

Searching The search system consists of a search entry field and a row of buttons which allow you to search in the: • • • • •

Reference Documentation (All installed doc-packages are searched.) Current contents of the pad. Current Project (Python and text resources in the project are searched.) Standard Library (path) (Python resources in the PYTHONPATH are searched.) Web Search (Searches using a remote search service. Click again for the next registered web location.)

To use the search facilities, just enter the search text in the field and press a search button. The result is presented as a list of links in the quick-info panel. The following control links may also be available: show only perfect hits/show all hits: If you have performed a multiple word search in the doc you can choose to show all hits or only the ones containing all words. A percentage is displayed next to each hit to tell you how accurate it was. • refresh: Updates the search. Can be used to update a search after modifying the resources in a pad (or project). • show/hide: Show or hide the hits for different documents. • replace with. Replace all occurrences of the search string. •

Certain bindings in the editor also give access to the search functions. Note: Documentation and web search is done using full word search, and case doesn't matter. The pad, project and lib searches matches on partial strings as well. If the search string is all lowercase, the search is case independent. However, if the search string contains one or more uppercase characters, PythonWorks does an exact case-sensitive search.

Using PythonWorks

Page 54 of 87

More About Directory Workspaces

More About Directory Workspaces The Directory Workspace The directory workspace is intended to provide a mechanism whereby an existing external project can be used in PythonWorks. Connecting to your project via a directory workspace allows PythonWorks to be aware of any external changes made to the project. This means that an external editor and or version management system can be used in conjunction with PythonWorks.

Connecting to a Directory Workspace The connection is setup at project creation by selecting the appropriate workspace from the list in the project creation dialog. Name your new project, select the directory workspace and click OK. You will then be asked to enter the path to your external directory. The majority of the usual PythonWorks operations are available within a directory workspace project. When using certain version management systems the project resources are read-only until they are explicitly checked out. The PythonWorks directory workspace is aware of this and resource state is indicated by an appropriate coloring of the resource name: • •

red indicates resources which are read-only. black indicates editable resources.

If the workspace gets out of sync, you can use the project >> refresh command to update the contents. Note: The directory you connect to might be very large, and a separate repository would occupy a lot of disk space. Thus, the repository feature is disabled for directory workspaces.

Using PythonWorks

Page 55 of 87

More About Perforce Workspaces

More About Perforce Workspaces Perforce workspace The Perforce workspace plugin (p4workspace) allows you to perform a limited group of the usual p4 client commands from within PythonWorks. PythonWorks version control does not yet support merging, therefore checking out a resource has the effect of locking it on the server until a commit is performed, or the checkout is revoked by a revert of the resource. A Perforce server and a small amount of knowledge concerning what's on the server are required to use the interface successfully. The Perforce software can be downloaded from www.perforce.com.

Terminology depot: The location of stored files on the Perforce server. • head revision: the last committed version of a resource. • versioned resource: a resource under Perforce versioning control. • unversioned resource: a new resource or a versioned resource which has been renamed and has yet to be committed. •

Connecting to a Perforce Workspace The connection is setup at project creation by selecting the appropriate workspace from the list in the project creation dialog. Name your new project, select the perforce workspace and click OK. Note: Selecting the Checkout on connect checkbox, causes PythonWorks to synchronise the project with the server upon project creation You will then be asked to fill in the required information for connecting to the Perforce server. If PythonWorks was able to deduce any information for you, some of the fields may already contain text. It is advisable to check them anyway. Connection details: P4PORT: A colon separated string containing the hostname and port of the Perforce server (e.g. server:1666) • USER: Your username or the username you use with the Perforce server



Using PythonWorks

Page 56 of 87

More About Perforce Workspaces •

DEPOT VIEW: Click browse to see what is available or write the connection path directly. The view corresponds to the depot which will be displayed in the PythonWorks workspace browser. (e.g. //depot/subfolder/...). The three dots are required, they represent a wildcard, i.e. everything below subfolder will be displayed in the workspace browser.

Once connected, if you did not select the Checkout on connect checkbox an update operation is needed for the PythonWorks workspace browser to reflect the contents of your chosen depot view. The state of the resources both locally and on the server is indicated by an appropriate coloring of the resource name: • • • • • • •

red indicates versioned resources which are read-only locally. black indicates new (unversioned) resources. green indicates versioned resources which have been checked out, and are therefore editable locally. bold green indicates versioned resources which you have edited. bold red indicates versioned resources which are checked out by another user and therefore locked on the server. bold blue indicates resources where a newer version is available on the server. light gray indicates that a commit is needed before the resource can be manipulated further.

Available Perforce Operations Operations on individual resources can be accessed via the right button popup menu in the PythonWorks workspace browser. Operations on the whole project can be accessed from the project homepage. Alternatively, all operations can be accessed from the appropriate menu at the top of the workspace browser.

Browser based Operations Once a project is under Perforce versioning control, four of the operations in the PythonWorks project browser popup menu allow interaction with the Perforce server. These are: Edit: Red resources (read-only) when initially selected are loaded into a read-only viewer in the pad. Selecting Edit from the popup menu of such a resource checks it out from the server for editing and locks the version on the server, to prevent access by other users. The resource name changes to green an its contents can now be edited. • Revert Changes: A resource which has been checked out for edit (green or bold green resource name) can be reverted to the last committed version on the server using this operation. The resource name will then return to red.



Using PythonWorks

Page 57 of 87

More About Perforce Workspaces Clone: A resource in any state can be cloned. The contents of the resource is copied to a new resource and _new is appended to the new resource name. You can edit the title field to rename it. The Perforce server is notified that this resource will be added to the depot at the next commit of the project • Delete Deleting a versioned resource deletes the head revision from the server and removes the local resource. Deleting a new or unversioned resource removes the local resource and informs the server that this resource will not be added to the depot. • Diff Diff of an edited (bold green) resource displays the differences to the head revision on the server. Diff of an updatable resource (bold blue) displays the differences of the head revision on the server to the version you have in your project. •

Operations can be undone and redone as earlier using the project menu at the top of the PythonWorks workspace browser. Note: Moving a versioned resource around within the project browser or renaming a versioned resource leads to a branching of the resource in the depot, and no further manipulation is possible until a commit is performed or the move is undone.

Homepage-based Operations Update: Retrieve the latest changes made to resources in the depot. • Commit: Submit your changes to the depot, allowing other users to access them. You are presented with a dialog box consisting of two parts. The upper text area allows you to enter a small description of the submission e.g. what you have accomplished with changes you've made. This description is required by the perforce server. The changes which to be committed can be seen in the lower area. The checkboxes indicate those resources that will be committed. Unchecking a box prevents that resource from being committed until the next time a commit operation is made. •

Note: You can double-click on a resource in this commit dialog to see what changes have been made compared to the repository. Note: When you do a commit the projects undo history will be cleared, even if it was only a partial commit.

Recovery If, for some reason, the interface ceases to function correctly, don't panic. There is a way out. Typing works:project-repair in the status field below the PythonWorks pad, or selecting project >> repair, will cause the project to be cleared, the connection refreshed and an update to be done. This Using PythonWorks

Page 58 of 87

More About Perforce Workspaces means the project will return to the last committed state. This is a last resort, and any pending changes you have made will be lost!

Using PythonWorks

Page 59 of 87

Plugins Reference

Plugins Reference Action Plugins action This is a command that runs inside PythonWorks. All internal commands are created as actions. To create an action inherit from works.Action and override the do method. See example "PythonTemplate-Plugin.py" in the demo project. Actions can be run from the status prompt, used by other actions or installed for example in the iconbar or as a bookmark.

Autotranslate Plugins autotranslate This installs a handler for a new translation type. Currently available types are images, sounds, and layouts. All resources of a defined type placed in these autotranslation folders will be processed by a translator before running or deploying the application. (Normally used to convert a special type of resource into a python resource for easy use.) See the Translate reference section for how to define a translator. Example: Create a -Plugin.py file and place it in your project. register( "autotranslate", ("images", "im"), ("image/*", "text/python", "MakeImage") )

This means: Register an autotranslate handler named ("images","im") to convert all image resources to python resources in folder images using the translator function MakeImage. To access an autotranslated resource from your project just import it. Example: Access a few autotranslated resources: # get an image called myimage from images import myimage

Using PythonWorks

Page 60 of 87

Plugins Reference im = myimage.image # PIL Image object im.save("test.png") from sounds import mysound snd = mysound.sound # PST Sound object snd.play() from layouts import mylayout frame = mylayout.UI(master, target) # Tkinter Frame object frame.pack() # Note: target is an interface object that gets called on events # from the user interface. See the layouteditor documentation for # details.

Bindings Plugins bindings This is the installed collection of keyboard bindings for the editors in the system. For the texteditor and the pythoneditor there are installed verions of Notepad-like bindings and Emacs-like bindings. You can define and add your own set of bindings for editors/viewers here.

Bookmark Plugins bookmark You can register an entry in the bookmark list. There are three kinds of things you can register as bookmarks. A PythonWorks command (See list of installed commands in show configuration) • A document bookmark. • A web-url. •

Example: Create a bookmarks.wpy file and add lines similar to these. # File: bookmarks.wpy register("bookmark", "Print All", "works:print-assistant") register("bookmark", "Modules Index", "info:python-libraryreference/modindex") register("bookmark", "Zoo", "http://www.zoo.com")

Using PythonWorks

Page 61 of 87

Plugins Reference This means: The first bookmark executes a PythonWorks command named print-assistant when clicked. The second shows a certain chapter in the documentation when clicked and the last registers a bookmark named Zoo that will show the web-page www.zoo.com when clicked.

Editprefs Plugins editprefs This registers editor preference profiles. You can then switch between the installed ones in project settings dialog on the project homepage. The example below contains the default values for all the parameters you can change. To make your own preference profile just create a .wpy file similar to the example below. Use reload actions to activate the changes. Note: You don't have to list all the attributes if you don't want to change them. The ones you omit will be assigned default values. Se example 2 below.

# File: editprefs.wpy class MyPrefs: COLOR = "black" # local constant background = "white" # the background color in the editor foreground = "black" # the default text color in the editor alternatebackground = "#ffe8e8" # background color when tracing readonlybackground = "light yellow" default_font_size = "8" # the default font size to use default_font_name = "Verdana" # the default font to use index_color = "light blue" # (tmp variable) indexline_color = index_color # the color on the margin separation lines selection_color = "gold" # the background color for selected text longline_color = "yellow" # the color of the longline marker # cursor cursor_color = "red" cursor_offtime = 300 cursor_ontime = 600

# the cursor color # the cursor off-time. use to set blink interval # the cursor on-time. use to set blink interval

# syntax coloring: # takes 1 or 2 arguments. The first is the color, must be a color defined # in the Tk color database or given as a hex number: #RRGGBB

Using PythonWorks

Page 62 of 87

Plugins Reference # the second optional argument is the font to use # The font is given as a string with font name, [size and [modifier]] # ('bold' or 'italic') or just the modifier. normal = COLOR # color and font for normal text symbol = COLOR # color and font for symbols integer = COLOR # color and font for integers token = COLOR # color and font for tokens keyword = COLOR, "bold" # color and fonts for Python keywords keyword_def = COLOR, "bold" # color and fonts for 'def' statement keyword_class = COLOR, "bold" # color and fonts for 'class' statement declaration = "firebrick", "bold" # color and fonts for names import_symbol = "firebrick" # color and font for imported module names builtin_symbol = "#771717", "bold" # color and font for builtin symbols special_symbol = COLOR, "bold" # color and font for special symbols string = "navy" # color and font for normal strings longstring = "navy" # color and font for long strings comment = "dark green", "italic" # color and font for commented text index = index_color, "{Helvetica} 8" # color and font for margin info tabsize = None # tab size (in pixels). use None for a default size margin = 40 # the size of the left margin (in pixels) register("editprefs", "my favorite", MyPrefs)

Example 2: # File: small_example.wpy # make the cursor navy blue class CursorColor: cursor_color = "navy" register("editprefs", "Blue Cursor", CursorColor)

Extension Plugins extension This is used to make PythonWorks recognise new file types based on their extension. A number of standard extension types are predefined. (See show configuration on the homepage in PythonWorks.) Here are a few examples to register new file types. register("extension", "frm", ("text/plain", "t")) register("extension", "mid", ("audio/midi", "b"))

Using PythonWorks

Page 63 of 87

Plugins Reference This example registers files with extension ".frm" as text files and extension ".mid" as binary midi files. The "t" stands for text and "b" stands for binary file. Note: You can use a user or unsupported MIME-type here as long as you install a handler for that resource type too. See the Resource Plugin reference section for details.

Iconbar Plugins iconbar Define mappings from buttons in the icon bar, to named action scripts. The icons (or text labels) will appear in the icon bar. Example: register("iconbar", "print-assistant", ("MY-PRINT", "Print resources"))

This means: Register an action called print-assistant in the iconbar that is given the internal name MY-PRINT, and has the tooltip "Print resources". Note: If the name (e.g. "MY_PRINT") is already in use by an installed icon button, that icon is shown instead. There's no way to install your own icons in the current version of PythonWorks.

Importer Plugins importer You can register a filter for each resource type. This filter is run on the resources as they are imported into PythonWorks. Could be useful to cleanup indentation in Python files etc.

Using PythonWorks

Page 64 of 87

Plugins Reference

Layout Plugins layout Additional widgets can be installed using this plugin. They can then be used in the layout editor.

Package-Doc Plugins package-doc If you have a documentation package *-doc.pak, place it in a project and PythonWorks will use it. It should appear in the list of reference documents.

Package-Ico Plugins package-ico Ico packages contain a set of icons. If you have an icon package *-ico.pak, place it in a project and PythonWorks will use it.

Package-Kit Plugins package-kit Kit packages can include extensions to PythonWorks and software distibution packages. If you have a source code package *-kit.pak, you can place it in a project and PythonWorks will use it.

Package-Src Plugins package-src Source packages can contain data files and scripts. If you have a source code package *-src.pak, place it in a project and PythonWorks will use it.

Using PythonWorks

Page 65 of 87

Plugins Reference

Package-Sys Plugins package-sys System package registry. In the current version of PythonWorks, the standard plugin loader adds system packages to PythonWorks. To install a system package (a file ending with *-sys.pak), place it in the SYSTEM project. Note: System packages usually contain compiled Python code which are linked into the PythonWorks environment, and can be used for patch releases as the package replaces previous functionality.

Resource Plugins resource If you want works to view/edit/handle a new resource type you must register an extension (see above) and register a new resource type and finally tell works which viewer and editor to use for this resource type (see below). You may be able to use a predefined editor/viewer or maybe you must write a special editor for this resource type. Here is an example snippet for how to create a new resource. Subclass from a Resource type and override the needed methods. Below is an example that defines the DTML-resource to behave exactly as the HTML resource. class DTMLTextResource(HTMLTextResource): _type = "application/x-zope-dtml" register("resource", "application/x-zope-dtml", DTMLTextResource)

You also need a resource viewer and a resource editor for the new data type.

Using PythonWorks

Page 66 of 87

Plugins Reference

Resource-Editor Plugins resource-editor When you register a new resource type you must also register a resource viewer. Example: Registers the DTML type to use the myHTMLEditor. register("resource-editor", "application/x-zope-dtml", myHTMLEditor)

Resource-Viewer Plugins resource-viewer When you register a new resource type you must also register a resource viewer. Example: Registers the DTML type to use the worksHTMLViewer. register("resource-viewer", "application/x-zope-dtml", myHTMLViewer)

Runenv Plugins runenv A run environment is a description of which python interpreter, settings, and environment should be used when running user programs. The user can choose which one to use. For more information, see the section on Run Environments.

Using PythonWorks

Page 67 of 87

Plugins Reference

Search-Uri Plugins search-uri You can register additional web search sites, provided they accept search terms in the URI. Each time you press search web the next URI from the registry will be used. Here is an example: register( "search-uri", "PythonWare search", "http://search.atomz.com/search/?sp-q=%s&sp-a=sp10011d41" )

This means: Register a search-uri called 'PythonWare search'. The uri to send is http:.... The %s in this string is replaced by the search words separated by '+'.

Template Plugins template This kind of plug-in registers an example template. PythonWorks includes several standard templates, including templates that show how to create plugins and other PythonWorks-specific files. Example: demo_template = ''' # This is a demo template. ''' class DemoTemplate: '''This is a demo example.''' _type = "text/python" data = demo_template register( "template", "demo template example", (DemoTemplate._type, DemoTemplate) )

The user can fetch templates from the project homepage via the link get example code snippets.

Using PythonWorks

Page 68 of 87

Plugins Reference

Translate Plugins translate Translators have two uses. One is to convert the items for an installed autotranslator (e.g MakeImage converts image files into python modules). The second is to convert files that are going to be deployed (e.g convert from .py to .pyc files if you want to deploy compiled pyc-files). There are also more advanced translators such as MakeExecutable that takes .py files and turn them into a Windows exe-file. A translator function takes a dictionary, or an object with a method getresources() that returns a dictionary, with resource names as keys and resource contents in string form as values. Some translators take other arguments to do their work. Your translator should return a dictionary containing the resulting resources. Example: The following translator converts py to pyc files def DemoCompile(resources, extension=".pyc"): if type(resources) != type({}): resources = resources.getresources() new_resources = {} for name in resources.keys(): codestring = resources[name] codeobject = compile(codestring, name, 'exec') fp = coreStringIO.StringIO() fp.write(imp.get_magic()) fp.write(i32(int(time.time()))) data = marshal.dumps(codeobject) fp.write(data) new_name = os.path.splitext(name)[0] + extension new_resources[new_name] = fp.getvalue() return new_resources register("translate", "DemoCompile", DemoCompile)

Workspace Plugins workspace

Using PythonWorks

Page 69 of 87

Plugins Reference

A workspace controls your project inside PythonWorks. It is responsible for the local workspace as well as being connected to a repository. The standard workspace has a simple backup directory as a repository but other workspace plugins could use fully-fledged version control systems to back you up. PythonWorks Pro 1.3 includes support for the Perforce version control system. See the More About Perforce Workspaces reference section for more information. PythonWorks Pro 1.3 also provides a workspace named directory workspace. This is intended for users who would like to run PythonWorks in “sidekick mode”, e.g. for using an alternate version management system or an external editor in conjunction with PythonWorks. See the More About Directory Workspaces reference section for more information.

Editor Details The editor is affected by the two plugin types named bindings and editprefs (editor preferences). The keyboard bindings and editor preferences can be set using the project setting dialog on the project page. Note: You can make your own bindings by defining your own bindings plugin, or editor preferences using the editprefs plugin.

Using PythonWorks

Page 70 of 87

Text Editor, Notepad Bindings

Text Editor, Notepad Bindings Mouse Bindings • • • • • •

Left click move the cursor to that position. Left click and drag to select a piece of text. Left click in margin selects one line. Left click and drag in margin to select a number of lines. Left double-click on word selects that word. Right click for cut n paste popup menu.

Keyboard Bindings Navigation: • • • • • • • • • • • • • • • • •

LeftArrow: move left RightArrow: move right UpArrow: move up DownArrow: move down Home: move to beginning of line End: move to end of line PageUp: page up PageDown: page down Control-LeftArrow: one word back Control-RightArrow: one word forward Control-UpArrow: scroll up Control-DownArrow: scroll down Control-Home: move to beginning of file Control-End: move to end of file Control-PageUp: page up Control-PageDown: page down Alt-g: goto line (dialog)

Editing: • • • • • • • • • •

Return: insert line break Backspace: delete character to the right Tab: insert tab Delete: delete character to the left Control-Backspace: delete word to the left Control-Delete: delete word to the right Alt-x Alt-o: delete blank lines (emacs style) Alt-o: delete all but one space Alt-t: transpose characters Alt-x Alt-t: transpose lines

Using PythonWorks

Page 71 of 87

Text Editor, Notepad Bindings Alt-u: make word/selection UPPERCASE • Alt-l: make word/selection lowercase • Alt-c: Capitalize word/selection •

Selections & cut and paste: • • • • •

Control-x: cut Control-c: copy Control-v: paste Control-a: select all Escape: select none

Extending selection: • • • • • • • • • • • • • • • •

Shift-LeftArrow: extend left Shift-RightArrow: extend right Shift-UpArrow: extend one line up Shift-DownArrow: extend one line down Shift-Home: extend to beginning of line Shift-End: extend to end of line Shift-PageUp: extend one page up Shift-PageDown: extend one page down Shift-Control-LeftArrow: extend one word back Shift-Control-RightArrow: extend one word forward Shift-Control-UpArrow: extend one line up Shift-Control-DownArrow: extend one line down Shift-Control-Home: extend to beginning of file Shift-Control-End: extend to end of file Shift-Control-PageUp: extend one page up Shift-Control-PageDown: extend one page down

History: Control-z: undo • Control-y: redo



Editing mode: •

Insert: toggle insert/overwrite mode

Searching: F1: search-info • Control-s: search buffer • Alt-s: search project • F2: search lib •

Using PythonWorks

Page 72 of 87

Text Editor, Notepad Bindings Pad Management: • • • • •

Alt-x Alt-x Alt-x Alt-x Alt-x

o: 0: 1: 2: 3:

next pad close pad close other pads split pad horizontally split pad vertically

Using PythonWorks

Page 73 of 87

Python Editor, Notepad Bindings

Python Editor, Notepad Bindings The basic bindings are the same as for the Notepad Text Bindings. Only the differences are described here.

Mouse bindings •

Left double-click in margin to select a section

A section can be: a code block (if clicked on an indented block.) a method/function (if clicked on a def line.) • a class (if clicked on a class line.) • a comment block (if clicked on a comment line.) • the entire file (if clicked on a unindented or empty line.)

• •

Keyboard bindings Navigation •

Alt-p: move to corresponding parenthesis

Editing • • • • • • • • •

Backspace: delete character to left (dedent indentation) Return: line break (smart indentation) Space: space (space is not allowed in indentation) Tab: indent line/selection Shift-Tab: dedent line/selection Alt-Space: (un)comment selection Control-Tab: (un)comment selection Shift-Control-Tab: (un)comment selection Control-Return: complete word (use keywords, builtin names, modules and names in the current file).

Miscellaneous Alt-h: select section Control-F1: summary overview • F5: execute • •

Using PythonWorks

Page 74 of 87

Text Editor, Emacs Bindings

Text Editor, Emacs Bindings PythonWorks contains a set of very extensive Emacs bindings. Almost all of the standard Emacs keys are there and even the most demanding Emacs guru will feel right at home. Besides the different keymap, there's a couple of things the Emacs bindings does differently, just to get that special Emacs feel: To mark text, you might want to set an anchor (Control-Space) and then just move the cursor to select the desired text. • Once selected, text is not killed on insert. Pressing the Delete key will erase the selection. • The clipboard has a history, flip thru it with Alt-y (yank-pop). • Escape is meta (alt). •

Mouse bindings • • • • • •

Left click move the cursor to that position. Left click and drag to select a piece of text. Left click in margin selects one line. Left click and drag in margin to select a number of lines. Left double-click on word selects that word. Right click for cut n paste popup menu.

Keyboard bindings Navigation: • • • • • • • • • • • • • • • • • •

LeftArrow: move left RightArrow: move right UpArrow: move up DownArrow: move down Home: move to beginning of line End: move to end of line PageUp: page up PageDown:: page down Control-LeftArrow: one word back Control-RightArrow: one word forward Control-UpArrow: scroll up Control-DownArrow: scroll down Control-Home: move to beginning of file Control-End: move to end of file Control-PageUp: page up Control-PageDown: page down Control-b: move left Control-f: move right

Using PythonWorks

Page 75 of 87

Text Editor, Emacs Bindings • • • • • • • • • • • •

Control-p: move up Control-n: move down Control-a: move to beginning of line Control-e: move to end of line Control-v: page up Alt-v: page down Alt-f: one word forward Alt-b: one word back Alt-: move to end of file Control-l center line Alt-g: go to line (dialog)

Editing: • • • • • • • • • • • • • • • • • • •

Return: insert line break Backspace: delete character to the right Tab: insert tab Delete: delete character to the left Control-d: delete character to the left Control-Delete: delete word to the left Alt-Delete: delete word to the left Control-Backspace: delete word to the left Alt-d: delete word to the right Control-o: insert line break in front of cursor Control-x Control-o: delete blank lines (emacs style) Alt-Space: delete all but one space Control-t: transpose characters Control-x Control-t: transpose lines Alt-u: make word/selection UPPERCASE Alt-l: make word/selection lowercase Alt-c: Capitalize word/selection Control-x Control-u: make word/selection UPPERCASE Control-x Control-l: make word/selection UPPERCASE

Selections & cut and paste: • • • • • • • • •

Control-space: set selection anchor Control-x Control-x: swap cursor and selection anchor Control-w: cut selection Alt-w: copy selection Control-y: paste Alt-y: cycle through clipboard history (after paste) Control-x h: select all Control-g: remove selection and abort current key-sequence Control-k: kill line (emacs style)

Extending selection (a la Notepad): Using PythonWorks

Page 76 of 87

Text Editor, Emacs Bindings • • • • • • • • • • • • • • • • •

Escape: select none Shift-LeftArrow: extend left Shift-RightArrow: extend right Shift-UpArrow: extend one line up Shift-DownArrow: extend one line down Shift-Home: extend to beginning of line Shift-End: extend to end of line Shift-PageUp: extend one page up Shift-PageDown: extend one page down Shift-Control-LeftArrow: extend one word back Shift-Control-RightArrow: extend one word forward Shift-Control-UpArrow: extend one line up Shift-Control-DownArrow: extend one line down Shift-Control-Home: extend to beginning of file Shift-Control-End: extend to end of file Shift-Control-PageUp: extend one page up Shift-Control-PageDown: extend one page down

History: F9: undo Shift-F9: redo • Control-Shift-_: undo • Control-Shift-/: undo • •

Editing mode: •

Insert: toggle insert/overwrite mode

Searching: F1:: search-info • Control-s: search buffer • Alt-s: search project • F2: search lib •

Pad Management: • • • • • • •

Control-x Control-x Control-x Control-x Control-x Control-x Control-x

o: next pad 0: close pad 1: close other pads 2: split pad horizontally 3: split pad vertically s: sync resource Control-s: sync resource

Using PythonWorks

Page 77 of 87

Python Editor, Emacs Bindings

Python Editor, Emacs Bindings See the Emacs Text Bindings section for basic bindings. Only the differences are described here.

Mouse bindings •

Left double-click in margin to select a section.

A section can be: a code block (if clicked on an indented block.) a method/function (if clicked on a def line.) • a class (if clicked on a class line.) • a comment block (if clicked on a comment line.) • the whole file (if clicked on a unindented or empty line.) • •

Keyboard bindings Navigation • •

Alt-p: move to corresponding parenthesis Alt-m: move to indent

Editing • • • • • • • • •

Backspace: delete character to left (dedent indentation) Return: line break (smart indentation) Space: space (space is not allowed in indentation) Tab: indent line/selection Shift-Tab: dedent line/selection Control-c Control-c: (un)comment selection Control-Tab: (un)comment selection Shift-Control-Tab: (un)comment selection Control-Return: complete word (use keywords, builtin names, modules and names in the current file).

Miscellaneous Alt-h: select section • Control-F1: summary overview • F5: execute •

Using PythonWorks

Page 78 of 87

Changes From Earlier Versions

Changes From Earlier Versions Changes in 1.2 • • • • • • • • • • • • • • • • • • • •

Uses Python 2.0 as the internal interpreter. Support for multiple pads, and multiple views in each pad Multiple python process support (Server-client development). New workspace plugin ("directory workspace"). Handles file syncronisation with external editors/version control systems. New tabstrip provides rapid access to recently used resources. Added more menus, to make available functions more visible. Performance improvements to editor and workspace browser. Simple class/module browser ("Summary view"), for navigation within a module. Import single file command. New functions in editor: capitalize, uppercase, lowercase, goto line. Word-completion in editor. (keywords, standard module names, builtin names and words in the current file.) Progress bar for update etc. Multiple untitled projects allowed. User configurable menus. Goto file/line by double-clicking on exception line in console or tracer windows. Esc followed by key is handled as Alt-key in emacs mode. More keybord shortcuts such as (F5) to run current resource. Improved dialogs. Updated documentation. Plus a lot of other improvements and bug-fixes.

Using PythonWorks

Page 79 of 87

Changes From Earlier Versions

Changes in 1.3 • • • • • • • • • • • •



Jython support. You can develop, run, and debug programs written for Jython/JPython 1.0, 1,1, 2.0, 2.1, and later. Improved support for newer Python versions. 2.1, 2.2 etc. This release uses Python 2.1.1 internally. Much improved user interface builder (layout editor) for Tkinter/uiToolkit. The main editor pad can be split, with subpads either on top of each other, or side by side. New functions such as built-in PyChecker, diff, etc. Much improved Emacs/Notepad-style editor bindings. The editor now highlights matching parentheses. Current line/column and selected editor mode is displayed in status line. New project settings panel. Speed improvements, most notable to the tracer and editor. New and improved menus. A rich set of predefined run environments for common Python distributions, plus automatic generation of run environments for Jython and others. An on-line version of Fredrik Lundh's "Python Standard Library" book is available as part of the help system.

Using PythonWorks

Page 80 of 87

PythonWorks License Agreement

PythonWorks License Agreement IMPORTANT, READ THIS CAREFULLY! USE OF THE SOFTWARE PYTHONWORKS IS SUBJECT TO SECRET LABS LICENSE TERMS BELOW. YOU SHOULD THEREFORE CAREFULLY REVIEW THE FOLLOWING TERMS. BY DOWNLOADING AND USING THIS SOFTWARE, YOU INDICATE YOUR ACCEPTANCE OF THESE TERMS AND THIS DOCUMENT THEN CONSTITUTES A BINDING AGREEMENT BETWEEN YOU, YOUR COMPANY AND SECRET LABS AB. Your use of Pythonworks, any associated media, printed materials and "online" or electronic documentation (the "Software") is governed by the following terms. 1.1 Grant of License. a. Software Secret Labs grants you as an individual a personal non-exclusive license to make and use copies of the Software for the sole purposes of designing, developing, and testing your software product(s). You may install copies of the Software on an unlimited number of computers provided that you are the only individual using the Software. If you are an entity, Secret Labs grants you the right to designate one individual within your organization to have the right to use the Software in the manner provided above. b. Electronic documents Solely with respect to electronic documents included with the Software, you may make an unlimited number of copies (either in hardcopy or electronic form), provided that such copies shall be used only for internal purposes and are not republished or distributed to any third party. c. Storage/Network Use You may also store or install a copy of the Software on a storage device, such as a network server, used only to install or run the Software on your other computers over an internal network, provided that the Software is only used by one individual. A license for the Software may accordingly not be shared or used concurrently on different computers.

Using PythonWorks

Page 81 of 87

PythonWorks License Agreement 2. Other Rights and Limitations a. Limitations on Reverse Engineering, Decompilation, and Disassembly You may not reverse engineer, decompile, or disassemble the Software, except and only to the extent that such activity is expressly permitted by applicable law notwithstanding this limitation. b. Separation of Components. The Software is licensed as a single product. Its component parts may not be separated for use on more than one computer, with the exception of those components which in the accompanying documentation are explicitly stated as redistributables. c. Rental You may not rent, lease, or lend the Software. d. Software Transfer You may permanently transfer all of your rights under this License Agreement, provided you retain no copies, you transfer all of the Software (including all component parts, the media and printed materials, any upgrades and this License Agreement), and the recipient agrees to the terms of this License Agreement. If the Software is an upgrade, any transfer must include all prior versions of the Software. e. Termination Without prejudice to any other rights, Secret Labs may terminate this License Agreement if you fail to comply with the terms and conditions of this License Agreement. In such event, you must destroy all copies of the Software and all of its component parts. 3. Upgrades If the Software is labeled as an upgrade, you must be properly licensed to use a product identified by Secret Labs as being eligible for the upgrade in order to use the Software. A Software labeled as an upgrade replaces and/or supplements the product that formed the basis for your eligibility for the upgrade. You may use the resulting upgraded product only in accordance with the terms of this License Agreement. If the Software is an upgrade of a component of a package of software programs that you licensed as a single product, the Software may be used and transferred only as part of that single product package and may not be separated for use on more than one computer.

Using PythonWorks

Page 82 of 87

PythonWorks License Agreement 4. Copyright All title and copyrights in and to the Software (including but not limited to any images, photographs, animations, video, audio, music, text, and "applets" incorporated into the Software), any accompanying printed materials, and any copies of the Software are owned by Secret Labs or its suppliers. The Software is protected by copyright laws and international treaty provisions. Therefore, you must treat the Software like any other copyrighted material except that you may install the Software on a single computer provided you keep the original solely for backup or archival purposes. You may not copy the printed materials accompanying the Software. 5. Dual-media Software You may receive the Software in more than one medium. Regardless of the type or size of medium you receive, you may use only one medium that is appropriate for your single computer. You may not use or install the other medium on another computer. You may not loan, rent, lease, or otherwise transfer the other medium to another user, except as part of the permanent transfer (as provided above) of the Software. 6. Export Restrictions You agree that neither you nor your customers intend to or will, directly or indirectly, export or transmit the Software or related documentation and technical data or process, or service that is the direct product of the Software, to any country to which such export or transmission is restricted by any applicable regulation or statute, without the prior written consent, if required, of such governmental entity as may have jurisdiction over such export or transmission. 7. Applicable Law This License Agreement is governed by the laws of Sweden. 8. Limited Warranty Secret Labs warrants that (a) the Software will perform substantially in accordance with the accompanying documentation for a period of ninety (90) days from the date of receipt, and (b) any hardware accompanying the Software will be free from defects in materials and workmanship under normal use and service for a period of one (1) year from the date of receipt. 9. Customer Remedies Secret Labs' and its suppliers' entire liability and your exclusive remedy shall be, at Secret Labs' option, either (a) return of the price paid, or (b) repair or replacement of the Software or hardware that does not meet Secret Labs' Limited Warranty and which is returned to the supplier with a Using PythonWorks

Page 83 of 87

PythonWorks License Agreement copy of your receipt. This Limited Warranty is void if failure of the Software or hardware has resulted from accident, abuse, or misapplication. Any replacement Software or hardware will be warranted for the remainder of the original warranty period or thirty (30) days, whichever is longer. NO OTHER WARRANTIES TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, SECRET LABS AND ITS SUPPLIERS DISCLAIM ALL OTHER WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH REGARD TO THE SOFTWARE, AND ANY ACCOMPANYING HARDWARE. NO LIABILITY FOR CONSEQUENTIAL DAMAGES TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL SECRET LABS OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE, EVEN IF SECRET LABS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

Using PythonWorks

Page 84 of 87

Index

Index B

H

bindings emacs 75 bookmarks 61 breakpoints 42

help search 54 home page 51 project 52

C

I

changes from version 1.2 79 from version 1.3 80 close project 12, 13 create resource 15

import multiple resources 21 import resource 20 import toolbox 53

J

D debugger breakpoints 42 debugging 24, 42 delete resource 16 deploy program 44 directory workspace

E editor 36 layout 37 preferences 62 python 36 text 36 editor bindings emacs 75 editor preferences 62 edit resource 15 emacs 75, 78 export multiple resources 22 export resource 22

Using PythonWorks

jython

6, 48, 80

L 13

layout editor license 81

37

N notepad

74

O open project

12

P pad window 28 paste resource 20 perforce 14, 56 Page 85 of 87

Index client 56 clone 58 commit 14, 58 delete 58 diff 58 edit 14, 57 recovery 58 revert 57 submit 14, 58 sync 58 synchronize 14 update 58 perforce workspace 14, 56 plugin 34 action 60 autotranslate 60 bindings 61 bookmarks 61 category 34 documentation package 65 editor bindings 61 editor preferences 62 editprefs 62 extension 63 filename extension 63 icon bar 64 icon packages 65 import 64 keyboard bindings 61 layout 64 resource 66 resource editor 66 search path 35 search URI 67 software kits 65 source packages 65 system packages 65 template 68 translator 68 workspace 69 print multiple resources 18 resource 18 toolbox 53 print resource 18 program debug 24 deploy 25, 44 run 23 stop 23 project 10, 11, 32 Using PythonWorks

close 12, 13 create 13 home page 52 open 12 python editor 36 python version 23 select 23

R remove resource 16 rename resource 16 repository 10 resource 15 create 15 delete 16 edit 15 editor plugin 66 export 22, 53 import 20 paste 20 play 23 plugin 66 print 18 remove 16 rename 16 run 23 search 54 view 17, 67 runenv 48, 67 run environment 48, 67 run environment select 23 run program 23

S scratch pad 12 search 54 software license 81 software license 81

T text editor

36 Page 86 of 87

Index tracer 42 translator plugin

68

V view resource

17, 67

W

help 30 info 30 pad 28 workspace directory 13 perforce 14, 56 plugin 69 standard 13 workspace directory workspace plugin 69

10

window

Using PythonWorks

Page 87 of 87