go ahead... be a heretic | |
PerlMonks |
Code & GUI created based on data structure?by jdtoronto (Prior) |
on Jun 27, 2006 at 18:52 UTC ( [id://557857]=perlquestion: print w/replies, xml ) | Need Help?? |
jdtoronto has asked for the wisdom of the Perl Monks concerning the following question:
Esteemed monks, I have a situation where I think I need some method of essentially creating GUI code based on a data structure, and have code execute itself based on the same structure. Here is my scenario: I have an application which needs to be able to send PDF documents which are customised, either by email or to a printer. Currently I create a PDF file as a 'template' which has the basic content in it. Data from a database is used to customise the PDF, it might be an address block for a sales letter, or it might be specific text or graphics which are inserted based on user preferences. All of this is currently working. I have a PDF, I have a Perl-Tk GUI window which creates a Config::Simple file which has the necessary config info. I can cusomtise the document and do what I need with it. BUT, and there is always a BUT. What about when I need to change documents? I was thinking that I could package the PDF and a config data structure in a zip like package and when the user selects the template the structure is loaded into the config. BUT what if the structure of the document is different? The GUI that has been coded will no longer match the data structure that is needed. So... How about I build the GUI based on the structure of the data? Then the same data structure could be used to run through a sequence of methods within the templating module. There are actually only maybe 5 methods required to place the data in the template and output it. But some of these 5 might be invoked multiple times depending on the data - getting things like the text position, colour, font choice and size form teh data structures. Am I proposing something that is out of left field? Any suggestions, any pointers to something like this that may already exist.
Back to
Seekers of Perl Wisdom
|
|