using RADs in object-oriented way

Torsten Marek shlomme at gmx.net
Wed May 21 07:43:24 EDT 2003


Serge Boiko schrieb:
> Hi, there,
> I have a question regarding the usage of IDE/RAD tools with Python, but the
> problem might be more general and equally can be applied to any
> language (see Allen Holub's notes on IDE/RADs for Java:
> http://www.javaworld.com/javaworld/jw-07-1999/jw-07-toolbox.html). 
> 
> When I use IDE/RAD I can easily create a GUI for my
> application. Initially this GUI may consist of the standard components
> provided by my IDE of choice. Usually I don't edit the code created by IDE
> directly.  Instead I subclass the container class (i.e. the
> application skeleton) and fill it with the contents and functionality
> I want.  This gives me an important flexibility: I don't have to
> change my code if I modified a file created by the RAD tool. Put it
> another way: any cosmetic changes of my application don't affect the
> functional part, these parts live in separate modules.
> 
> This approach works fine if I use *STANDARD* components. But what if
> instead of plain standard button presented by the class StandardButton
> I want to use a button of the class MyButton derived from
> StandardButton and my RAD doesn't provide facilities to add custom
> widgets written in Python? Surely, I could remove an instance of the
> StandardButton from the container widget and replace it with an
> instance of MyButton (again in the module that contains my
> functionality and is not generated by the RAD). This approach is not
> applicable to every situation, however. For complex layouts it may
> cause unpredictable results. An alternative solution is to extend
> functionality of the StandardButton dynamically adding/overriding
> methods of StandardButton at runtime. See recipe 5.12 in the Python
> Cookbook. It works if we need to modify our base class functionality
> only slightly.
> 
> More general approach would be to use some refactoring techniques but
> it implies that my IDE supports them. By the way is there any IDE that
> can do that?
> 
> So my question is: how to deal with such a situation in an
> object-oriented and reusable way, to separate RAD generated code for
> manually coded stuff? 
> 
> If these words are too abstract I could give a simple Python example.
> 
> Many thanks and looking forward to hearing from you, Python gurus!
> -Serge
> 
> 
Adding and using custom widgets is possible with the Qt Designer and
PyQt. You can even define which properties, signals and slots the widget
has (unfortunately, you cannot say that this widget is a subclass of
another widget). To use them, you can add python code prefixed with
"python:" into the widget comment, which will be put into the file
generated by pyuic.
I do not know whether you are interested in PyQt, because it is said to
be not as intuitive as eg. wxPython, but you might give it a try. For
furhter questions, feel free to contact the PyQt mailing list
(pykde at mats.gmd.de) or visit the PyQt homepage at
www.riverbankcomputing.co.uk.

greetings

Torsten





More information about the Python-list mailing list