Home
wxGlade manual
Contents
1. Base directory opt wxglade lib python2 7 site packages wxglade Documentation directory opt wxglade lib python2 7 site packages wxglade docs Icons directory opt wxglade lib python2 7 site packages wxglade icons Build in widgets directory opt wxglade lib python2 7 site packages wxglade widgets Template directory opt wxglade lib python2 7 site packages wxglade templates Credito miles opt wxglade share doc wxglade credits txt License file opt wxglade share doc wxglade license txt tutorial sel opt wxglade 1ib python2 7 site packages wxglade docs html gt index html USLE WAIVE 2o E a Ae loaded code generator for perl loaded code generator for XRC loaded code generator for python loaded code generator for lisp loaded code generator for C wxGlade manual 5 50 Found widgets listing gt opt wxglade lib python2 7 site packages wxglade widgets widgets ESSE loading widget modules frame dialog 1 5 5 Troubleshooting This section should help you to solve some non application issues wxGlade has started e g by clicking the desktop icon with mouse but no application window opens Check the log file for errors see Section 1 6 3 Configuration Files and check that all dependencies especially wxWid gets and Python are installed A list of dependencies is in Section 1 4 Requirements and Supported Platforms If you think this is an application issue file a bug report like described
2. wxGlade manual 47 50 Appendix A Abbreviations The following abbreviations are used in this manual API Application Programming Interface It s a standardized implementation independent programming interface Escape sequence Escape sequences are used to define certain special characters within string literals Escape sequences starts mostly with a backslash N gettext Widespread internationalisation 118n and localisation system GUI Graphical User Interface i18n Numeronyms for internationalisation support Internationalisation means adapting software to different languages regional differences OS Operating system OSX isa graphical UNIX operating system developed by Apple Inc OS X is certified by The Open Group SAE Standalone Edition Unix is a multitasking multi user operation system Today the trademark UNIX is owned by The Open Group Operating systems complaint with Single UNIX Specification and certified by The Open Group are called UNIX Unix like operating systems behaves similar to UNIX operating systems They are not certified by The Open Group This document use the term Unix for certified UNIX operating systems as well as Unix like operating systems Linux is an Unix like operating system UTF 8 Universal Character Set Transformation Format 8 bit Character encoding with the capability to encode all possible characters wxg File extension used by wxGlade to s
3. Example 2 2 Detailed application start code in Perl package MyApp use base qw Wx App use Strict sub Oninar 4 my self shift Wx InitAllImageHandlers my Sframe 1 MyFrame gt new Sself gt SetTopWindow Sframe 1 Sframe 1 gt Show 1 eun wxGlade manual 13 50 end of class MyApp package main unless caller my Slocal Wx Locale gt new English en en replace with 2 Slocal gt AddCatalog app replace with the appropriate catalog name my Sapp MyApp gt new Sapp gt MainLoop Example 2 3 Simplified application start code in Perl package main unless caller my Slocal Wx Locale gt new English en en replace with Slocal gt AddCatalog PlOggl app replace with the appropriate catalog name Lada Wes App a Ooae sub my PlOggl_app Wx App gt new Wx InitAllImageHandlers my SMp3 To Ogg PlOggl MyDialog gt new P10gg1_app gt SetTopWindow Mp3 To Ogg SMp3 To Ogg gt Show 1 P10gg1_app gt MainLoop 2 7 5 Compiling C Code You can compile your wxGlade project after the generation of the C source and header files The following examples demon strate compiling on Linux command line using g Example 2 4 Compiling a single file C project on Linux i Gt RontColeuricop S te comnie libs Se cole cxxtiags o Hontcolour 11 FontColourx rwxr xr x 1 carsten carsten 72493 Jun 15 09 22 Font
4. dictionary Such function accepts one argument the CodeOb ject representing the object for which the code has to be written and returns 3 lists of strings representing the lines to add to the __ init de set properties and do layout methods of the parent object Note The lines inthe init __ list will be added in reverse order 6 9 Contributing to wxGlade You are of course free to make any changes additions you want to wxGlade in whatever way you like If you decide to contribute them back however here are some simple stylistic rules to follow note that these are only general indications if you think they don t fit somewhere feel free to ignore them wxGlade manual 43 50 6 9 1 Coding convensions e Class names are usually CamelCase variables functions and method names are lower case with unserscores e Constants are UPPER CASE Source lines are at most 79 characters long e Class bodies are usually ended by a end of class ClassName comment Source files use Unix EOL conventions LF if possible In any case please don t mix Unix and Windows EOLs e Put your copyright info whenever appropriate 6 9 2 Testing Please write tests for significant changes and run the test suite before commiting changes 6 9 3 Commit Messages e Use the present tense Add feature not Added feature e Use the imperative mood Move cursor to not Moves cur
5. Section 2 7 4 Automatically Created wxApp Instances provides more information wxGlade manual 21 50 Encoding Encoding of the generated source files The encoding to use with new projects will be determined automatically based on the machine settings used if the automatic detection fails Enable gettext support Enable internationalisation and localisation for the generated source files Section 2 7 4 Automatically Created wxApp Instances provides more information Top window This widget is used as top window in the wxApp start code Section 2 7 4 Automatically Created wxApp Instances provides more information Code Generation Write all source code in one file or split the source into one file per class widget Section 2 7 Using the Source Code provides more information Language Programming language to generate the source files in wxWidgets compatibility Generate source files for the selected wx Widgets version Overwrite existing sources Overwrite existing source files or modify the code sequences generated by wxGlade in place Section 2 7 Using the Source Code provides more information UTF 8 will be Note This feature is deprecated now und will be removed within the next releases Output path Output file or directory Section 2 7 3 Output Path and Filenames provides more information Generate code Star
6. rpm pkg and deb on Linux It s to provide a simple way for running wxGlade without the need of installation privileges The dependencies listed at Section 1 4 Requirements and Supported Platforms have been satisfied The source packages and the development packages have the same structure They have a top level directory and all wxGlade files are under those top level directory Extract the package into the user s home directory Take care that the directory structure of the archive will be preserved Rename the top level directory to wxGlade That s shorter and simpler to use Change into the new created directory Execute the wxglade file on Unix operating systems or wxglade pyw on Microsoft Windows to start wxGlade Feel free to create a shortcut on your desktop That s all Installations below users home directory don t require administrative permissions wxGlade manual 4 50 Multi User Installation Variant 1 The first variant of a multi user installation is very similar to Section 1 5 4 Single User Installation except the installation di rectory And probably you need administrative permissions You could extract the wxGlade source package e g into c Program Files wxglade on Microsoft Windows or into opt wxglade on Unix Multi User Installation Variant 2 Extract the downloaded package into a temporary directory Change in this directory and execute the Python setup script using python setup py i
7. s node and the widgets on it as child nodes wxGlade manual 17 50 wxGlade Tree Uhome carsten Projo D x l Application dialog 1 MyDialog sizer_1 A label 1 ETE A label 2 ab text ctrl 1 WR button 1 Figure 3 2 The Tree Window You can show or hide the tree window by the menu item View Show Tree Usually a frame or a panel contains a sizer so you often see a sort of panel sizer widgets structure The tree gets more complex when you nest sizers within sizers You can navigate the visual presentation of your widget tree by mouse expand and collapse sizers and copy cut or remove widgets A click on an icon in the tree window displays the properties of the corresponding element in the properties window A double click in a frame dialog or panel icon makes the designer window show it as it appears Clicking with the right button of the mouse gives you a pop up menu Preview dialog 1 Strg P Figure 3 3 The menu for a widget wxGlade manual 18 50 sizer 1 Remove Entf Add slot Insert slot Eb Copy Strg S Cut Strg X Preview frame 1 Strg P Figure 3 4 The menu for a sizer The pop up menu for a widget allows you to copy cut or remove the element The pop up menu for a sizer allows you to copy cut or remove the element or add or insert an empty slot Note Often when you add an empty slot you have to make the designer window la
8. Correct entered wx constant 2 a 9 Detailed application start code in Perl e 12 Simplified application start code in Perl 0 000000 a A 13 Compiling a single file C project on Linux 2 2 0 000 000 0000 22 ee 13 Compiling a multi file C project on Linux aoaaa 2 ee 13 Converting a XRC file into a wxGlade project ee 14 wxPython code to load and show a XRC resource ee 14 Generated Python code of a subclassed widget 2 2 aa 24 Generated Python code of a widget with two base classes o o e e 25 Generated Python code for a variable assignment 2 2 ee 25 Generated Python code of an EVT TEXT event handler stub at line 12 o 29 Generated Python code for setting property MaxLength to 10 at line 14 o 31 Directory package ocios es ea eee RE eA EES DD e E O Bk oe ee eS 44 ZIP packi gens cess oe Ga eWeek AE Sok aR wit eee ee AE eet e oe Be ee 44 wxGlade manual ix Preface This manual describes the programm wxGlade initially written by Alberto Griggio wxGlade is a Python Perl Lisp C and XRC Graphical User Interface GUTI editor for Unix and Microsoft Windows Each of the chapters in this manual is designed as a tutorial for using wxGlade and a reference for widgets supported until now Contact Check the project homepage http wxglade sourceforge net for the mailing list to discuss the project
9. and Grid e wxBoxSizer widgets only have the Common tab Editing properties is quite simple Properties are represented by buttons text boxes checks and other controls Usually they are referenced by the same name or symbol that you find writing C code Usually you get the changes in the design window in real time In some cases you have to push the Apply button For example the wxNotebook widget shows in its properties window a list of child wxPanels You have to press the Apply button to show changes you make when you add or remove panels You can show or hide the properties window by the menu item View Show Properties 3 4 1 Application Properties The page Application contains the general settings of the active wxGlade project wxGlade manual 20 50 Properties app Application Settings Name LJ app Class L MyApp Enceding LITF 8 Enable gettext support Top window Code Generation Single file O Separate file for each class Language O Lisp Perl Python XRC wxWidgets compatibility O28 3 0 Overwrite existing sources Output path wxglade_out py Generate code Figure 3 6 Project Properties Application settings Name Name of the instance created from Class Section 2 7 4 Automatically Created wxApp Instances provides more information Class Name of the automatically generated class derived from wxApp
10. Dialog the method add toplevel object of wxGladeF rame is called this is responsible for the addition of the widget to the app This happens in this way wxGlade manual 41 50 the name of the class of the widget to add is obtained this is done with the use of the common refs dictionary which maps the ids of the buttons of the palette to the class names of the widgets e with the name just obtained the appropriate factory function for the widget to add is got from the common widgets dictionary This function must accept three parameters a reference to the parent widget None in this case a reference to the sizer to which the widget will be added again None for toplevel windows and the zero based position inside the sizer once again this is unused for toplevel windows e the call of the factory function actually builds the widgets and inserts it in the common app tree tree with a call to its method insert The __init__ method of the widget also builds all the Properties of the object and stores them in the self properties dict 6 3 Adding a Toplevel Sizer This is similar to the addition of a toplevel widget but the action is performed in two steps e when the user clicks on the button in the palette the method add object of wxGladeFrame is called this sets the global variables common adding widget and common adding_sizer to True and stores the class name of the s
11. at least two leading backslashes e g wi will be escaped to show exact the same sequence and don t convert it into control characters Question marks especially double quotes will be escaped also 2 4 Best Practice The main goal of the recommendations is to improve the usability and maintainability of code generated by wxGlade The recommendations combine the experience of many wxGlade users Always overwrite existing sources wxGlade can change code inside existing source files to reflect changed designs This feature have some limitations e g in case of name changes and changed dependencies Thereby it s recommended to overwrite existing sources always and extend derived classes with your functionality Note This feature is deprecated now und will be removed within the next releases Use the C naming convention Use the C names for all wx identifies like classes colours or events of the wx framework Please don t enter identifiers already formatted in a language specific form wxGlade is able to transform the entered original identifiers in language specific terms You can use your own style for your object certainly Example 2 1 Correct entered wx constant Enter wxID CANCEL even for wxPython instead of wx ID CANCEL Always use UTF 8 encoding It s generally recommended to use Unicode encoding for all non ASCII character sets Always use gettext support Enable internationalisation support There are no d
12. bitmap path wvxBITMAP TYPE ANY In Perl code generation a sign is added if you omit it You can enter a code chunk returning a wxBitmap by using the code tag This inserts verbatim the code you enter in brackets and nothing more e g if wxSomeWidget needs a wxBitmap as an argument the string code if x 0 get_bitmapl else get_bitmap2 produces wxSomeWidget if x 0 get bitmapl else get_bitmap2 optionl option2 wxGlade never declares or assigns variable or function names so after code generation you have to provide extra code to declare your variables or functions If you use var or code tags the preview window shows an empty bitmap of fixed size 4 3 Widget List Follow the widget list as it appears in the wxGlade main window 4 3 1 Frame This prompts for a wxF rame or a wxMDIChildFrame A vertical wxBoxSizer is appended In the properties window you can choose the styles and you can add an icon 4 3 2 Dialog or Panel This prompts for a wxDialog or a wxPanel in top level In the properties window you can choose the styles and for the dialog you can add an icon wxGlade manual 34 50 4 3 3 Panel This allows you to add a panel to a sizer In the properties window you can choose the styles 4 3 4 Splitter Window This produces a wxSplitterWindow and two associated panels as well You can choose vertical or horizontal splitting In the properties window you can choose the styles and
13. method is the recommended one 2 7 2 Shared Control Manual changes in the source files won t be overwritten if Overwrite existing sources isn t set You can safely edit the source code of the generated class This is because wxGlade marks the untouchable code with the special comments begin wxGlade and end wxGlade So you can edit all you need outside these two tags When you make changes in your forms a new code generation will not modify the user code wxGlade is applying most of the changes but not all changes Especially renamed classes and attributes need additional attention Note Overwriting multiple files is not recommended as well as overwriting of files with percent character inside is not supported Note This feature is deprecated now und will be removed within the next releases wxGlade manual 12 50 2 7 3 Output Path and Filenames Output path specifies the name of the output file for Single file projects or the output directory for multi file projects Sep arate file for each class The filename has to include the appropriate suffix of the programming language always An exception is the Output path for Single file C projects Filename don t contains the filename extension now The extension for C source and header files will be appended later automatically 2 7 4 Automatically Created wxApp Instances wxGlade can create an additional code to st
14. the property window you can enter the label the URL and also set the style wxGlade manual 35 50 4 3 9 Radio Box This produces a wxRadioBox In the properties window you can enter the dimension The style determines whether the dimension is the number of rows or columns You also can set which button is selected with the Selection spin starting from 0 You can edit the list of choices but remember to click on the Apply button to consolidate changes 4 3 10 Spin Control This produces a wxSpinCt r1 In the properties window you can enter the value the range and also set the style 4 3 11 Slider This produces a wxSlider In the properties window you can enter the value the range and also set the style 4 3 12 Static Text This produces a wxStaticText In the properties window you can enter the text set the style and tell wxGlade whether to store the control as an attribute 4 3 13 Text Control This produces a wxTextCt r1 In the properties window you can enter the text and also set the style 4 3 14 Check Box This produces a wxCheckBox In the properties window you can enter the text and the status checked or not of the button 4 3 15 Choice This produces a wxChoice In the properties window you can enter the position of the selected item starting from 0 You can edit the list of choices but remember to click on the Apply button to consolidate changes 4 3 16 Combo Box This produces a wxCo
15. the sash position Be careful not to put too large a widget in a splitter panel because while it might appear normal in the design window when you run your program one of two panels will take all the available space and the other will shrink to the minimum size possible 4 3 5 Notebook This produces a wxNot ebook and one panel for each tab In the properties window you can add and remove tabs which appear in a list Don t forget to click on the Apply button to transfer changes that you have made in the list to the design window 4 3 6 Buttons Button This produces a wxButton You can enter a caption and the default flag If you want to add an image you need a bitmap button see Section 4 3 6 Bitmap Button Bitmap Button This produces a wxBitmapButton You can set the default flag on or off You also can choose the bitmap for the button and optionally the bitmap for the disabled status Refer to Section 4 2 Specifying the Path of Bitmaps for bitmap path specifications Radio Button This produces a wxRadioButton In the properties window you can enter the text and the status clicked or not and the style Toggle Button This produces a wxToggleButton You can enter a caption and the status clicked or not of the button 4 3 7 Gauge This produces a wxGauge In the properties window you can enter the range and set the style 4 3 8 Hyperlink Control This produces a wxHyperlinkCtrl In
16. want to create multiple files for your design wxGlade expects an output directory in such case but the given output path isn t a directory Corrective Action Choose a output directory wxGlade manual 15 50 Generated source code couldn t converted to encoding lt encoding gt The source contains invalid characters lt characters from Details The current design uses characters that can t converted to the encoding selected for the source code file Corrective Action Choose a design encoding that supports the listed characters also Generating Lisp code for wxWidgets version lt version gt is not supported Details There is no Lisp support for the selected version of wxWidgets Corrective Action Create the code for an older wx Widget version XRC code cannot be split into multiple files Details You want to create multiple XRC files for your design This option isn t supported by wxGlade Corrective Action Select the Single file option to store the whole design in one XRC file Code generation from a template is not possible Details You ve selected a template as input file to generate source code from Corrective Action Use a design file instead of a template Code writer for lt language gt is not available Details The code generators for the given language hasn t been loaded Corrective Action That s probably a bug in wxGlade Please check the log file and file a bug report See Section 1 7
17. 0000000000 000004 42 6 8 Generating the Cource Code so ps 2 2 2 0 a a a A 42 6 9 Contributins to wxGlade ss ss a AE Re Re RD RA RD A a e e 42 6 9 1 Coding convensions guns smp Re a E O ae RA ee O 43 0 9 2 Testing sss dio Rg Sepa al ek i ad Gow e OE Rea OA Re we Re eee a 43 6 9 3 Commit Messages ss raspor dl ia Qe a ie a A em oe Eee ae A Ge eee a 43 7 Installing and Designing own Widget Plugins 44 7 4 Widgets Packages 2 ssa MRA a a E REGE A O E a E 44 7 1 1 Createa ZIP Package a e E E 45 7 2 Installing Widget Plugins Locally 00000022 ee eee 45 7 3 Designing own Widget Plugins a a A 45 7 3 1 Widget Initialisation 2 2 0 a 46 wxGlade manual v A Abbreviations 47 B Copyrights and Trademarks 48 C wxGlade License Agreement 49 D Licenses and Acknowledgements for Incorporated Software 50 Dit Ordered Dict 0 tea a 4 lo o a i Boe a a ee ee a ee See da da wxGlade manual vi List of Figures 11 1 2 1 3 3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 3 16 3 17 3 18 5 1 5 2 5 3 wxGlade Windows s osos a ms ko o SS Be e RS a a a 1 wxGlade preferences dialog snsc toesti meani ae e sia aa ea E e E ES o 6 An error dialog example 2 2 a e E EOE 7 The Maim Palette pe sal mus la a a ei e a AE a ee a a AA 16 The Tree Window 655 sora goe pae a ees dawn eee a tee ee 17 The Menu fora widget lt s sa eh A ee RS Be BS ee Sw A Boe ee Da 17 Th
18. 4a as ebb See ee eee Pa ERS ee bas Wo 39 4 3 13 Text Control cee cee oso encore ra A 35 4 3 4 Check BOX s p ome da a a bet e a R e E R bee ee 35 43 15 Choice ci ad a eed ee be a E ee ee y 35 4 3 16 Combo BOX lt e samme doado ep dr O ae ROS E A a be ea eee eee 35 43 17 ListBox 2 e cad i e SEA E eee eae ee UU ee ee A a 35 4 3 48 State bite our e n bet a a R A E ee 35 ALSO Static Bitmap s e ee eee a A aE qa e UE AA ca ae 36 43 20 List Control senad e E a eee wa bee 36 43 2i ree Control 2222 a Sao 84 a4 be oe Ghose EEE IP a E T o E DL E OS 36 4 3 22 Gnd 2 p ie Shaw Ped bet he ee SUE DR a A Eee Pee a EAD bs D 36 43 23 Custom WidSets 2 dps Fb db oP o PERE E Ged Ee A DRE he ee S bs 36 4 3 94 Space 22442 24 ORAR 36 5 Menu Statusbar and Toolbar 37 Sil AMtroOdUchoOn sos E ORE OR E AS Rd ee E ee Dew AS Gee eee eS a 37 532 MENU do Bess tects a ae Ye te A ee JE a ee he ee es ew eae ees ae 37 5 3 Statusbar its E ae ene a e SA OE ee a Be ee a 38 OA Toolbar saca eras ee a 0 O AE A A E A AA E ee e 38 6 wxGlade technical notes 40 OS Sta pis Rata es e oe tree A TE e AAA AE A A 40 6 2 Addinga Toplevel Widget ua gu pjs eae ene ds e A A ii a E 40 6 3 Adding a TopleveliSIZET ate AA AAA RA ad 41 6 4 Adding a Normal Widget Sizer a A 41 6 5 Changing the Value ofa Property 41 6 67 Saving the App puros Yue Sed Be RAR oa e a a Es a ee ae G Se 42 6 7 Loading an App froma XML flle 0000000200000 00
19. 5 Ev nis Properties ss ss esed bee A ewe ee ee owe a SD LR oe 28 3 4 6 Code Properties s opecs eee eR RN ee OR Rw Ew bk be ee ee ee e a 30 3 5 The wxGlade Menu 0 565485 Bea ERS EER A ee RO eo a 3 3 1 The FILE Men q eee eb ee a A ewe LEE ee e eae SO 31 35 2 The VIEW Ment ssa me bes eee ee ee eR Rew bk ee ee ee eee e a 31 3 9 3 The HELP Menu ssa 2 55 6 se big be OHS SR ROS a ea we ol ea eh ae 32 3 0 O MOMCU S E A A ADA AS AA e 32 4 Supported widgets 33 4 1 Introduction sre deaa GERA RE ESA A Ewe ee ee A 33 4 2 Specifying the Path of Bitmaps s s s coses soere a nekean eee 33 AS Wideri odds ira RU eee Oe eee eee e eee o de 33 ABA Fiame a dogs ee A o eat E RC ee eae Ee 34 4 3 2 Dialopor Panel ss ss esis od Ae a a a a e AE ee eo eas 33 433 Panel q 24 4 eme fones Fig eee HVS SG hae eee Gs Be See oa ew E A 34 4 3 4 Splitter Window uses 5084 ee bee EU ee oa eee Ea a 34 dor Notebook uoy e ana aint ay bbe SOR pn ee ee OR do a es ee nets BO ee oe oe e 34 43 0 BUUONS vos 2 ta eee hae Be eA She eG ee Se EA Ba a ea Se eS 34 437 Gauge spatial pm eee i del weed EGO a ee eee bbw Rb eee be ea eee ae Se 34 43 8 Hyperlink Control ss ass cae eee pp aR ee ae Re eS ee ee e 34 4 3 9 Radi BOX oc a eR eR RS e OR BR Se ee Be ok a ee we a 35 4 3 10 Spin Control e e sai eead PR SO DG a O ea G n 35 wxGlade manual iv AS Slider duro Go o ae deus ao Red RG A eve ee Eee Ge oe Tp a RS a DA e a 35 43 12 Static Text csc i254
20. Colour rwxr xr x 1 carsten carsten 1785 Mai 11 19 24 FontColour cpp rwxr xr x 1 carsten carsten 1089 Jun 11 07 09 FontColour h Example 2 5 Compiling a multi file C project on Linux gtt CPPOg9g2 main cpp wx config libs S wx config cxxflags N o CPP0gg2 main CPPOgg2_MyDialog cpp CPPOgg2_MyFrame cpp 11 CPPOgg2x rwxr xr x 1 carsten carsten 108354 Jun 15 09 33 CPPOgg2 main rwxr xr x 1 carsten carsten 844 Mai 11 19 25 CPPOgg2_main cpp rw r r 1 carsten carsten 5287 Mai 13 19 06 PROgg2_MyDiallog cpp SENS e E earsten earsten lisas Ja Ll 07211 CAM Mya Lola Wa e E earsten earsten 1785 Mai 11 19 25 CPPOgg2_MyFrame cpp SENS e E earsten earsten 1290 Jun 11 07 10 CPPOgg2_MyFrame h 2 8 Handling XRC Files wxGlade is able to save projects as XRC files and to convert XRC files into wxGlade projects One way for converting XRC files is the usage of the Python script xrc2wxg py at command line The script is part of wxGlade wxGlade manual 14 50 Example 2 6 Converting a XRC file into a wxGlade project E xrc2wxg py Hont Colour xne Is 1 FontColour x rw r r 1 carsten carsten 5554 Dez 4 20 36 FontColour wxg rw r r 1 carsten carsten 4992 Dez 4 20 13 FontColour xrc The File menu provides a menu item Import from XRC to import and open a XRC file directly The following example shows how to load and show the frame Main from XRC file test xrc Example 2 7 wxPyth
21. How to Report a Bug for more details Conversion of the source file lt filename gt to Unicode failed Details The file encoding set within the design doesn t match the encoding used within the source file Thereby the source file can t be loaded Corrective Action Check the encoding selected in your design and the encoding of your source file Change the design encoding to match source files encoding wxGlade manual 16 50 Chapter 3 wxGlade User Interface 3 1 Main Palette The main window is a palette that hosts the menu and the widget choice buttons E O wxGlade v0 6 5 E x a Jim ae la Po Are aag mo pagr so ER LL Figure 3 1 The Main Palette If you pass the mouse pointer over a button a tooltip shows the button s description The Add a Frame button and the Add a Dialog Panel button bring up a dialog to add a frame a dialog or a panel to your project The Add a MenuBar button asks you for the name of the class then adds a menu bar to your project The Add a ToolBar button asks you for the name of the class then adds a toolbar to your project The other buttons in the main window add widgets to a form When you click on one the mouse pointer changes to an arrow Then you can click on a sizer s empty cell to add the widget to it 3 2 Tree Window The tree window shows the logical hierarchy of widgets and its child widgets For example you can see a panel as a tree
22. Use the lists for questions proposals bug reports and collaboration Information support and bug reports can be addressed to the wxGlade mailing list too Any kind of feedback is always welcome License wxGlade is copyright 2002 2007 by Alberto Griggio and 2011 2015 by Carsten Grohmann Use and distribution of wxGlade is governed by the MIT license located in Appendix C wxGlade License Agreement wxGlade manual 1 50 Chapter 1 Introduction to wxGlade 1 1 What is wxGlade wxGlade is an open source graphical user interface builder written in Python using popular widget toolkit wx Widgets im wxGla O x 5 5 WxGlade Tree Hhome Be 15 EB Properties lt ar BE B lt Application Application settings pyogg2_app Class O MyApp its Encoding iso 8859 15 Enable gettext support b FrameOggCompressionDetails PyC LER Mp3 To Ogg window Code Generation O Single file Separate file for each class Language O C CLisp O Perl Python XRC wxWidgets compatibility Figure 1 1 wxGlade windows wxGlade allows to create graphical user interfaces using wx Widgets The designer can arrange different widgets using a drag and drop WYSIWYG editor This simplifies the creation of a graphical user interface in comparison with manual coded graphical user interfaces wxGlade is able to generate source code for Python Perl Lisp C and XRC based on the designed GUI As you c
23. an choose to let wxGlade to create the grid or leave it to the user code 4 3 23 Custom Widget When you put a custom widget in the design window you will be prompted for a class name In the properties window you can set a number of custom attributes that will appear in the constructor call These attributes have different effects in C Lisp Perl Python or XRC code generation Four special attributes Sid parent Swidth and height return the value you specify in the Common tab of the custom widget 4 3 24 Spacer When you put a spacer into a sizer slot in the design window you will be prompted for the size wxGlade will generate the code to set an empty space in that slot of the sizer wxGlade manual 37 50 Chapter 5 Menu Statusbar and Toolbar 5 1 Introduction wxGlade helps you to design the menu and the toolbar for your application You can create the menu and toolbar as stand alone classes by clicking the corresponding button in the main window Alternatively you can make the menu toolbar and statusbar associated with a wxF rame by selecting the related checkboxes in the wxF rame properties window 5 2 Menu In the menu properties window click on the Edit menus button A dialog will let you edit your menu Use the Add button to add items to the menu enter the label an optional name and help string You can use numbers or variable names as the item id If you use a variable name you have to provi
24. an guess by the name its model is Glade the famous GTK GNOME GUI builder with which wxGlade shares the philosophy and the look amp feel but not a line of code wxGlade manual 2 50 1 2 What can you do with wxGlade With wxGlade you can e Design the whole GUI of your application inclusive simple or complex dialogs as well as menu bars different kinds of buttons and text widgets bitmaps e Use the graphical editor for editing cutting and pasting widgets e Convert your design in source code of your favorite language e Run wxGlade on a wide variety of operation systems since it is written in Python 1 3 What is wxGlade NOT wxGlade is not a full featured IDE and will never be one wxGlade is just a graphical user interface builder The generated code does nothing apart from displaying the created widgets If you are looking for a complete IDE maybe Boa Constructor or PythonCard is the right tool wxGlade isn t a tool to learn programming with wx Widgets You can t use wxGlade if you do not have any basic understanding of programming You need to know the basics of wx Widgets as well as the basics of C Python Perl or Lisp 1 4 Requirements and Supported Platforms wxGlade has been tested and run on Microsoft Windows Linux OS X Because wxGlade is written in Python using wxPython it can also be run on any platform that supports Python and wxPython Especially the wxGlade requirements are e Python 2 a
25. art an instance of projects Top window There are two types of application start code e simplified application start code e detailed application start code The application start code generation is controlled by three properties 1 Name 2 Class 3 Top window Those properties are explained in Section 3 4 1 Application Properties Different combinations of those attributes generated different application start code The table below shows the type of application start code resulting from different combinations of the three properties The Enable gettext support property just triggers il8n enabled source code Name Class Top window Type of application start code to generate not selected not selected not selected not generated selected not selected not selected not generated not selected selected not selected not generated selected selected not selected not generated selected not selected selected simplified start code not selected selected selected not generated selected selected selected detailed start code Table 2 1 Interaction between properties to generate different types of start code The application start code of a multi file project will be recreated every time the code generation is running In opposition the application start code of single file projects will not updated if the name of the Top window has changed and Overwrite existing sources is not set
26. ceforge You have to log in at Sourceforge to file a bug report Alternatively you can send the bug report to the wxGlade mailing list Keep in mind that you need a subscription for sending emails to this mailing list Error Dialog An internal error occurred while loading file bugdialog_ui wxg Error type NotimplementedError Error summary That s just a test This is a bug please report it Error Summary Error Details Howto Report a Bug Figure 1 3 An error dialog example 1 8 Deprecated Features wxGlade can change code inside existing source files to reflect changed designs This feature is deprecated now und will be removed within the next releases wxGlade manual 8 50 Chapter 2 Exploring wxGlade 2 1 Quick Example We will design a simple form Start wxGlade by running the wxglade program on Unix or the wxglade pyw program on Microsoft Windows You will see a Main Palette with several buttons and a Tree Window with an icon marked Application A Properties Window shows the properties of the Application If you move the mouse over a button in the main window a tooltip will display its function To add a frame in the design window from the Main Palette choose the first button Add a frame Then choose wxF rame as the base class Look at the tree window and see that two icons are generated under the application icon a frame icon and a sizer icon If you double click with the mouse on the fram
27. de extra code in the generated source code Choose the type of the item Normal Checkable or Radio You can move menu items with Up and Down buttons and you can modify the hierarchy of the menu with lt and gt buttons 2 Menu editor ox Menu item Label Id Name Help String Type Event Handler File o id wxID_EXIT Ji Exit wxID_EXIT Finish program 0 Label Name l Event Handler o Type Normal O Checkable Radio Add Remove Up Down lt Add separator 4 ox Y Anwenden Abbrechen Figure 5 1 Menu editor wxGlade manual 38 50 5 3 Statusbar In the properties window you can edit the list of fields and their size but remember to click on the Apply button to consolidate changes Common Name Class wxStatusBar Style wxSTB_SIZEGRIP O wesSTB SHOW TIPS C wxSTB ELLIPSIZE START wxSTB_ELLIPSIZE MIDDLE wxSTB_ELLIPSIZE END C wxSTB DEFAULT STYLE Fields Text Size frame 2 statusbar 1 Figure 5 2 Statusbar properties 5 4 Toolbar You can edit the toolbar s style and bitmap size in the properties window wxGlade manual 39 50 Click on the Edit tools button to edit the toolbar buttons Use the Add button to add buttons to the toolbar enter the label an optional name and help string You can use numbers or variable names as the b
28. e myEVTTEXT self print Event handler event Skip uy self text ctrl 1 METE AL XT self myE event wxGlade myEVITEXT not implemented def MyFrame lt event_handler gt 3 4 6 Code Properties The fifth and last tab is named Code and has two parts Sa E O Properties lt text_ctrl_1 gt Common Layout Widget Events Code Extra code for this widget O Extra properties for this widget Add Remove Property Value Figure 3 17 Properties for extra code and extra properties The upper part provides the ability to add additional code for that widget e g for importing a custom class This Extra code will be added to the context of the source file and not to the context of the class The under part simplifies setting of additional widget properties Add the property name to the Property field and not the name of the setter function For instance add MaxLength and not SetMaxLength The Value field is just a text field You can wxGlade manual 31 50 enter e g a simple number only as well as a complex statement e g 0 0 1 or a function call But be carefully Your entered sequence will be inserted in the source without any changes one to one Note Extra code and Extra properties won t be processed for the widget preview l Extra properties fo
29. e icon the designer window appears Notice that the sizer is displayed as a set of gray boxes they are the slots of the grid sizer where you will place the widgets You put a widget on a sizer by selecting it on the main window then click on an empty slot on the frame on the designer window Try adding a static text a text control and a button If you want to add something else add empty slots on the sizer by right clicking on the sizer on the tree window and selecting Add slot Play around adding four or five widgets on the frame Now look at the properties form there are three tabs In the Common tab you can specify the name size and color of the widget In the Layout tab you can adjust borders and alignments In the Widget tab you find the properties depending on the widget You can select the properties of a widget by clicking on the designer window or the corresponding icon on the tree window Try adjusting widgets with the properties form until you know you have played enough Now let s generate the code Select the Application icon on the tree window and go to the properties window Check Name and Class choose a Top window check Single file and choose the language and set the Output path by pushing the button for selecting a path and a filename Finally press the Generate code button and the code is generated Compile and enjoy wxGlade manual 9 50 2 2 Bas
30. emenu forasiz r s ecis e cederent Re A a RO eae aS 18 The Design Window s coyta eig pepada a Ges RA a eee a e a a E 18 Project Properties Application settings ee 20 Project Properties Language settings 2 2 a 22 Common Properties o ques ee ep ee Re ok RR a ewe a E 23 Changing Common Properties a 24 Common Properties of a subclassed widget default behaviour o 000 4 24 Common Properties with Base class es entry ee 23 Common Properties with a variable assignment ee 25 Layout Properties qse s e 40s es ae eae a g eai BAe ae eG BA ele a RO QU OR O RE E 21 Widget PrODETtIES sopa s 255 pum e pe op a aa A a See a 28 Events Properties p 4 2044 e p43 a a RA A e E a Sead de a 29 Events Properties with entered event handler name 29 Properties for extra code and extra properties o oo e 30 Set extra property Veloso mesara a eS Se ee RIR e E Re e E E a e a 31 M nu editor ss ccedi siaa 40446 bee rbd nee Bk ee a E UN a ee UR e aa eS 37 Statusbar Properties isa 24 sdara 844555 e SL E e RD E E AL A en eb Sere or 38 Toolbar editor 3s eee ew a hee we Dao ee a E eee a Seay a E 39 wxGlade manual vii List of Tables 2 1 Interaction between properties to generate different types of start code 0 o o 12 wxGlade manual viii List of Examples Installing wxGlade at opt wxglade 2 a 4 Starting wxGlade at opt Wxglade bin wxglade a 4
31. es is not set 1 N wxGlade manual 25 50 5 O Properties lt frame 1 gt Common widget code dE C class MyFrame ss Base class es myFrameMixin wxFrame Figure 3 11 Common Properties with Base class es entry Example 3 2 Generated Python code of a widget with two base classes class MyFrame myFrameMixin wxFrame def init self args xkwds begin wxGlade MyFrame init kwds style wx DEFAULT FRAME STYLE myFrameMixin init self xargs xkwds wxFrame init self Td This property could be a constant numeric value a predefined identifier e g wxID ANY e a predefined variable like a class member e g self myButtonID e a variable assignment e g self myButtonID The pattern of a variable assignment is always variable value The value could be again a numeric value a predefined identifier another predefined variable or a shortcut for wxNewld im O Properties lt button 1 gt e button aa4a Class wxButton d selfmyButtonD y Figure 3 12 Common Properties with a variable assignment Example 3 3 Generated Python code for a variable assignment class MyFrame wx Frame def __init__ self xargs kwds begin wxGlade MyFrame __init__ kwds style wx DEFAULT FRAME STYLE wx Frame init self xargs x x kwds self myButtonID wx Newld self button 1 wx Button self self myButtonID butt
32. ext perl codegen py SS 2013 12 09 10202 static_text static_text py wxGlade manual 45 50 7 1 1 Create a ZIP Package Creating a ZIP package is quite simple Just create a ZIP package from widgets directory with all Python and additional files Don t include Python bytecode files because they are not platfrom independend tree static_text static kt es A A ay codegen py EOE o ONY lisp_codegen py perl_codegen py static_text py mao 16 CaCl rest O STALLE TET adding static_text stored 0 add no Susie ero imit py WCerlarec 310 adding static_text codegen py deflated 67 adding static_text wconfig py deflated 64 adding static_text lisp_codegen py deflated 54 adding static_text perl_codegen py deflated 56 adding static_text static_text py deflated 69 Check the integrity of the created ZIP archive d Zip T Statide text zip test of static text zip OK 7 2 Installing Widget Plugins Locally The installation of local plugins is a two step process 1 Place the widget package in the Local widget path see Section 1 6 1 Preferences Dialog Create this directory if it doesn t exist 2 Add widget name to the text file named widgets txt This file is also located in the directory specified in Local widget path Just create a simple text file if the file doesn t exists The new widget will be avalable after myrun has been restarted 7 3 Design
33. h ee da g 2 5 Language Specific Peculiarities s s 66 SR PRS tenenu RE RD E REL Re 6 10 24 Python eee ci E e ee ee ee ER e ee le eae eal ee 10 292 MP a sa Bac hs ee ee ee EA AA o a 10 2 6 Command Line Invocation 2 2 2 a a a a A 10 2 7 Using the Source Codes pe er nesecita 288 4460 G4 Ree A E A Ea ee T wxGlade manual iii 2 7 1 Full Control by wxGlade s pp ee spreda aea ee se ee ty 21 2 Shared Control sip saiake ices a BOA ee Re ORAL SG ee Re A Ae ee ee eh wee a 11 2 73 Output Path and Filenames lt 5 222 5 4 44444 e SEGA DA RUE a eee he bo 12 2 7 4 Automatically Created wxApp Instances 1 ee ee 12 2 1 5 Compiling C Code o casec soe ee ee ee ee eh ee ee ee 13 2 8 Handling XRC HNES axe at e ae ee A E AS AS bx 13 2 9 Error Messages o sge punir sera ic ee Oe Ba a ee A a PRA e 14 3 wxGlade User Interface 16 31L Mam Paleta ee Be de ty Fh Gs At Ee Oe Oe OE a oe ee ee OR ak Se 16 32 Tree Window 2 2284 225 ne eek bg Bee ed EG bw eee ee RS eS hee ee eS 16 3 3 Design Window s ra doe a0 den eee dae dee bed RE eee wa bbw hE O be ea ee ae Se 18 34 Properties WindOW us ssa ach be we ee PA ee RE Oe ee Gee ewe a eR om Oe e 19 3 4 1 Application Properties o ooo asse e ea ae e e e eee ee 19 34 2 Common Properties s Ce ses cee ee serasa E RA RA ee e ADS E 23 34 3 Layout Properh s ssa ps eR RN EER eR be SR Pe eee eee e a 26 3 44 Widget Properties iscas pd E Re a a i aE a e da 21 3 4
34. h object in turn calls the appropriate xml builder function got from the common widgets from _xml dictionary that creates the widget this function is similar to the factory function used to build the widget during an interactive session see the code for details and differences e when the end of an object element is reached the object at the top of the stack is removed and its widget see the source of XmlWidgetOb ject is laid out e when the end of a Property element is reached the appropriate setter function of the owner of the Property is called This is the default behaviour suitable for simple properties For more complex properties whose xml representation consists of more sub elements each widget can define a particular handler see for example Font Handler in edit_windows WindowBase 6 8 Generating the Cource Code This section is the result of a cut amp paste of the comment at the beginning of codegen py_codegen py Itis VERY incomplete The ContentHandler subclass which drives the code generation is ml parse CodeWriter How the code is generated every time the end of an object is reached during the parsing of the xml tree either the function add object or the function add class is called the latter when the object is a toplevel one the former when it is not In the last case ada object calls the appropriate writer function for the specific object found in the obj_builders
35. hanges to display the properties of the selected object this is done by the functions show properties of edit_windows EditBase and edit sizers SizerBase which are called inside two event handlers for focus and tree selection events When the value of a Property is changed its setter function is called to update the aspect layout of the widget the Property belongs to such function is obtained from a call to the widget s __getitem__ method which must return a 2 tuple getter setter for the Property wxGlade manual 42 50 6 6 Saving the App This operation is performed by the common app tree Tree for every Node of the tree an object xml element is generated with the following attributes name class base class Each object contains an element for each Property generated by the write method of Property and then an object element for all its sub widgets and or sizers Properties in the sizer pro perties dictionary are treated in a different way as well as the children of a sizer which are sub elements of sizeritem objects see the source code for details 6 7 Loading an App from a XML file This is done by xml_parse XmlWidgetBuilder a subclass of xml sax handler ContentHandler Basically the steps involved are the following e when the start of an object element is reached a xMLWi dget Object instance is created and pushed onto a stack of the objects created suc
36. ics of wxGlade The program wxGlade is a tool for designing Graphical User Interfaces GUI It is intended to be used with the wx Widgets framework in all its flavors C Lisp Perl Python and XRC You use a visual editor for creating forms menus and toolbars with the mouse Your design is saved in a wxg file which is the wxGlade file format Then you generate source code or XRC by using visual tools or invoking wxGlade at the command line You can also use wxGlade in your makefile by generating source code only when the wxg file changes A wxg file can contain multiple forms panels menus and toolbars and generate either a single file containing all classes or multiple files containing one class each wxGlade does not manage events file inclusion function names stubs or anything else but graphic interface code 2 3 Escape Sequences Escape sequences are used to define certain special characters within string literals wxGlade supports escape sequences gen erally The only exception is the null byte 0 and the escape sequence 0 belonging to it wxGlade can t handle null bytes Escape sequences like w or Ar will not touched by wxGlade Thereby the generated source code contains excatly the same sequence as entered The language interpreter or compiler will interpret and probably convert the sequence into control characters For example n will be converted into a line break Escape sequences with
37. in Section 1 7 How to Report a Bug please 1 6 Configuring wxGlade 1 6 1 Preferences Dialog You can access the Preferences Dialog with the menu item View gt Preferences You can choose some decoration options like whether to show icons in menus or not but also something more effective For example you can modify the number of buttons in the Main Palette If you type a value of 15 or 30 you get a long toolbar like Main Palette You can also choose the default path where you save wxGlade files or generate source code Another useful option is to enable a default border of 3 around some widgets In many cases this can be useful to have set You need to restart wxGlade for changes to take effect wxGlade manual 6 50 jm wxGlade preferences x dim Interface Other Interface Other Use icons in menu items O Use dialog units by default for size properties Mi Show properties and tree windows as small frames Create backup files for generated source Mi Show progress dialog when loading wxg files C Default border width for widgets la B M Remember position and size of wxGlade windows Y Log additional debug infomation Show handles of sizers Y Auto save wxg files every l 120 S seconds O Use native file dialogs on KDE Insert timestamp on generated source files C Show success message for code generation O Insert wxg file name on generated source files Fe a EA dialoga jho
38. ing own Widget Plugins Note This section is under constraction Please use this information carefully 1 Create a new directory named like the widget and change in this directory 2 Place an empty file___ init__ py in that directory 3 Create a Python file codegen py with initial content like 2 Code generator functions for myCtrl objects 4 copyright lt Add year and your name gt wxGlade manual 46 50 s license lt Choice a license gt nu s import common u class PythonMyCtrlGenerator wcodegen PythonWidgetCodeWriter 13 tmpl 2 name s klass s parent s id s label s style s n 5 end of class PythonMyCtrlGenerator 18 def initialize 19 common class_names EditmyCtrl myCtrl 20 21 pygen common code_writers get python 22 if pygen 23 pygen add_widget_handler myCtrl PythonMyCtrlGenerator 4 Create a Python file named like the widget directory e g myctrl py 5 Create remaining code generators 6 Example of the created structure mye all im bie DY codegen py imei Jony 7 3 1 Widget Initialisation Note This section is incomplete 1 Loade generic and language independent widget configuration from wconfig py common load config 2 Load and initialise language code writers common load code writers 3 Load and initialise widgets common load widgets 4 Load and initialise sizers common load sizers
39. isadvantages if internationalization is active but not used It s hard to add 118n and Unicode afterwards from project point of view wxGlade manual 10 50 Suggestion on naming The wxWidgets are written in C and follow the C naming convention This naming convention may differ from the language specific and or project specific naming convention For consistency s sake it s recommended to use the wx Widgets style Prevent language specific statements Usage of language specific codes e g for Extra code for this widget or in generic input fields complicated changing the output langauge later e g to re use GUI elements in another project too 2 5 Language Specific Peculiarities 2 5 1 Python It s not recommended to use nested classed and functions in combination with disabled feature Overwrite existing sources Use derived classes to implement your functionality See Section 2 4 Best Practice also 2 5 2 Lisp The Lisp code generated by wxGlade may or may not working with a current Lisp dialect Help to improve the Lisp support is really welcome Unsupported features in Lisp e Unicode support e Support for wxWidgets 3 0 2 6 Command Line Invocation You can run wxGlade without parameters to start the GUI on an empty application as follows wxglade Run wxGlade GUI on an existing application specifying the wxg file as follow wxglade lt WXG File gt If you only want to generate the c
40. izer to add in the global common widget to add the name is obtained from the common refs dictionary as described above when the user left clicks the mouse inside the previously added toplevel widget its drop_sizer method is called which 1s responsible of the addition of the sizer 1t calls the factory function for the sizer passing self as the first argument which will build the object and add it to the tree 6 4 Adding a Normal Widget Sizer This step is more or less the same as step 3 e wxGladeFrame add object is called in response to a button click e when the user drops the widget inside a slot in a sizer the method drop widget of edit_sizers SizerSlot is called which in turn calls the appropriate factory function with arguments self parent self sizer and self pos i e the parent sizer and position inside the sizer of the slot that will be replaced Factory functions of non toplevel objects call apart from common app_tree insert to insert the object in the tree the method ada item of edi t_sizers SizerBase to add the object to the sizer and to remove the slot For managed widgets sizers the ini t__ method also builds the Properties which control the layout of the object inside a sizer and stores them in the self sizer_properties dictionary 6 5 Changing the Value of a Property When the user selects a widget the property window c
41. lass of wxApp which in turn creates a wxGladeFrame this is the main window of the app i e the one with the palette of buttons The initialization of wxGladeF rame consists of three steps Creation of the three frames of the app the palette itself the tree and the property window Loading of the code generator modules The codegen subdir is scanned to find the available code generators when a python module is found the app tries to load it and to access its writer attribute if this is succesfully accomplished such writer object is considered a valid code generator and is inserted into the common code writers dict the key used is the language attribute of the writer itself Loading of the widget and sizer modules To load the widgets the file widgets widgets txt is read and the app tries to import every widget module listed on such file For every module succesfully imported the initialize function is then called this function sets up the builder and code generator functions for a particular widget explained later and returns a wxBitmapButton instance to be added to the main palette The loading of the sizers is more or less the same except that all the sizers are in the same module edit sizers and the initialization function called init gui returns a list of wxBitmapButton objects 6 2 Adding a Toplevel Widget When the user clicks on a button of a toplevel widget a Frame or a
42. lation Python and wxPython The wxWidgets are bundled with wxPython on Microsoft Windows Thereby you don t need to install wx Widgets separately There is no need to install additional packages for the standalone edition because the standalone edition includes the required parts of Python wxPython and wx Widgets The installation process is quite simple Just download the installer file execute it and follow the installer instructions 1 5 3 Installing on Unix Unix like Operating Systems Current Linux distributions provide wxGlade packages already Use the distribution specific install mechanism to install the wxGlade package and all dependencies You may install wxGlade from the source package if your distribution doesn t provide any package or the package is out of date 1 5 4 Installing from Source The installation from scratch requires Python wxPython and wxWidgets Those three components have to be installed first Maybe you could use already packaged versions of those components for your operating system Otherwise read the installation documentation of the missing components and follow the instructions There are two ways for installing wxGlade from source single or multi user installation Download a source package or a development package in a first step Single User Installation The Single User Installation is a simplified installation without using native package like msi and exe files on Microsoft Windows or
43. loper The configuration file is a simple text file and contains user settings It s named wxgladerc on Unix or wxglade ini on Microsoft Windows Be careful with manual changed The configuration directory contains also a list of recently used files in file_history txt wxGlade writes always a small error log file wxglade log It s also stored inside this directory The file size is limited to 100 KB and wxGlade will keep at most two log files wxglade log and wxglade log 1 The roll over from wxglade log to wxglade log 1 will occur if the file size limit is reached An already existing file wxglade log 1 will be deleted automatically The log file is a text file and the content is UTF 8 encoded wxGlade manual 7 50 1 7 How to Report a Bug Writing a helpful bug report is easy if you follow some hints The items below should help you to integrate useful information They are not an absolute rule it s more like a guideline e What did you May you want to include a screenshot e What do you want to happen e What actually happened e Provide a short example to reproduce the issue Include the internal error log file wxglade log always The pane How to Report a Bug contains the full path of the error log file The file location is additionally described in Section 1 6 3 Configuration Files May you read How to Report Bugs Effectively additionally Please open a new bug in the wxGlade bug tracker at Sour
44. mboBox In the properties window you can enter the position of the selected item starting from 0 You can edit the list of choices but remember to click on the Apply button to consolidate changes 4 3 17 List Box This produces a wxListBox In the properties window you can enter the position of the selected item starting from 0 You can edit the list of choices but remember to click on the Apply button to consolidate changes 4 3 18 Static Line This produces a vertical or horizontal wxStaticLine In the properties window you can tell wxGlade whether to store the object as an attribute of the frame class wxGlade manual 36 50 4 3 19 Static Bitmap This produces a wxStaticBitmap You will be prompted for the bitmap path Refer to Section 4 2 Specifying the Path of Bitmaps for bitmap path specifications In the properties window you can set the style and you can tell wxGlade whether to store the object as an attribute of the frame class 4 3 20 List Control This produces a wxLi stCtr1 In the properties window you can set the style 4 3 21 Tree Control This produces a wxTreeCt r1 In the properties window you can set the style 4 3 22 Grid This produces a wxGrid In the properties window you can set the style the row number the label size the line and background color and the selection mode You can edit the list of columns but remember to click on the Apply button to consolidate changes Also you c
45. me carsten Create backup wxg files Initial path for home carsten Heeli options 7 code generation file dialogs append to filename append bak to filename Number of items in file history 4 Local widget path Number of buttons per row p 2 Jhomeycarsten wxgladejwidgets m in the main palette B Do Y Abbrechen Y OK 1 Abbrechen Figure 1 2 wxGlade preferences dialog 1 6 2 Environment Variables wxGlade supportes only one environment variable WXGLADE_CONFIG_PATH If you want to store the whole configuration data inclusive user generated templates and log files in a non default directory then store the full path of the alternative directory in the environment variable WXGLADE_CONFIG_PATH and start wxGlade with the new environment 1 6 3 Configuration Files wxGlade stores several internal information like configuration settings and log files in an own directory The location of this directory varies between different operating systems On Unix wxGlade uses wxglade On Microsoft Windows the infor mation will be stored in C Users username gt AppData Roaming Note Some components of the path will be translated to the users language on Microsoft Windows automatically and transparently in the Windows Explorer and other graphical applications Other applications show the original names The translation behaviour depends on the API used by the application deve
46. n a terminal window Example 1 1 Installing wxGlade at opt wxglade python setup py install prefix opt wxglade culiao masia running build running build_py creating build ercarang loud AA O SO 207 creating build lib linux 1686 2 7 wxglade creating build lib linux 1686 2 7 wxglade widgets creating build lib linux 1686 2 7 wxglade widgets combo_box Es copying docs html ch04s23 html gt opt wxglade share doc wxglade doc html copying docs html ch04s26 html gt opt wxglade share doc wxglade doc html copying docs html ch05s02 html gt opt wxglade share doc wxglade doc html copying docs html pr01 html gt opt wxglade share doc wxglade doc html creating opt wxglade share doc wxglade doc pdf copying docs pdf manual pdf gt opt wxglade share doc wxglade doc pdf creating opt share man creating opt share man manl copying docs man wxglade 1 gt opt wxglade share man manl copying docs man manpage xml gt opt wxglade share doc wxglade copying docs src manual xml gt opt wxglade share doc wxglade running install_egg_info Writing opt wxglade lib python2 7 site packages wxGlade 0 6 5_ py2 7 egg info After the installation has finished the wxGlade main script wxglade is located at lt install directory gt bin Execute the script to start wxGlade Example 1 2 Starting wxGlade at opt wxglade bin wxglade opt wxglade bin wxglade Starting wxGlade version 0 6 5 on Python 2 7 2
47. ode without starting the GUI use the g or generate code option with the language as argument as follows wxglade g lt LANGUAGE gt lt WXG File gt wxglade generate code lt LANGUAGE gt lt WXG File gt Possible values for LANGUAGE are XRC python perl lisp or C You can also specify the destination of the generated code with o or output option wxglade g lt LANGUAGE gt o lt DESTINATION gt lt WXG File gt The DESTINATION argument can be a file or a directory If DESTINATION is a file wxGlade will generate single file source code In case DESTINATION is a directory wxGlade will generate multiple file source code This is the complete description of the command line wxglade help Usage wxglade lt WXG File gt start the wxGlade GUI Ses wxglade lt Options gt lt WXG File gt generate code from command line Om wxglade version show programs version number and exit Ors wxglade h help show this help message and exit Options version show program s version number and exit wxGlade manual 11 50 cHe help show this help message and exit g LANG generate code LANG required output language valid languages are C XRC lisp perl python PAs Oi bir ia optional output file in single file mode or output directory in multi file mode Example Generate Python code out of myapp wxg wxglade o temp g python myapp wxg Report bugs to lt wxglade general lists sou
48. on 1 self set properties self do layout end wxGlade wxGlade manual 26 50 Size Set the widget size in pixels Background Set the background colour of the widget Foreground Set the foreground colour of the widget Font Set the font for widgets text elements Tooltip Set a tooltip for this widget Disabled Disable the widget Focused Sets the widget to receive keyboard input Hidden Hide the widget 3 4 3 Layout Properties The second tab is related to layout properties that control position and resizing within the sizer wxGlade manual 27 50 im O Properties lt text_ctrl1 gt O Position 1 Proportion Border 3 E Border wxALL L wxLEFT L wxRIGHT O wxTOP LC wxBOTTOM Alignment wxEXPAND O wxALIGN_RIGHT C wxALIGN_BOTTOM wxALIGN_CENTER_HORIZONTAL C wxALIGN_CENTER_VERTICAL wxSHAPED wxADJUST_MINSIZE O wxFIXED_MINSIZE Figure 3 13 Layout Properties These properties apply to any widget You can check or uncheck any option related to the placement in the sizer Many widgets may have a default value of 3 in the Border property in the Preferences Dialog see Section 1 6 1 Preferences Dialog If you let a widget have a default border the wxA11 option is also checked 3 4 4 Widget Properties The third tab named Widget is different f
49. on code to load and show a XRC resource usr bin env python import wx from wx import xrc GUI FILENAME test xrc GUI MAINFRAME NAME Main class MyApp wx App def OnInit self self res xrc XmlResource GUI FILENAME self frame self res LoadFrame None GUI MAINFRAME NAME self frame Show return True Glade name _ main app MyApp app MainLoop 2 9 Error Messages The following list are error messages should help you to find the reason and take corrective actions Please note the list is still incomplete Output path lt path gt must be an existing directory when generating multiple files Details You want to create multiple files for your design wxGlade expects an output directory in such case but the given output path isn t a existing directory Corrective Action Create the missing directory or select an existing output directory Output path lt path gt exists but the directory is not writable Corrective Action Choose a writable output directory Output path lt path gt can not be a directory when generating a single file Details You want to write your design into a single file wxGalde expects an output filename but the given output path is a directory Corrective Action Choose a file instead of a directory Output path lt path gt should be a directory when generating multiple files Details You
50. or each widget and lets you edit properties for the specific element you have selected wxGlade manual 28 50 jm O Properties lt text ctrl1 gt O x _widget events Code Figure 3 14 Widget Properties The set of options may also be quite complex in the case of widgets that have a great deal of methods and properties such as grids and tree views In this case wxGlade greatly simplifies the process of designing forms 3 4 5 Events Properties The fourth tab named Events lists the widgets events wxGlade generates an event handler stub and binds the event for each added handler name wxGlade manual 29 50 im O Properties lt text ctrl 1 gt Events Event Handler EVT TEXT EVT TEXT ENTER EVT TEXT URL EVT TEXT MAXLEN Figure 3 15 Events Properties 5 O Properties lt text ctrl 1 gt Events Event Handler EVT_TEXT MyEVTTEXT EVT TEXT ENTER EVT TEXT URL EVT TEXT MAXLEN Figure 3 16 Events Properties with entered event handler name Example 3 4 Generated Python code of an EVT TEXT event handler stub at line 12 1 class MyFrame wx Frame 2 def init self args xkwds 3 begin wxGlade MyFrame init wxGlade manual 30 50 kwds style wx DEFAULT FRAME STYLE wx Frame init self xargs xkwds self text ctrl 1 wx TextCtrl self 1 self set properties selts OMS OA self Bind wx EVT_TE end wxGlad
51. r code generation wxWidgets defaults are used instead Enable the property in the wxGlade GUI to set non default values see Figure 3 9 Changing Common Properties u ae WN nm wxGlade manual 24 50 5 O Properties lt text ctrl 1 gt O Name Jtext ct rll Enter different value Class Id SN Property name Enable disable input field Background J FFF Figure 3 9 Changing Common Properties Name Name of the instance created from Class Class Name of the subclass of the widget How this name affects code generation depends on the output language 5 O Properties lt dialog_1 gt Common widget code Name dialogi Class MyDialog Base class es Se Figure 3 10 Common Properties of a subclassed widget default behaviour Example 3 1 Generated Python code of a subclassed widget class MyDialog wxDialog def __init__ self xargs xkwds begin wxGlade MyDialog __init__ kwds style wxDEFAULT_DIALOG_STYLE wxDialog __init__ self xargs x kwds Base class es A comma separated list of custom base classes The first will be invoked with the same parameters as this class while for the others the default constructor will be used This property will be shown only for non managed widgets for instance wxFrame wxDialog wxNotebook wxPanel and wxSplitterWindow You should probably not use this if overwrite existing sourc
52. r this widget Add Remove Property Value MaxLength 10 Figure 3 18 Set extra property Example 3 5 Generated Python code for setting property MaxLength to 10 at line 14 class MyFrame wx Frame def __init_ self x args xxkwds begin wxGlade MyFrame init kwds style wx DEFAULT FRAME STYLE wx Frame init self xargs x x kwds self text ctrl 1 wx TextCtri self 1 self set properties self do layout end wxGlade def __set_properties self begin wxGlade MyFrame __set_properties self SetTitle frame 1 self text ctrl 1 SetMaxLength 10 end wxGlade 3 5 The wxGlade Menu wxGlade has only a few very small menus 3 5 1 The FILE Menu In the FILE menu there are the classic File New File Open and File Save items When opening or saving a new file the file dialog defaults to the directory that you put in the Initial path textbox in the Preferences dialog usually the user home directory The File Generate code item produces the code from the current design 3 5 2 The VIEW Menu In the VIEW menu you can show or hide the tree window and the properties window In this menu you access the Preferences Dialog as well wxGlade manual 32 50 3 5 3 The HELP Menu The HELP menu provides access to the wxGlade user manual this documentation as well as to the About dialog 3 6 Shortcuts Ctrl G Generate code from the cur
53. rceforge net gt or at lt http sourceforge net projects wxglade gt wxGlade home page lt http wxglade sourceforge net gt Note Use wxglade pyw instead of wxglade on Microsoft Windows 2 7 Using the Source Code There are a lot of options to control the source code generation process They are bundled in the Application page of the Properties window see Figure 3 6 Project Properties Application settings Let s talk about three of those options Single file Separate file for each class and Overwrite existing sources The first two options triggers wxGlade to generate one file with all classes inside or multiple files one per class widget The Single file option includes source and header file for C certainly The third option Overwrite existing sources is just about control Full control by wxGlade and Shared control It separated the two ways to work with wxGlade 2 7 1 Full Control by wxGlade If Overwrite existing sources is set wxGlade will re generated all source files and drop potential manual changes You ve to include the generated source files and use derived classes for implementing changes The files written by wxGlade are consistent always Also if e g classes or attributes are renamed Rewriting the whole files is less error prone in comparison with Section 2 7 2 Shared Control That is the advantages of this method This
54. rent GUI design Ctrl Import GUI design out of a XRC file Ctrl N Start a new GUI design Ctrl O Read a GUI design from a wxg file Ctrl S Save the current GUI design to a wxg file Shift Ctrl S Save the current GUI design to another wxg file Ctrl P Open a preview window for the current top level widget Ctrl Q Exit wxGlade Ctrl C Copy the selected item element text Ctrl V Insert clipboard content Ctrl X Cut the selected item element text F1 Show the wxGlade user manual this documentation F2 Show the Tree window F3 Show the Properties window F4 Show all application windows F5 Refresh the screen wxGlade manual 33 50 Chapter 4 Supported widgets 4 1 Introduction wxGlade supports a number of widgets and helps you to edit the properties and visual look of each one 4 2 Specifying the Path of Bitmaps In wxGlade some widgets need to specify a bitmap path You can use any graphic format supported by wx Widgets The bitmap can be specified in several ways Usually you can type an absolute path in a text box or browse for a bitmap with a file dialog This will produce a wxBitmap object with the typed string as bitmap path e g wxBitmap usr share icons application png wxBITMAP TYPE ANY You can enter a variable name using the var tag in the text box This will produce a wxBitmap object with the variable name as bitmap path e g var my bitmap path produces wxBitmap my
55. rger to show the new slot 3 3 Design Window The design window shows the frame or panel you are creating in WYSIWYG mode and allows you to select a widget from the main palette and to put it on an empty slot of a sizer You can show the design window by double clicking on the icon of a frame or dialog in the tree window O lt Design gt dialog 1 Personal Your Name Data Type here your name Figure 3 5 The Design Window By clicking with the right mouse button on a widget you can access the context menu Notice that the sizers which are invisible elements have a little gray handle that you can click to select the sizer or let the pop up menu appear The pop up menu is the same as the one you get in the Tree Window as shown in Figure 3 3 The menu for a widget or in Figure 3 4 The menu for a sizer wxGlade manual 19 50 3 4 Properties Window The properties window lets you see and edit the properties that apply to the selected element This window consists up to six different tabs All six tabs are not always present The visibility of the single tabs depends on the widget type Most widgets have a Common tab and a Code tab The combination of presented tabs depends on the widget type For example e wxFrame widgets have Common Widget and Code tabs e Spacers have the tabs Layout and Code e wxGridSizer widgets have Common
56. sell copies of the Software and to permit persons to whom the Software is furnished to do so subject to the following conditions The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software THE SOFTWARE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND EXPRESS OR IMPLIED INCLUD ING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM DAMAGES OR OTHER LIABILITY WHETHER IN AN ACTION OF CONTRACT TORT OR OTHERWISE ARISING FROM OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE wxGlade manual 50 50 Appendix D Licenses and Acknowledgements for Incorporated Software This section lists licenses and acknowledgements for third party software incorporated in wxGlade D 1 OrderedDict The OrderedDict class version 1 1 has been integrated The class is downloaded from http pypi python org pypi ordereddict and contains following notice Copyright c 2009 Raymond Hettinger Permission is hereby granted free of charge to any person obtaining a copy of this software and associated documentation files the Software to deal in the Software without restriction including without limitation the rights to use copy modify merge publish distribute sublicense and or sell copies of the Software and
57. sor to e Limit the first line to 72 characters or less e Reference issues and pull requests liberally wxGlade manual 44 50 Chapter 7 Installing and Designing own Widget Plugins wxGlade supports a simple plugin system for widgets to load all widgets at the application startup dynamically The plugin system loads all built in widgets like Static Text widget or the Gauge widget It also loads widgets installed by users 7 1 Widgets Packages The wxGlade plugin system supports two different types of widget packages 1 directory package a single directory with all necessary files inside 2 ZIP package a zipped version of a directory package Example 7 1 Directory package static text lt Directory named after the widget nam Alina joy lt Mostly an empty file or a file with just a comment codegen py lt Python and C code generators weoimicabe jony lt Widget configuration lisp codegen py lt Lisp code generator perl codegen py lt Perl code generator Ve EEC ALC ted ay lt wxGlade GUI code Example 7 2 ZIP package i layer L STETE Texts Alo Archive static text zip Length Date Time Name O 2013 12 09 10 02 static text SAS 2011 12 08 10902 icone ste eee init sdy 3352 20LI 12 09 TOs 02 static_text codegen py 340 ESO OO OZ static_text wconfig py LEAO OS ZO LO 02 static_text lisp_codegen py Ted 2013 12 08 10302 static t
58. t generating source files The page Settings contains the language specific settings of the active wxGlade project wxGlade manual 22 50 Properties app El Application Settings General Settings Indentation mode O Tabs Spaces Indent amount C Settings Source ext Header ext Figure 3 7 Project Properties Language settings Indentation mode Use spaces or tabs for indentation within the generated source files Indentation amount Number of spaces or tabs used for one indentation level Source ext Extension of the source file The extension doesn t has a leading dot wxGlade manual 23 50 Header ext Extension of the header file The extension doesn t has a leading dot 3 4 2 Common Properties The first tab contains the common properties that apply to all widgets As shown in Figure 3 8 Common Properties the common properties are related to name class size colors fonts and tooltip 5 O Properties lt text_ctrl1 gt O Common Layout widget Events Code Name text_ctrl_1 Class wxTextCtrl Id Size Background hoa ES Foreground 1b1918 ES E E O O O Font Tooltip Disabled Focused Hidden Figure 3 8 Common Properties The property name is a mangled version of the wxWidgets property name The property input field is disabled by default wxGlade won t use disabled properties fo
59. t least 2 4 or any later version of Python 2 e wxPython 2 8 or 3 0 Sometimes the wxPython module wxversion is packaged separately e g in Debian Please install the wxversion package manually in such case e wxWidgets 2 8 or 3 0 the wxWidgets are often bundled with wxPython wxWidgets is available at http www wxwidgets org and wxPython at http www wxpython org 1 4 1 Installation Requirements Building wxGlade packages from the Mercurial repository need additional software setuptools e setuptools hg 1 5 Installation wxGlade is available in four different package types 1 the sources packages zip and tar gz the full installer at Microsoft Windows wxGlade VERSION setup exe 2 3 the installer of the Standalone Edition at Microsoft Windows wxGlade SAE VERSION setup exe 4 current development version wxGlade manual 3 50 1 5 1 Download Official Release Packages All stable version are available for downloading at http sourceforge net projects wxglade Development Versions wxGlade manages source code in a Mercurial repository hosted on Bitbucket org You can fetch the whole repository from https bitbucket org agriggio wxglade using anonymous Mercurial hg access Alternatively you can download different source tarballs from https bitbucket org agriggio wxglade downloads too 1 5 2 Installing on Microsoft Windows The default installer requires a local instal
60. to permit persons to whom the Software is furnished to do so subject to the following conditions The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software HE SOFTWARE IS PROVIDED AS 15 WITHOUT WARRANTY OF ANY KIND EXPRESS OR IMPLIED INCLUDING BUT NO IMITED TO THE WARRANTIES OF RCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM DAMAGES OR OTHER LIABILITY WHETHER IN AN ACTION OF CONTRACT TORT OR OTHERWISE ARISING FROM OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE FE E E
61. tore the project in a XML file wx abbreviation for wxWidgets wxWidgets wxWidgets a widget toolkit and tools library for creating graphical user interfaces GUIs for cross platform appli cations wx Widgets is open source and written in C WYSIWYG What You See Is What You Get X11 The X Window System version 11 XRC XML based system for describing wx Widgets resources like dialogs menus or toolbars Those resources are loaded into the application at run time wxGlade manual 48 50 Appendix B Copyrights and Trademarks wxGlade is copyright 2002 2007 by Alberto Griggio Use and distribution of wxGlade is governed by the MIT license located in Appendix C wxGlade License Agreement wxWidgets is copyright C 1998 2005 Julian Smart Robert Roebling et al See http www wxwidgets org for details Microsoft and Windows are registered trademarks of Microsoft Corporation UNIX is a registered trademark of The Open Group All other trademarks are property of their respective owners wxGlade manual 49 50 Appendix C wxGlade License Agreement Copyright c 2002 2007 Alberto Griggio Copyright c 2011 2015 Carsten Grohmann Permission is hereby granted free of charge to any person obtaining a copy of this software and associated documentation files the Software to deal in the Software without restriction including without limitation the rights to use copy modify merge publish distribute sublicense and or
62. utton id If you use a variable name you have to provide extra code in the generated source code Choose the type of the button Normal Checkable or Radio You can move toolbar buttons with Up and Down buttons You have to enter two bitmaps one for normal status and the other for the pushed status Refer to Section 4 2 Specifying the Path of Bitmaps for bitmap path specifications jm Toolbar editor nx Tool Id e PD Short Help Long Help Po Event Handler Po Normal Bitmap gt Second Bitmap bo B Normal Bitmap S Type o Normal O Checkable O Radio gt Add Figure 5 3 Toolbar editor wxGlade manual 40 50 Chapter 6 wxGlade technical notes O Caution Last update 2003 06 26 but only Section 6 9 Contributing to wxGlade The rest has not been updated since 2002 07 22 and it s likely be very outdated in some parts This is an informal overview of wxGlade internals made through a sample session of use Each action of the hypotetical user will be described from the point of view of the application to hopefully understand what s happening behind the scenes These notes are absolutely incomplete and in some cases they might be outdated or not completely correct the best reference is always the source code 6 1 Startup The program starts from the function main in the module main this creates an instance of wxGlade a subc
63. wxGlade manual wxGlade manual wxGlade manual ii Contents Preface ix 1 Introduction to wxGlade 1 1 1 Whatis wxGlade scams Dm as fede oe wae aa es oe Oba va a de be a ee ae wal ee 1 1 2 What can you do with wxGlade 2 a a a a a 2 13 Whatis wxGlade NOTO au suma da ee A Sa Ye Ra po ELE eR ke Ve PN ee ee Ge E 6 2 1 4 Requirements and Supported Platforms 002 ee ee 2 1 4 1 Installation Requirements 2 2 0 0 ee 2 1 5 Installation sessao oS Rae st RAR SO NB UG E A aa da 2 Lo Download sa Se al a E Udo ba ee al o DE eae Oe 3 1 5 2 Installing on Microsoft Windows 3 1 5 3 Installing on Unix Unix like Operating Systems 2 20 0 0 000 0000000000 3 1 5 4 Installing from Source 2 e 3 1 5 5 Troubleshooting s oco c sacer regane a a i E a 3 1 6 Configuring WXGlade s s s a acae gua A e E Bee ee EE e E 5 1 6 1 Preferences Dialogs es ce aaret Ree eA ee ERAS EE ee eee ee A ee 5 1 6 2 Environment Variables soos e coea meo aa mea Gm abra a GRR RA G a 6 1 6 3 Configuration Files dera a IS a a Pa E eR Ud 6 G 6 1 7 HowtoReportaBug 0 02000 a a a 7 1 8 Deprecated Features sua gua sa aee eR eR ee ae RS E CEL A ee a q 2 Exploring wxGlade 8 21 Quick Example es aha eee ae e aa Aa OS RA a e 8 2 2 Basicsol wxGlade 244 25 400 perra a SE E Lae RE Se 9 2 3 ESCAPE Sequences s coe Be eee a A ea ee RA de ee 9 2A Best Practice poa Se SE Re ES eS Oe Be a ea we Gg a e
Download Pdf Manuals
Related Search
Related Contents
Gembird A4-G501 headset mode d`emploi Biotracker product sheet 1 安全のために必ず守ってください Multicontroller Speedlink 5501 CACND - Controle de acesso para garagens em condomínios O Copyright © All rights reserved.
Failed to retrieve file