Home

BlackAdder user manual

image

Contents

1. DE the KOMPAN Yeom BlackAdder Manual 1 Introduction BlackAdder is designed to allow you to rapidly build professional applications using the popular Object Oriented Python scripting language A key component of BlackAdder is PyQt a GUI library that allows you to rapidlycreate cross platform applications Linux and Windows currently PyQt is a set of Python bindings for the popular Qt user interface library and includes the qt module standard set of Qt widgets qtcanvas a module that provides a highly optimized 2D graphic widget qtnetwork which allows you to quickly create client server implementations qttable a module for quickly creating big tables and operations with them qtxml XML rendering engine that provides a well formed XML parser using the DOM Level 2 Document Object Model We ve included our powerful PyQtDoc application which allows you to quickly and easily navigate through hundreds of classes and functions BlackAdder supports syntax highlighting for a variety of languages most importantly Python With the new project wizards you can rapidly generate a skeleton of your GUI in addition we ve included Qt Designer as a Form Editor for BlackAdder Qt Designer is a high level tool for designing user interfaces with the PyQt library The Form Editor will help you build a user interface with layout tools that allow you to move and scale your widgets controls in Windows terminology
2. The Add folder dialog allows you to create a new folder in your project or whole chain of subdirectories You just need to write the name of a folder starting with a file system separator or all subdirectories like folder1 folder2 folder3 all non existing directories will be created 4 12 9 Add class 7 New class ies Class AdvancedWidget Super class Qwidget a File name Jadvancedwidget py Reimplement S QWidget m i adjustSize 2 O contextMenuEvent O customWhatsThis fe O dragLeaveEvent 2 O dragMoveEvent O dropEvent O enabledChange z O focusOutEvent J fontChange i Pw ese ear e tat 7 This dialog provides a wizard as a simple method to create a new class or sub class it from your existing classes or just from PyQt classes You need to enter the name of a new class and file of where to save the class note that if the file already exists it will not be overwritten the class will be just be appended to the existing file A combo box for super class support has auto completion so you can enter the first few letters of a class press Enter and navigate with the arrow buttons up down to select the class you want to sub class Below is a dialog that shows a list of virtual functions you can reimplement in your new class note that not all functions in the PyQt library are virtual because it is not possible with bindings to Qt C library where not all functions are vir
3. A good shortcut is to use Ctrl L when you need more space for editing Show hide bottom panel show hide bottom panel with messages and Python console shortcut Ctrl D Help menu provides information about the IDE and help for working with BA About dialog that provide info version of IDE copyright and credits Sub classing opens help browser with instructions about subclassing in BlackAdder Please see section below if you want to read more about subclassing Using Qt Designer open help browser with instruction about using Form Editor in BlackAdder Please see section belove if you want to read more about using Form Editor 4 2 Toolbars First look at tool bars amp B Jon Bl en XE BR w GS oe hareio You can see that the tool bar has 5 parts The first part pertains to operations with files such as new new project new form open file or project and save Note one useful thing you can have quick access to recent files and projects by pressing the right part down arrow of Open tool button See screen shot below fee fhomeyshurik projects opfiles opfiles pra Fa fhomeyshurik projects aciock aclock pra Fa homey shurik projects buttongroups buttongraups pro E fhomeyshurik projects myproject life pro homey shurik projects opfiles mydialogimpl py fhameyshurik proajects aclock aclock py homey shurik projects myproject life py fhomeyshurik projects buttongroups buttongroups p
4. do something Create a main py to start our app Run our new application o N OQORAR OON 3 2 Getting Started Start the process by launching BlackAdder BA on Windows you do this in the normal manner clicking on the icon on your desktop On a Linux based os you type ba at a command prompt in X Windows 3 3 Creating a new project Once BA has launched choose menu Project gt New Project This will launch the New Project dialog which allows you to create a new project from scratch In the name field type myfirstapp Notice that BA will fill in the other two fields for you Click Next In the next step select the Empty template click Finish 3 4 Creating a form Now you have been presented with a screen displaying an empty project Choose menu item Project gt Add Form This will display the New Form dialog which asks you to choose a form template Choose the Dialog template and type MyFormBase ui in the File Name field at the top of the dialog Then click Ok In the project view on the left hand side of BA you will see your new form Double click on the form in the project view This will launch BA s customized version of QT s designer 3 5 Finishing your form You should now have a blank form open in Designer From the toolbox on the left drag thre controls onto the form a PushButton a LineEdit and a TextLabel Arrange them any way you would like and then select each one and make the following prope
5. editor switch to next editor in list of opened files Next editor switch to previous editor in list of opened files Search Project Run Tools Options gt Find Ctrl F gt Find Next F3 3 Search in files Ctri Alt F 7 Replace Ctri R 6o to Line Ctrit G Search menu contains actions for searching in text searching in files goto to line Find open search dialog for searching first occurrence of text Find Next searching next occurrence of search text Search in files open dialog for searching in files Output of results of searching will be in message panel you can just clicking on results for quickly jump on file See more info in Dialogs sections Replace replace dialog Go to line move the cursor to a specific line number Project Run Tools Options V New New fram example _ Open project Open recent project Project menu contains actions for working with the files in a project New creates a new project Opens the new project dialog where you can select or create a directory where the project will be placed project name and project file name XML file where will be stored all info about your project After these settings you can select a type for your project and start a wizard to generate Python files if they are available New from example opens dialog where you can select existing predefined example project All files
6. from In this case if you wanted to re implement methods in QDialog or QWidget you could easily do that For now change the text in the Class field to MyForm and uncheck the _tr option in the Reimplement view and then click Ok You should see your new class appear in the Project view 3 8 Making it do something Now we need to write some code Open up our implementation by double clicking on the MyForm class in the project view This will open up the class in an editor window You will notice that there is an __init__ method already defined At the end of that method add the following code connect self talk SIGNAL clicked SLOT slotTalk So that the entire __ init__ method looks like this def anit self args apply MyFormBase __init__ self args self connect self talk SIGNAL clicked self slotTalk This connects the clicked signal of the button on our form to a slot we will add in a moment NOTE Depending on your tab settings you may have to tweak the indentation of the code that existed already Next create a new method in this class with the following code def slotTalk self self output setText self edit text 3 9 Finishing up Now we need to put the finishing touches on our application Start by right clicking on the project in the Project view this is the top level item and looks like four colored blocks and selecting Add main py A dialog will appear asking you to c
7. if debug session was stoped on some breakpoint Single step execute one line of Python code It will enter in body of function if Python code of the function Is in current project and can be opned Step over execute one line of Python code but without entering in called functions Stop debug stop debugging session Set Clear breakpoint set or remove breakpoint on current editor line Note that you can use shortcut Ctrl B do it quickly Select target selecting target file that will be executed in Python interpreter when you run debug a project Tools Options Window Help Form Editor PyQt Documentation Tool menu contains actions for execute tools distributed with BlackAdder Form Editor run Form Editor Qt Designer PyQt Documentation run PyQt documentation system PyQtDoc application Options Window Help Options menu contains actions for configuring editors and IDE Configure main IDE options as selecting directory where your projects located path to Python interpreter and pyuic converter Select style sub menu for selecting style of application widgets Configure editor editor options as font indent and etc Window Help show hide left panel Gtri L Show hide bottom panel GCtri tDO Window menu contains actions for show hide BA panels Show hide left panel show hide left panel with project fileexplorer
8. Grand Theft Auto Vice City Microsoft Visual Studio 6 0 MS Office NetworkSimplicity Norton Antivirus Corporate Edition Realtek Sound Manager Startup theKompany i Ready to Install Click the Next button to install Python 2 3 or the Back button to change choices Install directory C Python23 Doing admin install Make backups into C Python23 BACKUP Components Python interpreter and libraries Register file extensions Start Menu group Python 2 3 Cancel 1 6 Wait while Python 2 x installs its own components then click Finish 2 Python 2 3 Installation python for Windows 2 Install PyQt 3 7 2 1 Uninstall any previous version of PyQt and make sure you have Python installed 2 2 Download from your download basket and run PyQt 3 7 YYMMDD Python2 x exe 2 3 Click Next gt Welcome to the PyQt Installation Wizard lis strongly recommended that you exit all Windows programs before running this setup program Click Cancel to quit the setup program then close any programs wou have running Click Next to continue the installation WARNING This program is protected by copyright law ard International treaties Unauthorized reproduction or distribution of this program or any portion of it may result in severe civil and criminal penalties and Will be prosecuted to the maxinurn extent possible under law PyQt has been successfully installed Click the Finish button to exit thi
9. Office org ybin build s Egpropects Bpublic_html jtmp Ework E newtorm ui m UserManual sxw m Jsvno0 swn Jzvit shura 200308 doc Root Directory S 3 a Operations with files S mainpy main py 2 5 mydialog ui mydialog py g MyDialog z g init 2 gP languageChan E mydialogimpl py 8 MyDialogimp D init E So you can add folders or files to a project directory note that files will be copied to the project directory if they are in another place create new class or subclass from an existing one add form and add main py similar to function main in C the operation will ask you for Main Window form and then generate small file with code similar to the following import sys from gE import from aclock import AnalogClock a QApplication sys argv Il AnalogClock w show a connect a SIGNAL lastWindowClosed a SLOT quit a exec_ loop This is standard Qt code that allow you to initialize the PyQt library and run the main form of your project You can all call the project options dialog here Right clicking on a folder will show you next menu Mew Folder Add files f Add Class Remove fram project Close project lt has the same operations as a project item like new folder add files and add project Also it has the action remove from project note that it will not delete the directory from your file system Note that when
10. alog for creating new action where you can specify action text variable name for QAction element option is the action toggled action pixmap hotkey and connect it to slot Almost all elements support auto completion from entering name of action You will need specify class of Main window filename for the class EST ol Add menu File Edit Options Help B Add toolbar Add Action Open Class name MyClass Generate i Python file File name myclass py Documents Class name MDIWindtow ot ssts lt Ss Ul file Ska a Type of central widget QTextEdit hd 5 Run x Use status bar x Use text label on tool bars from qt import import sys TRUE 1 FALSE 0 class MyClass QMainWindow def init self narent None name None fl 0 4 12 Dialogs 4 12 1 New Form File name home yshurik newform ui eat T Dialog with Dialog with Dialog Buttons Buttons Right oontdialog ui Bottom dialogright ui dialogbottam ui Fam ter f il Main Window Tab Dialog Widget widget Wizard wizard mainwindow ui tabdialog ui ui ui The new form dialog allows you to select a template for your form and select a file name of where to save the user interface file After clicking Ok Form Editor Qt Designer will be run 4 12 2 Find Text to find Options O Case sensitive CI Whole words only UI Erom cursor LI In selected area O Regular expression The Find di
11. alog is standard and very easy to use Just type the text you are looking for and check the options that you need You can use accelerators to quickly select options that you need for example you can switch check box Case sensitive with Alt C 4 12 3 Search in files Searchinfiles ea els Directory home yshurik work ba examples 2 File pattern py e Search for MDIApp Options O Whole word x Case sensitive C Regular expression Da we search in files allow you to search through a set of files using regular expressions In the dialog you can select a directory where you want to search file pattern and search text or regular expression You can also use options to search for a whole word case sensitive option if the search text is a regular expression The yellow status line shows you the file where the search is currently Search results will output in a message panel as seen below homeyshurik projects mdi mdi py E w MDIWindow selfws Ot WDestructiveClose 36 Qt s Multiple Document Interface MDI O Class MDIWindow QMainWindow mw setCaption PyGQt Example Multiple Documents Interface MDI homeyshurik projects mymai madi py E w MDIWindow selfws Ot WDestructiveClose As you can see after searching for the word MDI there is a full report in the message file about the files and lines that contained the searched for text You can j
12. arita CA 92688 USA For questions regarding purchase and pricing please contact us at sales thekompany com or phone 949 713 3276 6 6 Product support theKompany com is offering support contracts for all its products As part of your support contract you will receive 24 hour turn around on your initial request Our support services are broken into two categories developer tools and desktop applications For each category there is one of three support tiers Per Incident Personal Annual and Corporate Annual As an introductory offer the Personal Annual support contract for desktop applications is being offered at half price and will include any and all products that come out in this category even if they are released after you purchase your contract Pricing is as follows Per Incident 15 USD Personal Annual 99 USD for Developer Tools Personal Annual 49 95 USD for Desktop Applications Corporate Annual 3 000 USD which includes up to 10 registered users You can purchase support with any of our supported Credit Cards a personal check a money order electronic wire bank draft or Purchase Order All forms of payment subject to funds clearing before the contract is activated Credit Cards contracts are approved immediately 7 Authors BlackAdder Oleksandr Yakovlyev Dmitry Poplavsky Igor Skrygun PyQt Phil Thompson PyQtDoc Oleksandr Yakovlyev PyQt Documentation Oleksandr Yakovlyev Igor Skrygun Aleksander Kravch
13. ates you can select At the top you need to specify file name of your new form The form will be added at the top of projects tree If you want to add a new form to some folder in the project you need to use the right button menu on project folder in project panel Just after clicking Ok button it will opens Form Editor where you can advance the form template Note that these templates are stored in usr local ba templates Linux or C Program Files BA templates Windows Each template has three files png with a snapshot image of template ui form with template form and text file with descriptions that you are seeing in new form dialog Options opens projects options Now options dialog contains project name and target file that will be executed in Python interpreter when you will run debug project Run Tools Options Window Help E 7 Run current file Debug file Run Gontinue execution Ctri F5 4 Single step F p Step over FF Set Clear breakpoint CtritB Run menu contains actions to run Python scripts projects or debug them Run project execute current project Output of application will be outpututed in Message panel Run current file execute current editor file in Python interpreter Debug file start debug session with file opened in editor Debug project start debug session of current project Run Continue execution start execution or continue
14. automatically at runtim The PyUic convertor allows you to easily convert files with form interfaces to Python code with no effort on your part With BlackAdder you can easily subclass Qt and your custom designed classes BlackAdder is a powerful editor and IDE with many features that will allow you to build cross platforms applications faster than you ever thought possible Detailed information about the product is in the following pages 2 Installation 2 1 Linux Requirements On Linux you will need a working X11 system this is typically installed by default with any system using a windowing interface such as KDE or Gnome but note that neither of these desktops are required All the libraries required to run BlackAdder are included in thekompany support package which are distribution independent but you will need to install the version that best applies to your system You will need to have Python version 2 2 or later installed as well Python is not supplied with BlackAdder but is freely available from www python org For Linux you need to download and install these packages thekompany support BlackAdder PyQt These packages have the following naming convention packagename version builddate rpom or packagename version builddate tar gz For example BlackAdder 1 0 030828 rpm illustrates that it was built on August 28 2003 The PyQt packages will have a suffix such as py22 ucs2 py22 ucs4 py23 ucs2 py23 ucs4 It mean that
15. ct a folder where the application will be installed The Wise Installation Wizard will install the files for Blackadder in the following folder To install into a different folder click the Browse button and select another folder You can choose not to install BlackAdder by clicking Cancel to exit the Wise Installation Wizard Destination Folder C Program Files 6 4 Browse Wise Installation Wizard crcl 3 5 Click Next gt to begin installation 3 6 Click Finish 51x BlatkAdder BlackAdder has been successfully installed Click the Finish button to esit this installation DE the Kompany com 4 Back Eancel 2 3 Starting BlackAdder To run BlackAdder on Linux you just need to run ba in a console ba or ba myfile py if you want to start BlackAdder with a specific file in this case myfile py On Windows you need just run the shortcut Start gt Programs gt theKompany gt BlackAdder gt BlackAdder 3 Quick start guide 3 1 Introduction We are going to create a small and relatively useless application to demonstrate how the tools in BlackAdder make developing professional applications in PyQt easy Here is the process we will be following Create a new project Add a form to the project Place controls on the form Turn the form design into a python class Derive from the class to create an implementation Add code to our derived class to make our application
16. d adage Sl OpenOffice org Toul arate tlds hoet o anie i p build eppen a a i i projects E3 public_html Eam o Ee e New project dialog allows you to create your new project and use a set of wizards released with BlackAdder to quickly generate skeleton code for your project The first page of the wizard contains next a number of things you need to enter such as project name the name of the project that will be shown in the list of projects in project panel Project directory this is the directory where all the files in your project will be stored note that you can t have files part of a project outside of the directory only files included in the directory and subdirectories and the name of the file where the project paramater XML note that the project file also will be included in the project directory Here you can see an example of what it looks like 215 x Select type of project Available types Empty 102 103 class ApplicationWindow Mail 104 def init self 105 i QMainWindow __ init 106 107 self filename Q5tr 108 self printer QPrin 109 110 111 112 113 114 115 116 117 118 115 120 Dialog App 1 wid zil Dialog App 2 Dialog App 3 c conor App as QWhatsThis whatsThis Multi Document App 123 QWhatsThis addiself 124 QMimeSourceFactor 125 QWhatsThis addis Single Document App 126 JWhatsThis add The n
17. d line above with it will also add an indent backspace indent is an option if all indent space can be cleaned with one backspace Smart home is options for behavior of action on pressing Home button If the options checked then first press of Home will set cursor at first non space symbol of line not to just first symbol of line Replace tabs allows you to change tabs to spaces The word wrap option applies to opening files if the option is set then new editor window will be opened with word wrap Note that Menu gt Editor gt Word wrap applies to current editor document only new files will be opened in word wrap mode from the dialog option 5 Using Qt Designer 5 1 Creating forms Creating a form in BlackAdder is very simple There are two ways first is just create from without project then you need to just click on New Form on the tool bar it will open a dialog where you need to select a filename and an existing template for the form A second way is when you have a project opened then you can create a new form from the project menu or by right button popup menu on projet panel you need press the right button on the folder item or on project After New Form dialog Form Editor will be executed 5 2 Export forms from other projects You can use forms from other C Python projects without restrictions It is the same ui file interface created with Qt Designer so it is no problem importing user interface from
18. eated with pyuic Here you can enter the name of your new class and select a list of virtual functions which you want to reimplement You can open a tree of inheritance and see all the functions that you can reimplement at virtual functions PT zox Class MyDialogimp Super class fo My Dialog X File name Reimplement geMyDialog o 2 E tri O language Change S QDialog Step 5 After these operations you will have the following structure of classes 9 oro 8 8 Operations with files al main py 2 E mydialog ui i mydialog py i MyDialog of init__ E ga language Change E mydialogimpl py My Dialogimp a ga init 6 Questions and answers 6 1 Known bugs and bug reporting lf you have found a bug or have a feature request that you want to see in an upcoming version of BlackAdder you can post it in our bugtracking system Mantis online bug reporting system to tell us about the bug This is the fastest and easiest way to let us know about it and to provide us with the needed information to fix it as quickly as possible Mantis bug reporting system https www thekompany com mantis login_page php Use this for reporting all bugs to us for any theKompany com software both commercial software and open source projects Mantis documentation https www thekompany com mantis doc documentation html If you need help using Mantis use the link above Just type in your browser https www
19. es a new form from template and edits it with the Form Editor Open opens an existing file Open recent small submenu for opening recent files Close close current document Save save currently open document Save as save document under new selected name Save all saving all currently opened documents Exit just quit application If you have modified documents BlackAdder will prompt you to save them Edit Search Project Run Tools Of m Unde Ctritz ja Reda Ctrit Shittt Z jae Cut Ctri X Lr Copy Ctri c Paste Ctrl V Select All CtritaA Y Indent Ctritl Unindent Ctritu Word wrap F2 Prev Editor Alt Lett Next Editor Alt Right Edit menu contains editor actions Undo revert the most recent undo operation in editor Redo revert the most recent editing actions in editor Cut cut the selected text and move it to clipboard Copy copy selected text to clipboard Paste paste previously copied or cut clipboard contents Select All select entire text of current document Indent use this to indent a selected block of text Unindent use this to unindent a selected block of text You can configure whether tabs should be honored and used or replaced with spaces in configuration dialog Word wrap use this command to wrap all lines of the current document which are no longer the width of current view Prev
20. ext page allows you to create the type of project Depending on the type you select BlackAdder will run a wizard where you can select options for generating code for your files 4 12 7 New project from example Examples elie Project folder home yshurik projects my project test A PyQOtDoc Examples A Complete Application Window with Actions A Directory Browser A MDI Application A Rectangle Draw Benchmark A Tiny Example Featuring a Toggle Action A Tiny QTL Example A simple demonstration of QFant member functions Advanced use of tool tips Analog Clock Biff Buttons and Groupboxes Canvas Example Connect the Points Cursors Digital Clack Draw Demo Font Displayer Hello World How to create a large sparse OTable loonview Layout Managers a Life qame hi The dialog provide you a clean and quick way to start from a template In the dialog you can select an existing template we use templates from PyQt examples select a directory where the files of your project will be put After clicking on Ok the files will be copied to the directory and your project will be opened in BlackAdder This is a good way to study PyQt for the first time you can create your first projects from the examples study the Python code and change what you need 4 12 8 Add folder Folder You can create set of subfolders when enter Molder folder2 begins it from it is relative to project directory newfolder i
21. g for creating new action where you can specify action text variable name for QAction element option is the action toggled action pixmap hotkey and connect it to slot Almost all elements support auto completion from entering name of action You will need specify class of Main window filename for the class document class name and sub class it from existing class BA Wizard Dialog with Buttons alala xi Include Buttons button name newButton1 button text New Button 1 Add button This is a preview your Dialog Add spacer Remove i Up Down BA Wizard Dialog with Tabs 21 Ci x Include Tabs tab1 tab2 Tab text tab1 Add tab This is a preview your Dialog Cancel next gt gt TTT ox Add menu File Edit Add toolbar Class name MyClass Generate Python file File name myclass py Ul file Documents Class name MDIWindow a Type of central widget QTextEdit ad Run xX Use status bar x Use text label on tool bars from qt import import sys TRUE 1 FALSE 0 class MDIWindow QMainWindow def init self parent name wflaas Y 4 11 5 Single document application The wizard is like same as wizard for multi document wizard It help you quickly create skeleton of main window of your application Here you can quickly adds menu items separators tool bars and tool buttons for tool bars When you adding some new active element it shows di
22. g the Form Editor Qt Designer chapter The subclassing approach for more info about enhancing forms 4 6 Classes window Python parser The window shows contents of currently editing file It is list of classes amp and functions When you will click on class name or function name then rrr cursor in editor will jump to the line of code Belove you can see list of T ceeacues opened files Clicking to filename will switch editors tab to the file and you ke init will continue editing with the file Contents of file is updating with each 5 timeout second so the window follow to your changes in editor A Bea m init 4 7 Debugger window In debug window you can see values of variables in python debug session There are two windows for local variables and for global variables Also you can navigate through python debugger frames with romaryshurik project sack buttons on top stack of calls Some variables can be opened to values E E inside value S 8m self j main_ Analog Globals Value Ha lt qt QApplication i 4 8 Messages window print system path NameErrar name system is not defined i Vhome yshurik Yusrlib python2 2 fusr lib python2 2 plat linux2 usr lib python2 2 lib tk usr lib python2 2 Message window allow you see output of your python scripts and errors of python interpreter Small button with icon on bottom right corner allow you clean the windo
23. hoose your main form you will want to select our implementation called MyForm and choose Ok 3 10 Testing our creation Now that we re done let s test what we have made Click the Run button on the toolbar When asked to choose the target pick main py If all has gone well you will see the form that we created in designer If not review the output to determine the cause of the error hint check for indentation or a problem with the name of a class Enter some text in the line edit and then click Talk You should see your text displayed in the label on your form 3 11 Summary You ve now written a complete application in PyQt Granted this is very simple but it does demonstrate many of the concepts needed to build your own applications More thorough examples are provided with BA in the examples directory 4 Overview 4 1 Menu BlackAdder has a main menubar and popups menus on context items The main menu has standard items such as File Edit Search Project Run Tool Options Window and Help All these menus can be accessed by Alt first_symbol_of_menu for example you can quickly access the File menu with Alt F keyboard shortcut File Edit Search Project Run 1 New Ctri N 1 E New Form Open Ctri O Open recent Close Ctrityw lal Save Ctri S Save as Save all Exit Ctrit Q File menu contains actions for standard operations as New creates a new empty file New Form creat
24. nfigure Z Configure ais Directory contains BA projects home y shurik projects python interpreter usr bin python A pyuic converter usr bin pyuic A The configure dialog will allow you to change various IDE variables as a directory for your projects All new projects you will create will be at default stored in the directory You can also set the file name of the Python interpreter and pyuic converter if the default are not found 4 12 14 Configure editor Configure editor ajoj x Edit Options ix Auto indent quertyuiop x Backspace indent QWERTYUIOP 1234567890 x Smart home C Wrap cursor x Indicator Margin x Replace tabs x Line Number Margin O Selection Margin Other O Vertical selection Tab width a E ie Remove trailing spacer Ix Word Wrap In this dialog you can select the behavior of the BlackAdder editor You can select the font of editor text margins which you want to see indicator margin that shows breakpoint icons line number margins and selection margin you can select blocks of texts with margin and use drag and drop to move blocks Below you can select tabulation width and options for vertical selection not too useful for Python coding but can be useful in some situations Edit options contains group of indent options auto indent first text symbol of new line starts at same position as line above but if you en
25. ng on it Here is an example By right mouse clicking you can switch to tree mode which is the second interface to do copy paste delete insert file or directory in current project and reload current directory if there are new elements Our next file style is Tree Mode this is where you can expand or collapse directory structures by clicking on the icon next to the name or double clicking on the name While this is useful for certain types of operations it can create a cluttered view as well 4 5 Project window When you start BlackAdder and switch to the Project panel you can see a list of names of recently opened projects You can open one of them by double clicking If you want to remove a bookmark you can do it with a right button click and remove it from the list of recent projects After opening a project you will see a tree where on the top level you see the name of a project root and a tree like list of files and folders from it Right button click on the root of a project to allow to do the following New Folder Add files i Add Class A Add Form Add main py Options Close project D 8 a a G OpenOffice org bin build projects public_html UserManual sxw svnOO svn zvit shura 200308 doc S Groen B E Analog Clock Buttons and Groupboxes Life game 9 Operations with files Qe S B a Home Directory Backup Desktop yDocuments Mail 6 Open
26. o the directory just created and run the install script as root user cd packagename install sh 2 2 Windows Installation of BlackAdder 1 0 for Windows 9x Me NT 2000 XP To install BlackAdder you need to install Python 2 x and PyQt 3 7 1 Install Python 2 x 1 1 Download Python 2 x from http www Python org and run the Python 2 x exe 1 2 Choose a directory where you want install Python 2 x then click Next gt 2 Python 2 3 Installation python for Windows C Python23 Eg Cygwin 9 Documents and Settings 9 Program Files Cg Prthon22 amp at C Recycled Eg System Volume Information E temp E windows 2 Python 2 3 Installation python for Windows 1 3 Select the Python 2 x components and click Next gt Make sure that Python interpreter and libraries are selected s Python 2 3 Installation Select Components Choose which components to install by checking the boxes below J Python interpreter and libraries 9203 k IV TclTk Tkinter IDLE pydoc 5444 k J Python HTML docs 12455 k J Python utility scripts Tools 575k J Python test suite Lib test 2726 k Disk Space Required 30403 k Disk Space Remaining 20819000 k Advanced Options Cancel Select Start Menu Group Enter the name of the Start Menu program group to which to add the Python 2 3 icons Python 2 3 Accessories ACD Systems Administrative Tools
27. of the project will be copied to directory you will set so you can start very quickly Note that these predefined projects are stored in usr local ba examples Linux or C Program Files BA examples Windows Each directory contains Python files pro file XML project and text file with description of the project the text you are seeing New from example dialog Open project open project dialog Open recent project small popup menu with list of recently opened files Close project close currently opened project Note that the operation does not close your opened files Add files adds files to current project It opens the file select dialog You can select multiple files by dragging the mouse or just with Shift or Ctrl Add folder adds a new folder to project If you type in a dialog name of a non existing folder it will be created You can type a name with directory separators and the entire chain of sub directories will be created Add class opens new class dialog Here you can subclass an existing qt class or one you previously created You can also just type in the dialog select virtual functions you want to reimplement The dialog has a combo box where you can specify a new file name or just select existing files where the class will be added As super class you can select existing Qt class or yours Add form adds new form to your project It opens dialog with templ
28. other projects 5 3 Extending the functionality of a form First let s look at a small figure that shows the relationship between ui files generated code and application code file C Documents and Settings Administrator My Documents make_cd BlackAdder designer1 png Qt Designer reads and writes ui files e g form ui The user interface compiler pyuic creates an implementation file e g form py from the ui file The application code in main py imports a form Typically main py Is used to instantiate the QApplication object and start off the event loop While this approach is simple it isn t sufficient for more complex dialogs Complex dialogs tend to have quite a lot of logic attached to the form s widgets more logic than can usually be expressed with predefined signals and slots One way of handling this extra logic is to write a controller class in the application code that adds functionality to the form This is possible because pyuic generated classes expose a form s controls and their signals to the public space The big disadvantage of this method is that it s not exactly Qt style If you were not using Qt Designer you would almost always add the logic to the form itself where it belongs This is why the capability of adding custom slots and member variables to a form was added to Qt Designer early on The big additional benefit with this approach is that you can use Qt Designer to connect signals to those cus
29. plication with buttons at bottom The wizard allow you quickly create a dialog with 212151 x Include Buttons bottom line of some buttons All just you need it is enter text for buttons and order them on bottom line Use Left and Right to move buttons Also you can adds spacer items for splitting groups of buttons Next page will allow you specify name of class and filename of form ox _ancet_ New Button 1 button name newButton1 button text This is a preview your Dialog 4 11 2 Dialog application with buttons at right The wizard allow you quickly create a dialog with right line of some buttons All just you need it is enter text for buttons and order them on bottom line Use Up and Down to move buttons Also you can adds spacer items for splitting groups of buttons Next page will allow you specify name of class and filename of form 4 11 3 Dialog application with tabs The dialog helps you create application based on tabbed dialog for example some small dialog for configurable section Here you can simply adds new tabs and move them for order what you want Next wizard page allow you specify name of class and filename 4 11 4 Multi document application The wizard help you quickly create skeleton of main window of your application Here you can quickly adds menu items separators tool bars and tool buttons for tool bars When you adding some new active element it shows dialo
30. rty changes on the property editor located on the right hand side of the screen Control Property New Value Name MyFormBase Form o Caption My First PyQt Application Text Talk PushButton Name talk LineEdit Name edit Text Empty String TextLabel Name output Once these changes are complete close out of Designer choosing Yes when asked if you want to save your changes 3 6 Compiling your form You will now switch back to the main BA window In the project window on left hand side of the screen right click on the form you created and choose Generate py with pyuic This will take the xml file created by Designer and turn it into executable code You won t modify this code however because when you make changes to your form this code will be overwritten Instead you will want to create a new python class that inherits from this new one that BA has created for you which you can then add your implementation code to We will cover this in the next step 3 Creating a form implementation To create a form implementation class right click on the MyFormBase dialog in the project view and choose inherits You will be presented with the New Class dialog This dialog is allowing you to derive from an existing class in this case the python implementation of our form It also allows you to override methods in the base classes that your class derives
31. s installation 3 Install BlackAdder 1 0 3 1 Download from download basket and run BlackAdder 1 0 YYMMDD exe 3 2 Click Next gt 3 3 Read license and if you agree with the license agreement select I accept the license agreement then click Next gt jig BlackAdder Setup Ioj xi License Agreement You must agree with the license agreement below to proceed CONTRACT between you either an individual or a single entity and TheEomparny com Ine theRompany com which covers your use of either BlackAdder and related software components All such software is referred to herein as the Software Product A software license and a license key or serial number Software Product License issued to a designated user only by TheEompany com Inc of its authorized agents is required for each concurrent user of the Softurare Product If you do not agree to the terms of this EULA then do not install or use the mofturare Product or the Softurare Product License By explicitly accepting this EULA you are acknowledging and agreeing to be bound by the following terms 1 EVALUATION LICENSE WARNING can probably drop this whole paragraph a f accept the license agreement f do not accept the license agreement Reset z Back Cancel Wise Installation Wizarde 3 4 Choose a directory where you want to install BlackAdder 1 0 then click Next gt BlackAdder Setup loj x Destination Folder Sele
32. signer forms FormBase and their subclasses Form This made a lot of sense because they always subclassed and were using those subclasses in application code 5 5 Step by step Step 1 You have created your form in Qt Designer You include the form in your project or create with Project gt Add form You need to generate a Python implementation of the form To do it press the right mouse button on the ui file in the project panel and select Generate py with pyuic B opr H amp S S Sr 8 a 8 Operations with files a main py S Ei mydialog ui Open in Form Editor Generate py with pyuic Inherits Remove fram project Delete the file Close project Step 2 Now you can see in the project panel sub item maindialog py It is implemented as a sub item for splitting your project files and generated files Useful when projects have a lot of forms and your Python files S Sree 8 E 8 Operations with files main py E mydialog ui 8 mydialog py Step 3 You have created an implementation file You need to sub class the class of the designer form To do it press the right mouse button on ui file in project panel and select Inherits S Grr 8 E 8 Operations with files F main py Sij mydialog ui i mydialog Open in Form Editor Generate py with pyuic Inherits Remove from project Delete the file Close project Step 4 Now you see a small wizard for subclassing classes cr
33. the package can be used for Python2 2 or Python2 3 Python can be compiled in 2 variants with unicode support ucs2 all text symbols have 2 bytes or with Unicode support ucs4 all text symbols have 4 bytes the variant used in RedHat 9 0 You can check how Python was compiled with ucs2 or ucs4 in this file usr include python pyconftig h define Py UNICODE_SIZE 2 Or define Py UNICODE_SIZE 4 About installing PyQt from tarballs Unpack it and run install script as root user It will ask you for PREFIX where Python was installed Typically it is just usr but if you built Python manually then it could be something like usr local Enter your path or press enter if it is usr For installing roms you need to use the rpm utility from your linux distribution Note that PyQt from thekompany can conflict with any installed PyQt from your distribution Free Edition so you need to remove it before installing the BlackAdder version Also make sure to remove all previous packages of BlackAdder thekompany support and PyQt If you have purchased PyQtDoc perviously you need to remove the package because the application is already included in BlackAdder For example rpm i thekompany support 1 2 030828 rpm BlackAdder 1 0 030828 rpm PyQt 3 7 030828 suse82 rpm To install the tar gz package you need to unpack the contents to temporary directory with the following command tar zxf packagename version builddate tar gz Go t
34. thekompany com mantis login_page php register there and post your bug or feature request 6 2 BlackAdder maillist For communication with other BlackAdder users or developers you can use our maillist ba thekompany com where you can talk about your ideas or questions with other users and our BlackAdder developers For subscribing you need check http Awww thekompany com mailman listinfo ba 6 3 BlackAdder PyQt forum For exchanging information we created a PyQt forum where you can post your problem or just search for existing problems and solutions Also we are posting announcements and news to the forum You can access the forum at http Awww thekompany com pyat 6 4 Where to find more information As you can see ahead you can read our maillist and our pyqt forum There is PyKDE maillist which is related to sip pyqt pykde problems only There is also a book about PyQt programming but related to old beta4 of BA You can access it online at http www opendocs org pyat There are few a articles that you can find on official site of PyQt Check http www riverbankcomputing co uk articles php 6 5 How to buy BlackAdder You can order BlackAdder applications from http www thekompany com products blackadder We accept payment by Credit card VISA American Express Mastercard Discover Check US or international Checks and order forms can also be sent by ordinary mail to theKompany com PO Box 80265 Rancho Santa Marg
35. tom slots in the same elegant graphical way that is used to connect signals to predefined slots The uic then adds an empty stub for each custom slot to the generated form py implementation file The big question now is how to add custom implementation code to those custom slots Adding code to the generated form py is not an option as this file gets recreated by pyuic whenever the form changes and we don t want a combination of generated and handwritten code There is an alternative solution which we ll cover next 5 4 The subclassing approach A very clean way to implement custom slots for generated forms is via Python inheritance as shown in the next figure file C Documents and Settings Administrator My Documents make_cd BlackAdder designer2 png Here the user wrote an additional class Formlmpl and the implementation file formimp1 py The file imports the pyuic generated form and reimplements all the custom slots This is possible because uic generated custom slots are virtual In addition to implementing custom slots this approach gives the user a way to do extra initialization work in the constructor of the subclass and extra cleanups in the destructor Because of these benefits and its flexibility this approach became the primary way of using Qt Designer in Qt 2 x Note To keep the namespace clean most users did not follow the Form and FormImpl naming scheme shown in the figure but instead named their Qt De
36. tual but in the list are shown only virtual functions that you can reimplement If you scroll down the list you will see a super class which you can open and see their functions which you also can reimplemnt 4 12 10 Add form File name T Dialog with Dialog with Dialog Buttons Buttons Right confdialog ui Bottom dialogright ui dialogbottam ui tam i oe Gare ll Main Window Tab Dialog Widget widget Wizard wizard mainwindow ui tabdialog ui ui ui C e a F ate The Add form dialog allows you to select a template for your form and select a file name for your user interface file After clicking on Ok the Form Editor Qt Designer will be started Differences in the New Form dialog are that you don t need to enter the whole path to the file you need to just enter the short name After you click on Ok the file will be added to the project 4 12 11 Project options Project options Progect name Operations with files Run target main py ey sare we This dialog will allow you to change the project name and target file that will be executed in Python interpreter when you will run debug project 4 12 12 Select target Target 2lolx main py mydialog py mydialogimpl py select target dialog contains a list of project files You need to select a file that will be executed when you run your project or when you start debugging your project 4 12 13 Co
37. uk lt yshurik thekompany com gt lt dima thekompany com gt lt bender thekompany com gt lt phil lt yshurik thekompany com gt lt yshurik thekompany com gt lt bender thekompany com gt lt krav thekompany com gt riverbankcomputing co uk gt
38. un Alt RP Run project Alt RF Run current file Alt RI Debug file Alt RR Debug project Alt RE Run Continue execution Alt RS Single step Alt RO Alt RT Alt RB Alt RA Alt T Alt TF Alt TP Alt O Alt OC Alt OS Alt OE Alt W Alt WL Alt WB Alt H Alt HA Alt HS Alt HU Step over Stop debug Set Clear breakpoint Select target Tool Form Editor PyQt Documentation Options Configure Select style Configure editor Window Show hide left panel Show hide bottom panel Help About Sub classing Using Qt Designer The following key bindings are also available file operations Ctrl N New Ctrl O Open Ctrl W Close Ctrl S Save Ctrl Q Quit editor operations Ctrl Z Undo Ctrl Shift Z Redo Ctrl X Cut Ctrl C Copy Ctrl V Paste Ctrl A Select all Ctrl l Indent Ctrl U Unindent F2 Word wrap Alt Left SWitch to previous editor Alt Right switch to next editor Ctrl F search text FoS Find next Ctrl R Replace Ctrl G Go to line run debug operations F5 run current project or curent file if no opened project Ctrl F5 run continue execution F6 Single step F7 Step over Ctrl B Set Clear breakpoint workspace operations Ctrl L Show Hide left panel Ctrl D Show Hide bottom panel 4 11 Wizards 4 11 1 Dialog ap
39. ust click on a line in the message panel and it will open BlackAdder with that text available 4 12 4 Replace Replace Text to find vasya hi Replace with Pupkin hd Options x Case sensitive O In selected area Whole words only From cursor position O Regular expression Replace All The Replace dialog will allow you to search and replace text in your file Just enter the text you want to replace and the text to replace it with You can select a variety of options such as matching case limiting the range of search etc If you enter a regular expression in to the text window then that will be processed instead of a literal translation It is still possible to use Undo to cancel this operation 4 12 5 Go to line Goto line aloj xl Line number 453 Y z Go to line dialog allow you to quickly jump to an existing line with some number Note that you can use the features bye pressing Ctrl G gt Enter line number gt press Enter this combination allows you to very quickly jump through text 4 12 6 New project Project name and destination Name Fieop sis Project directory he yshurik projectsifileop Project file name fleoppro Lat lt count la mame Z oclasees ire si Home directory Ta Pile nanm lower lclame_s rint clamm_ nar i i atl Backup chari l o H Deskto lt i i E P r Ha Documents DOC writs i c aligr i i Tout w BCei E
40. w 4 9 Python console Python 2 2 2 1 Mar 17 2003 15 17 58 SCC 3 3 20030226 prerelease SuSE Linux on linux2 Type copyright credits or license for more information 222 print Hello world Hello world me The window give you access to python interpreter Here you can experiment with small parts of code for check your thoughts Small button with icon on bottom right corner allow you clean the window 4 10 Key bindings Here is a list of keyboard shortcuts for the menu options Alt F File Alt FN New Alt FF New Form Alt FO Open Alt FR Open recent Alt FC aoe Alt FS Sav Alt FA Sa a as Alt FL Save all Alt FE Exit Alt E Edit Alt EU Undo Alt ER Redo Alt ET Cut Alt EC Copy Alt EP Paste Alt ES Select All Alt El Indent Alt EN Unindent Alt EW Word wrap Alt ER Prev editor Alt EE Next editor Alt S Search Alt SF Find Alt SN Find Next Alt SS Search in files Alt SR Replace Alt SG Go to line Alt P 2 Project Alt PN New Alt PE New from example Alt PO Open project Alt PR Open recent project Alt PC Close project Alt P Add files Alt PO Add folder Alt PL Add class Alt PF Add form Alt PP Options Alt R R
41. y fhome yshurik projects aclock aclock pra shell cpp ba fhome yshurik Documents Textdocuments blackadder_ license txt homey shurik proajects cursor cursar py The next part of tool bar is standard editor commands is undo redo and cut copy paste After that you can see a tool button for search operations find find next and search in files dialog Two buttons to run the Form Editor Qt Designer and PyQt Documentation system create tools toolbar The last group of buttons is the debugger operations and run It contains buttons to run the current project or file if a project is not open continue operation two buttons for single step and step over button to stop a debug session and set clear breakpoint 4 3 Editor The Editor that is used in BlackAdder is another product developed at theKompany and is used in a variety of our products The editor has standard features for editing as well as a powerful highlighting system which allow you to easily navigate in your code on the fly checking and repair of errors Note We are planning to include the Vim editor in BlackAdder as plugin Then you will be able to use all the power of vim editing if you have already experience working with Vim this is optional and expected to be in version 1 1 4 4 File Explorer BlackAdder has two File views They are located on the panel named Files The first is a list style interface you can open a directory or select a file by single clicki
42. you create a new folder in a project then the file init__ py will be automatically generated then you can use import for files from the directory and add some initialization to the init__ py file If you click the Python file you can see that appears to the left of the icons this item can be expanded to see the structure of the Python file of course if the file doesn t contain functions and classes you will not see Here is an example MP Biaciockoy g AnalogClock Dobe init gP paintEvent be timeout fe JustTestSelf Fen of init gP QMIN When clicking on classes or funcions the file will be opened in the editor and the cursor will go to the definition of the class or function this is a handy feature for rapidly navigating a file Right mouse clicking on a Python file will show the next menu Open Remove fram project Delete the file Close project The menu contains operations for opening a file in the editor remove the file from a project and to delete it from file system Right clicking on the UI User Interface file will open the following menu Open in Form Editor Generate py with pyuic Inherits Remove from project Delete the file Close project Here you can open a file in the Form Editor Qt Designer generate a Python file with the pyuic converter and subclass the form form class of user interface for enhancing the implementation of the form Refer to this manual for usin

Download Pdf Manuals

image

Related Search

Related Contents

Fiche Observation public- copie  Talkswitch TS-200  ヘルパー実施記録Ⅱ 取扱説明書 登録ボタンを押し、ヘルパー登録画面  ダウンロード(PDF 0.53MB)  machine warranty terms  Silvercrest KH2351 User's Manual  

Copyright © All rights reserved.
Failed to retrieve file