Re: [Boa Constr] Contrib: makepy dialog for Boa
Status: Beta
Brought to you by:
riaan
From: Riaan B. <riaan@e.co.za> - 2001-04-09 23:22:33
|
Hi Mike, thanks for the contribution, it's now integrated with Boa and accesible from the 'New' palette page. To expand the COM support in Boa I've added Acrobat and IE as examples. I have not automated the process and there is some manual work to get a COM control integrated in Boa. Like other controls you have to write a Companions class for the COM control. See Companions.ComCompanions for examples. Additionally you have to write a thin wrapper for the ActiveX control itself, this makes it look more like a normal control to Boa and allows it better integrate with current machinery. This could be automated. See bcrtl.activex.acrobat and bcrtl.activex.IE for details. Note that for IE I have added code which translate the Python COM events to wxWindows events so that they may be defined in the Inspector. This was a mechanical process and could definitely be automated as well. This is a first draft at COM support and everything may still change. COM properties aren't supported yet. Note that now for the first time Boa needs to have a run time library. Before, all code was generated to run on wxPython libraries but the extra COM control layer needs to be accessible to your generated source. For now I've decided to place this run time library under wxPython.lib. If you wrap a COM control, the new module must be placed under here. e.g. wxPython.lib.bcrtl.activex.acrobat. This will also apply to any new control you wish to add to Boa which is not part of the wxPython distribution. Place these controls modules under wxPython.lib.bcrtl.user. One problem may me wxPython's very aggresive uninstaller which deletes everything under the wxPython directory. For deployment I think Boa should also be able to generate source that uses components defined in the application's own directory. Also in this direction, Boa should make it much easier to to use visual objects defined in an application, but for which there is no associated Companion (defining design time logic). Boa should simply handle such objects as their base classes, e.g wxListCtrl or wxStaticText or whatever. I've put in a check so that Boa automatically creates/copies these files if they do not exist on startup. There is also an option in Preferences.py, blockCOM which is on by default (because of the crasing under win9x). Turn off the block to enable COM. "Mike C. Fletcher" wrote: > > I wanted to play around with Boa as an IDE a little more, so I decided I'd > make a MakePy dialog for it (a Win32COM thing that lets you auto-generate > wrappers for COM controls). It's slightly more advanced than the dialog in > PythonWin, as it lets you search for libraries. This isn't particularly > beautiful, but it does seem to work. Eventually you'd want to create > Design-time controls and options on the design palette for each wrapped > control (maybe even scanning the gen_py directory for controls generated by > other systems), but for now it's just a "tell it to generate a wrapper" > dialog. One problem at the moment is that it generates different type libraries than the EnsureModule call that is used when ActiveX controls are used in wxPython. If the library is generated from the Dialog, the controls no longer work in wxPython. (Test this with the demo). I believe that the EnsureModule behavior should be the default behaviour. It also generates the methods which it useful. Can you change your dialog to work like this? > > Thoughts that have arisen as I worked: > An option for PythonWin key bindings would be nice (is there a way to > plug-in whole key-binding sets with minimal fuss?). See PrefsKeys, I believes this meets your requirements. > Block indent/dedent mapped to tab/shift-tab is very useful To use Tab for indent dedent was one of the few keys that could not be mapped from PrefsKeys because the keys in PrefsKeys are bound with an accelerator table and when a key is bound in a table, it does not generate key events in the control anymore (which I needed) I've duplicated the logic in the Indent/Dedent methods so the key tab is no longer needed and tab/shift tab indenting now works. I'm not convinced this should be default tho. > Block-comment/uncomment mapped to Alt-3, Alt-4 is nice > Ctrl-G mapped to Goto Goto what? Line number? > Option for tab-preservation/conversion wasn't immediately obvious in the > interface, possibly in the preferences. Boa is rather harsh in this respect. No tabs preserved. As the style guide says 4 space tab levels, this is enforced. > Tools to tabify/untabify source are needed. Running Edit->Reindent whole file will remove all tabs and correct a few other things, this is non reversable. > Auto-complete windows a-la PythonWin are very helpful (for me anyway). There is limited auto-complete support, pressing control space after 'self.' will bring up a list of all methods/attribute for that object defined in the current module. wxPython object decendants brings up a list of all methods in the wxPython libraries. Ctrl-Space without 'self.' in a class will bring up the entire wxPython namespace. Shift-Space for parameter tips, but there is very little support here. Note that sometimes you'll have to refresh your code (Ctrl-R) (so the source is reparsed) before the code completion box will appear. > Might be nice to have an option that makes the "interface" text get wrapped > in _( ) for internationalisation (or whatever the standard is), with the > files generated for translators on the side. Yes this seems like a good idea, I have no experience with this and if someone gives me the exact requiremnets I'll look into implementing it. > The trace/error window doesn't appear until the client process completes > and doesn't seem to update if I have to kill the client process. Makes it > hard to use with mis-behaving apps. I'm at the mercy of popen2 here, sometimes you get output when you nuke an app or it crashes, sometimes you don't, suggestions would be welcome. Another painful fact is that both wxProcess and popen blocks if they run a GUI application and only writes to their output and error streams after the app terminates, I know of no workarounds. wxProcess also has other problems when spawning GUI applications. > Option in the inspector to auto-generate shortcuts would be cool. > Would be good to have option to auto-generate a test-harness application > for dialogs/frames. See the attached for a simplistic harness. Such a feature is already part of Boa. On the Source View select Edit -> Add simple app. Not this this applies only to wxFrames at the moment, for Dialogs the code has to be a little different. I will still fix this. This is the code that should be added for Dialogs: if __name__ == '__main__': app = wxPySimpleApp() dlg = create(None) try: dlg.ShowModal() finally: dlg.Destroy() Destoying the dialog is not strictly necessary as the process will always terminate after ShowModal... Ok, I've just fixed it so that Dialogs get the above code. Model.getSimpleRunnerSrc() now returns the runner code for the module type. Intersting question is what should a normal python module get here? For now the following lines are added to plain python scripts: if __name__ == '__main__': pass # add a call to your main function here > > Module attached, enjoy yourselves, > Mike Thanks for the code and feedback, > > __________________________________ > Mike C. Fletcher > Designer, VR Plumber > http://members.home.com/mcfletch > > ------------------------------------------------------------------------ > Name: makepydialog.py > makepydialog.py Type: Plain Text (text/plain) > Encoding: quoted-printable -- Riaan Booysen ___________________________________________________ Boa Constructor - RAD GUI building IDE for wxPython http://boa-constructor.sourceforge.net |