> You should rephrase the question: Why use python code ?
> Particularly for larger projects using ressources makes the maintenance
> way easier. You just change the xrc file and the dialog will be fine.
> In one of my apps I went even further. I wrote custom xml handlers that
> pull information out of a database. I now can just add an entry to a
> table telling the system to store values in field "ID_SOME_FIELD" into a
> specific database column/table, or to do a certain validation. Works
> great. The only thing about XRC is that some customizations aren't as
> easy as with python code, but once you have written a custom handler it's
> a breeze.
Could you elaborate a bit more on the customizations you made? Particularly
the database part is very interesting to me.
You can see the database part in the attached demo handler. The _attr variable
is a database row abstraction class instance, which allows accessing the
columns by name.
The table layout is:
CREATE TABLE public.ib_dialog
(
id int4 NOT NULL DEFAULT nextval('ib_dialog_seq'::text),
dialog varchar(255),
field varchar(255),
field_type varchar(255),
field_mask varchar(255),
autoformat varchar(255),
validator varchar(255),
mandatory bool DEFAULT 'f',
dbtable varchar(255),
dbfield varchar(255),
message varchar(255),
mandatory_mask varchar(255),
field_mask_format varchar(255),
decimals int4 DEFAULT 2,
CONSTRAINT ib_dialog_pkey PRIMARY KEY (id)
)
Are your XML handlers parsed with Python? Are you using XML-RPC?
Yes and No. The XML handlers are normal python classes. I attached one of
them, maybe you can see what I did. There's also some documentation on
writing own XML handlers in the wxwindows docs.
I'm using Twisted perspective broker as network layer (www.twistedmatrix.com).
In fact, the "not as easy as with python code" customizations were the ones
that drove me to write my first message. That and some worry with
performance.
Due to the above, if I have to add another say checkbox to the dialog I just
add it and also add a row in the ib_dialog table to tell the system which
databasefield to store the value to and which validator to use for that. All
the "mask" values in the table define the mask used in conjunction with the
maskedTextCtrl class.
Performance was never an issue. Currently the xrc file contains some 60
dialogs and has a total size over 1 MB - I can't notice anything slow about
it.
The problem with customization is that for anything special you want to do you
have to modify the Handler code - and if it's only one widget in one dialog
you want to behave differently you have to write a completely new one using a
custom class in the xrc file just to address that little thing.
Hope that helps
UC
- --
Open Source Solutions 4U, LLC 2570 Fleetwood Drive
Phone: +1 650 872 2425 San Bruno, CA 94066
Cell: +1 650 302 2405 United States
Fax: +1 650 872 2417
demo.py (2.34 KB)
···
On Friday 30 April 2004 06:11 pm, Jorge Godoy wrote:
On Sex 30 Abr 2004 19:36, Uwe C. Schroeder wrote: