Hi,
I wish to use an easy way to generate reports from wxPython and feel
wxHtmlEasyPrinting could be a good solution.
I now need to generate the HTML wxHtmlEasyPrinting can print: I need to have
a title followed by lines of text that do not look too ugly. If possible I
would like to use an existing module.
Q1) Is there such a module ?
Q2) Is my approach fairly good ?
Regards,
Philippe 14 2560
PS: I am looking at the formatter module which seems to be related to HTML
somehow, but without any code sample I'm a bit lost
Philippe C. Martin wrote: Hi,
I wish to use an easy way to generate reports from wxPython and feel wxHtmlEasyPrinting could be a good solution.
I now need to generate the HTML wxHtmlEasyPrinting can print: I need to have a title followed by lines of text that do not look too ugly. If possible I would like to use an existing module.
Q1) Is there such a module ? Q2) Is my approach fairly good ?
Regards,
Philippe
You could generate your report in reStructuredText
format (Google is your friend) and then convert
them in HTML, PS, PDF, etc.
Michele Simionato
Am Thu, 09 Jun 2005 12:43:19 +0000 schrieb Philippe C. Martin: Hi,
I wish to use an easy way to generate reports from wxPython and feel wxHtmlEasyPrinting could be a good solution.
I now need to generate the HTML wxHtmlEasyPrinting can print
I don't know wxPython, but generating HTML is very easy.
Some people say mixing HTML and programming code is not good.
But if you want to create dynamic pages with more logic than HTML
this is the best solution.
Example: Multiplication Table
rows=[]
heading=[]
for i in range(1, 11):
heading.append('<th bgcolor="grey">%s</th>' % i)
cols=[]
for j in range(1, 11):
cols.append('<td align="right">%s</td>' % (i*j))
row='<tr><th bgcolor="grey">%s</th>%s</tr>' % (i, ''.join(cols))
rows.append(row)
html="""
<html>
<head><title>Multiplication Table</title></head>
<body>
<table border="1">
<tr>
<th> </th> %s
</tr>
%s
</table>
</body>
</html> """ % (''.join(heading), ''.join(rows))
I guess this looks more ugly in most template languages.
HTH,
Thomas
--
Thomas Gttler, http://www.thomas-guettler.de/
I'll take a pick thanks - I like the fact it's buit-in (no extra
installation)
Michele Simionato wrote: You could generate your report in reStructuredText format (Google is your friend) and then convert them in HTML, PS, PDF, etc.
Michele Simionato
Thanks a bunch,
I'm currently playing with HTMLGen (great but not in Python distrib ...) and
it look very good - Yet your code example looks simple enough for me to
look at that alternative.
Thomas Guettler wrote: Am Thu, 09 Jun 2005 12:43:19 +0000 schrieb Philippe C. Martin:
Hi,
I wish to use an easy way to generate reports from wxPython and feel wxHtmlEasyPrinting could be a good solution.
I now need to generate the HTML wxHtmlEasyPrinting can print
I don't know wxPython, but generating HTML is very easy.
Some people say mixing HTML and programming code is not good.
But if you want to create dynamic pages with more logic than HTML this is the best solution.
Example: Multiplication Table
rows=[] heading=[] for i in range(1, 11): heading.append('<th bgcolor="grey">%s</th>' % i) cols=[] for j in range(1, 11): cols.append('<td align="right">%s</td>' % (i*j)) row='<tr><th bgcolor="grey">%s</th>%s</tr>' % (i, ''.join(cols)) rows.append(row) html=""" <html> <head><title>Multiplication Table</title></head> <body> <table border="1"> <tr> <th> </th> %s </tr> %s </table> </body> </html> """ % (''.join(heading), ''.join(rows))
I guess this looks more ugly in most template languages.
HTH, Thomas
I looked at HTMLGen a while ago- I didn't see what the advantage was.
I wrote soem code similar to the example above, to generate a page..
It worked out fine.
However, I want to add HTML ouput to many of my other python programs,
and I don't want to re-write this for each program. So some higher
level of abastraction is needed, but I don't know how just yet.
HTMLGen is no longer maintained, so I don't know what the best choice
is.
If you know the basics of HTMl, you can write a simple class to write
the html, and just call a method from your program, so your app does
not have any HTML in it.
Philippe C. Martin wrote: Thanks a bunch,
I'm currently playing with HTMLGen (great but not in Python distrib ...) and it look very good - Yet your code example looks simple enough for me to look at that alternative.
Thomas Guettler wrote:
Am Thu, 09 Jun 2005 12:43:19 +0000 schrieb Philippe C. Martin:
Hi,
I wish to use an easy way to generate reports from wxPython and feel wxHtmlEasyPrinting could be a good solution.
I now need to generate the HTML wxHtmlEasyPrinting can print
I don't know wxPython, but generating HTML is very easy.
Some people say mixing HTML and programming code is not good.
But if you want to create dynamic pages with more logic than HTML this is the best solution.
Example: Multiplication Table
rows=[] heading=[] for i in range(1, 11): heading.append('<th bgcolor="grey">%s</th>' % i) cols=[] for j in range(1, 11): cols.append('<td align="right">%s</td>' % (i*j)) row='<tr><th bgcolor="grey">%s</th>%s</tr>' % (i, ''.join(cols)) rows.append(row) html=""" <html> <head><title>Multiplication Table</title></head> <body> <table border="1"> <tr> <th> </th> %s </tr> %s </table> </body> </html> """ % (''.join(heading), ''.join(rows))
I guess this looks more ugly in most template languages.
HTH, Thomas
Philippe C. Martin wrote: Hi,
I wish to use an easy way to generate reports from wxPython and feel wxHtmlEasyPrinting could be a good solution.
I now need to generate the HTML wxHtmlEasyPrinting can print: I need to have a title followed by lines of text that do not look too ugly. If possible I would like to use an existing module.
Q1) Is there such a module ? Q2) Is my approach fairly good ?
There are many ways to do this. The simplest is just to mix HTML and Python code in your own module, as Thomas has shown. This is quick and easy to do but IMO it doesn't scale well to large pages or large number of pages; the mix of raw HTML and Python code is hard to work with.
This page lists many alternatives: http://wiki.python.org/moin/WebProgramming
The interesting categories from that page:
"Templating Engines" provide a way to describe the HTML that is more-or-less independent of the code. They vary widely in style. If you want a lot of control over the generated HTML you probably want to use one of these.
"HTML Shorthand Processors" provide an alternate way to specify markup and a program to convert the markup to HTML. reStructuredText is in this category. To use one of these you would still have to generate the alternate markup in your program similar to the simple HTML method.
"HTML Generation class libraries" are libraries that make it easier to create HTML programmatically. This can be a good approach if the HTML is simple. I guess you can add many Python XML libraries to this category as well; for example you could use ElementTree to generate a model of an XHTML page and output it.
Choosing within the categories depends a lot on personal preference, you just have to find a package whose style you like and whose features fit your needs.
HTH,
Kent
Thanks
Kent Johnson wrote: Philippe C. Martin wrote: Hi,
I wish to use an easy way to generate reports from wxPython and feel wxHtmlEasyPrinting could be a good solution.
I now need to generate the HTML wxHtmlEasyPrinting can print: I need to have a title followed by lines of text that do not look too ugly. If possible I would like to use an existing module.
Q1) Is there such a module ? Q2) Is my approach fairly good ?
There are many ways to do this. The simplest is just to mix HTML and Python code in your own module, as Thomas has shown. This is quick and easy to do but IMO it doesn't scale well to large pages or large number of pages; the mix of raw HTML and Python code is hard to work with.
This page lists many alternatives: http://wiki.python.org/moin/WebProgramming
The interesting categories from that page: "Templating Engines" provide a way to describe the HTML that is more-or-less independent of the code. They vary widely in style. If you want a lot of control over the generated HTML you probably want to use one of these.
"HTML Shorthand Processors" provide an alternate way to specify markup and a program to convert the markup to HTML. reStructuredText is in this category. To use one of these you would still have to generate the alternate markup in your program similar to the simple HTML method.
"HTML Generation class libraries" are libraries that make it easier to create HTML programmatically. This can be a good approach if the HTML is simple. I guess you can add many Python XML libraries to this category as well; for example you could use ElementTree to generate a model of an XHTML page and output it.
Choosing within the categories depends a lot on personal preference, you just have to find a package whose style you like and whose features fit your needs.
HTH, Kent
Cappy2112 wrote: I looked at HTMLGen a while ago- I didn't see what the advantage was. I wrote soem code similar to the example above, to generate a page.. It worked out fine.
However, I want to add HTML ouput to many of my other python programs, and I don't want to re-write this for each program. So some higher level of abastraction is needed, but I don't know how just yet.
HTMLGen is no longer maintained, so I don't know what the best choice is.
If you want an alternative to HTMLGen that is still maintained, you
might want to try XIST ( http://www.livinglogic.de/Python/xist)
A few simple examples can be found here: http://www.livinglogic.de/Python/xist/Examples.html
Bye,
Walter Drwald
"Philippe C. Martin" <ph******@philippecmartin.com> writes: PS: I am looking at the formatter module which seems to be related to HTML somehow, but without any code sample I'm a bit lost
As others have noted, if you need any computation at all, it is easier
to write directly in python.
I came to python from perl, where I used CGI.pm. To get that effect,
I wrote my own CGIpm.py and used it for a while. http://www.seanet.com/~hgg9140/comp/index.html
But (at the suggestion of others in this newsgroup), I then tried
writing directly. The net effect is trivial html generation, with all
the power of python at your fingertips.
Note:
To save even more time, I made a CGI template that includes this main:
#============================
if __name__=="__main__":
mystart()
#cgi.print_environ_usage()
#cgi.print_environ()
form = cgi.FieldStorage()
try:
if len(form)==0:
send_form1()
else:
form_name=form['form_name'].value
if form_name=='form1':
recv_form1()
except StandardError, e:
print "\n<BR>ERROR: %s\n" % e
myend()
To support a stateless world:
1. Each form has a send_xyz and recv_xyz function. The end of each
recv_xyz decides what send_xyz to do next.
2. mystart and myend handle opening and closing the http and html.
They also handle state save/restore as needed (pickle or database).
Philippe C. Martin wrote:
Hi,
I wish to use an easy way to generate reports from wxPython and feel wxHtmlEasyPrinting could be a good solution.
I now need to generate the HTML wxHtmlEasyPrinting can print: I need to have a title followed by lines of text that do not look too ugly. If possible I would like to use an existing module.
Q1) Is there such a module ? Q2) Is my approach fairly good ?
Regards,
Philippe
-- ha************@boeing.com
6-6M21 BCA CompArch Design Engineering
Phone: (425) 294-4718
Thanks
Walter Dörwald wrote: Cappy2112 wrote: I looked at HTMLGen a while ago- I didn't see what the advantage was. I wrote soem code similar to the example above, to generate a page.. It worked out fine.
However, I want to add HTML ouput to many of my other python programs, and I don't want to re-write this for each program. So some higher level of abastraction is needed, but I don't know how just yet.
HTMLGen is no longer maintained, so I don't know what the best choice is.
If you want an alternative to HTMLGen that is still maintained, you might want to try XIST (http://www.livinglogic.de/Python/xist)
A few simple examples can be found here: http://www.livinglogic.de/Python/xist/Examples.html
Bye, Walter Dörwald
PS: Just wanted to add that HTMLGen works very well and outputs html that
wxHtmlEasyPrinting and my email client have not problem reading (I output
student grades, missing assignments, ... in tables).
The one gitch is they do not have any installation program (that I've seen)
for windows.
Regards,
Philippe
Walter Dörwald wrote: Cappy2112 wrote: I looked at HTMLGen a while ago- I didn't see what the advantage was. I wrote soem code similar to the example above, to generate a page.. It worked out fine.
However, I want to add HTML ouput to many of my other python programs, and I don't want to re-write this for each program. So some higher level of abastraction is needed, but I don't know how just yet.
HTMLGen is no longer maintained, so I don't know what the best choice is.
If you want an alternative to HTMLGen that is still maintained, you might want to try XIST (http://www.livinglogic.de/Python/xist)
A few simple examples can be found here: http://www.livinglogic.de/Python/xist/Examples.html
Bye, Walter Dörwald
"Philippe C. Martin" <ph******@philippecmartin.com> wrote in message news:HP****************@newssvr12.news.prodigy.com ... Hi,
I wish to use an easy way to generate reports from wxPython and feel wxHtmlEasyPrinting could be a good solution.
I now need to generate the HTML wxHtmlEasyPrinting can print: I need to have a title followed by lines of text that do not look too ugly. If possible I would like to use an existing module.
Q1) Is there such a module ? Q2) Is my approach fairly good ?
There is one huge problem with wxHtml and consequently wxHtmlEasyPrinting. It
doesn't understand stylesheets in any way. There are many packages that
generate HTML, but they all expect a lot of the styling to be handled by
CSS. It is also a lot easier to write that way.
I would absolutely love a piece of code that could take CSS and HTML and
apply the CSS to the HTML to get the right appearance, but without any
CSS left. For example it would turn CSS formatting for class/div/span
into HTML attributes, as well as overal formatting instructions.
I did do something similar for BitPim but it requires the HTML to be perfect
and the CSS is actually a Python data structure expressing the attributes and
how they get applied. I'd love to replace it with something better.
But ultimately it does work.
Roger
Philippe C. Martin wrote: I now need to generate the HTML wxHtmlEasyPrinting can print: I need to have a title followed by lines of text that do not look too ugly. If possible I would like to use an existing module.
How to do this really depends on what your data looks like, and how you
get it. E.g. if you just want uniform pages with paragraphs of plain
texts with headings in between, you can just make a template HTML file
with the main block of text replaced with %s, and then do something like:
text = []
for heading, paragraph in data_source:
text.append('<h2>%s</h2>' % heading)
text.append(paragraph)
templ = open('template.html').read()
print templ % '\n'.join(text)
If your data has more structure, you might find a tool like Fredrik
Lundh's elementtree useful. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dan Gass |
last post by:
The difflib.py module and the diff.py tools script in Python 2.4 alpha
3 now support generating side by side (with intra line differences) in
HTML format. I have found this useful for performing...
|
by: Tim Henderson |
last post by:
Hi
I want to dynamically generate a graph in python that would be
displayable on a web page. What would be the best way to do this?
The reason I want to do this, is because I am making a program...
|
by: Tim Daneliuk |
last post by:
I use a makefile to create distribution tarballs of freestanding Python
programs and their documentation. I cannot seem to find the right
command line option to just generate a pyc/pyo file from...
|
by: Xah Lee |
last post by:
# -*- coding: utf-8 -*-
# Python
# David Eppstein of the Geometry Junkyard fame gave this elegant
# version for returing all possible pairs from a range of n numbers.
def combo2(n):
return...
|
by: Michele Simionato |
last post by:
What is the recommended way of generating HTML from Python? I know of
HTMLGen and of
few recipes in the Cookbook, but is there something which is more or
less standard?
Also, are there plans to...
| |
by: Andreas Jung |
last post by:
Hi,
does anyone know of a high-level solution to produce RTF from Python
(something similar to
Reportlab for producing PDF)?
Thanks,
Andreas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG...
|
by: flupke |
last post by:
Hi,
i create my GUIs mainly via wxGlade. However when you start of to
program and want to do some rearranging to the gui, wxglade overwrites
your file and you've got to put your own code back...
|
by: Xah Lee |
last post by:
The following is a program to generate thumbnail images for a website.
Useful, if you want to do that.
It is used to generate the thumbnails for my “Banners, Damsels, and
Mores” project...
|
by: Sebastian Bassi |
last post by:
Hello,
What are people using these days to generate HTML? I still use
HTMLgen, but I want to know if there are new options. I don't
want/need a web-framework a la Zope, just want to produce...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |