Hello All
Look at my example
Example:
_sql = “Select * from customer”
cursor.execute(_sql)
reg = cursor.fetchall()
for x in reg:
customer = x[“customer”]
html_text = “”"
<html>
<body>
<table>
<tr>
<td>%s</td>
</tr>
</table>
</body>
</html>
""" % (customer)
This code returns only last customer, how I fill all customers in
???
I am creating this code to use with a HtmlEasyPrinting
Thanks !
|
Hi Fernando,
Hello All
Look at my example
Example:
_sql = "Select * from customer"
cursor.execute(_sql)
reg = cursor.fetchall()
for x in reg:
customer = x["customer"]
html_text = """
<html>
<body>
<table>
<tr>
<td>%s</td>
</tr>
</table>
</body>
</html>
""" % (customer)
This code returns only last customer, how I fill all customers in <td> ??? I am creating this code to use with a HtmlEasyPrinting
Thanks !
This is technically not a wxPython question, but it's an easy one, so I'll give it a shot. Something like the following *untested* code should do the trick:
<code>
_sql = "Select * from customer"
cursor.execute(_sql)
reg = cursor.fetchall()
html_text = """
<html>
<body>
<table>
<tr>
"""
for x in reg:
customer = x["customer"]
html_text = html_text + "<td>%s</td>" % customer
html_end = """ </tr>
</table>
</body>
</html>
"""
html_text = html_text + html_end
</code>
Hope that gets you going or at least shows you how to do it.
···
-------------------
Mike Driscoll
Blog: http:\\blog.pythonlibrary.org
Python Extension Building Network: http:\\www.pythonlibrary.org
Thanks to all.
I have another question on HTML, is possible to set css style ???
···
----- Original Message ----- From: "Tim Roberts" <timr@probo.com>
To: <wxpython-users@lists.wxwidgets.org>
Sent: Tuesday, June 03, 2008 3:01 PM
Subject: Re: [wxpython-users] Html in wxPython
Fernando Paiva wrote:
Hello All
Look at my example
Example:
_sql = "Select * from customer"
cursor.execute(_sql)
reg = cursor.fetchall()
for x in reg:
customer = x["customer"]
html_text = """
<html>
<body>
<table>
<tr>
<td>%s</td>
</tr>
</table>
</body>
</html>
""" % (customer)
This code returns only last customer,
Of course it does. Your loop fetches each result, one at a time, and throws away all of them except the last one.
how I fill all customers in <td> ??? I am creating this code to use with a HtmlEasyPrinting
I assume you really want one customer per row of the table. There is a straightforward way, and there is a tricky way. This way is probably just a bit too terse:
cursor.execute( "select * from customer;" )
html_text = "<html><body><table><tr><td>%s</td></tr></table></body></html>" % (
"</td><td>".join( x[0] for x in cursor.fetchall() )
)
The straightforward way probably makes it a bit more clear.
cursor.execute( "select * from customer;" )
html_text = ["""
<html>
<body>
<table>
<td>
<tr>"""]
for row in cursor.fetchall():
html_text.append( '<td>%s</td>' % row[0] )
html_text.append( """
</tr>
</td>
</table>
</body>
</html>""" )
html_text = '\n'.join( html_text )
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
--
No virus found in this incoming message.
Checked by AVG. Version: 7.5.524 / Virus Database: 269.24.6/1480 - Release Date: 3/6/2008 07:00
Fernando Paiva wrote:
I have another question on HTML, is possible to set css style ???
not with the wxHTML widget -- it only handles simple, basic, HTML.
-Chris
···
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov
I did trying this.
html_text = [ """
<html>
<head>
<style type="text/css">
th{
font-family:'verdana';
}
</style>
</head>
<body>
<table>
<tr>
<th>Header</th>
</tr>
</table>
</body>
</html>
"""]
but not work
···
----- Original Message ----- From: "Christopher Barker" <Chris.Barker@noaa.gov>
To: <wxpython-users@lists.wxwidgets.org>
Sent: Tuesday, June 03, 2008 4:58 PM
Subject: Re: [wxpython-users] Html in wxPython
Fernando Paiva wrote:
I have another question on HTML, is possible to set css style ???
not with the wxHTML widget -- it only handles simple, basic, HTML.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
--
No virus found in this incoming message.
Checked by AVG. Version: 7.5.524 / Virus Database: 269.24.6/1480 - Release Date: 3/6/2008 07:00
Fernando Paiva wrote:
I did trying this.
html_text = [ """
<html>
<head>
<style type="text/css">
th{
font-family:'verdana';
}
</style>
</head> ...
but not work
No. wxHtmlEasyPrinting is designed to be simple and useful, but not feature-rich.
However, for that SPECIFIC change, you can use wxHtmlEasyPrinting.SetFonts to change the font used for the whole document.
···
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.