Re: Dynamic HTML controls

2010-01-21 Thread Alan Harris-Reid

Aahz wrote:

In article ,
Alan Harris-Reid   wrote:
  
Does anyone know where I can find any decent dynamically-constructed 
HTML control classes (dropdown list, table, input field, checkbox, etc.) 
written in Python.  For example, for a HTML table I would like something 
like...



You might look at Quixote:
http://quixote.ca/
  

Thanks for that Aahz - I'll check it out.

Regards,
Alan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic HTML controls

2010-01-21 Thread Aahz
In article ,
Alan Harris-Reid   wrote:
>
>Does anyone know where I can find any decent dynamically-constructed 
>HTML control classes (dropdown list, table, input field, checkbox, etc.) 
>written in Python.  For example, for a HTML table I would like something 
>like...

You might look at Quixote:
http://quixote.ca/
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

import antigravity
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic HTML controls

2010-01-14 Thread Alan Harris-Reid


Pierre Quentel wrote:

On 12 jan, 04:26, Alan Harris-Reid  wrote:
  

Hi,

Does anyone know where I can find any decent dynamically-constructed
HTML control classes (dropdown list, table, input field, checkbox, etc.)
written in Python.  For example, for a HTML table I would like something
like...

MyTable =tml_table()   # instantiate class
MyTable.data =ata_list# data-list (eg. cursor from SQL SELECT
statement)
MyTable.border =  
MyTable.width =87  
MyTable.column_headers =ol_headers# list or tuple of column-headers

table_code =yTable.table.create()   # returns string
containing appropriate HTML code

I don't mind writing my own classes (it will be good practice for me),
but I don't want to re-invent the wheel if it can be avoided.

TIA,
Alan Harris-Reid



Hi,

There are a few modules to generate HTML from Python : there is a list
at http://wiki.python.org/moin/Templating, section HTML Generation
packages

With HTMLTags, your example would be coded like this :

from HTMLTags import *
table =ABLE(border=1,width~7)
table <=R(Sum([TD(header) for header in col_headers]))
for result in data_list:
table <=R(Sum([TD(value) for value in result]))
print table

The operator <=eans "add child" in the DOM tree structure, it avoids
having to nest tags with brackets

- Pierre


Thanks Pierre.  I can see this module being very useful.  I have 
downloaded the code from the Activestate site (is that the latest 
version?) and will try it out as soon as possible.

Is HTMLTags Python3 compatible? (I am using 3.1).

Regards,
Alan Harris-Reid

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic HTML controls

2010-01-12 Thread Michel Claveau - MVP
Hi!

I had write PLUIE, for use DHTML as GUI: 
  http://www.ponx.org/ponx/guie.htm
But it is not a good answer to your problem. Sorry.

Nevertheless, there are several functions & methods 
for generate DHTML objects (and Python keep the
control on each object.

@+
-- 
Michel Claveau 


*** sorry for my bad english
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic HTML controls

2010-01-12 Thread Alan Harris-Reid

alex23 wrote:

On Jan 12, 1:26 pm, Alan Harris-Reid 
wrote:
  

Does anyone know where I can find any decent dynamically-constructed
HTML control classes (dropdown list, table, input field, checkbox, etc.)
written in Python.



There's pyWeb[1], which seems pretty close to what you're asking for:

  mytable =able(align='center', cellspacing=0, cellpadding=3,
border=
  mytable.add(tr(td("first row"), td("second row")))

While it might be a little heavier than what you're after, you should
also be able to do this with ToscaWidgets[2]. You'd probably have to
make basic widgets for the general HTML controls, but that would give
you a good head-start on writing your own, more complex widgets.
Widgets can be a compilation of Python, HTML, CSS & JS. (I used this
fairly extensively when it used to be called TurboWidgets)

If you want to roll your own from scratch, I'm a big fan of the html
[3] library:

  >>> from html import HTML
  >>> h =TML()
  >>> with h.table(border=', width='987'):
  ...   with h.tr:
  ... for header in ['column 1', 'column 2']:
  ...   h.th(header)
  ...
  >>> print h
  
  column 1column 2
  

1: http://www.freenet.org.nz/python/pyweb
2: http://toscawidgets.org
3: http://pypi.python.org/pypi/html/1.7

Hi Alex (I'm assuming that is your name from your nickname)

Thanks for the reply - I'll check-out all 3 solutions you suggest and 
I'm sure I'll find something near to what I am looking for.


Regards,
Alan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic HTML controls

2010-01-12 Thread Diez B. Roggisch

Alan Harris-Reid schrieb:


Hi,

Does anyone know where I can find any decent dynamically-constructed 
HTML control classes (dropdown list, table, input field, checkbox, etc.) 
written in Python.  For example, for a HTML table I would like something 
like...


MyTable = html_table()   # instantiate class
MyTable.data = data_list# data-list (eg. cursor from SQL SELECT 
statement)
MyTable.border = 1  MyTable.width = 987  MyTable.column_headers 
= col_headers# list or tuple of column-headers table_code = 
MyTable.table.create()   # returns string containing appropriate 
HTML code


I don't mind writing my own classes (it will be good practice for me), 
but I don't want to re-invent the wheel if it can be avoided.



Maybe toscawidgets is for you, it has a lot of additional features such 
as static dependency declaration & injection.


For a form within a table, it would look like this:


table_form = TableForm("table_form",
   fields=[SingleSelectField("foo", options=["A", 
"B", "C"]), action="/some/action", method="GET")



table_form.render(dict(foo="B"))


Diez
--
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic HTML controls

2010-01-12 Thread Pierre Quentel
On 12 jan, 04:26, Alan Harris-Reid  wrote:
> Hi,
>
> Does anyone know where I can find any decent dynamically-constructed
> HTML control classes (dropdown list, table, input field, checkbox, etc.)
> written in Python.  For example, for a HTML table I would like something
> like...
>
> MyTable = html_table()       # instantiate class
> MyTable.data = data_list    # data-list (eg. cursor from SQL SELECT
> statement)
> MyTable.border = 1          
> MyTable.width = 987  
> MyTable.column_headers = col_headers    # list or tuple of column-headers
> table_code = MyTable.table.create()           # returns string
> containing appropriate HTML code
>
> I don't mind writing my own classes (it will be good practice for me),
> but I don't want to re-invent the wheel if it can be avoided.
>
> TIA,
> Alan Harris-Reid

Hi,

There are a few modules to generate HTML from Python : there is a list
at http://wiki.python.org/moin/Templating, section HTML Generation
packages

With HTMLTags, your example would be coded like this :

from HTMLTags import *
table = TABLE(border=1,width=987)
table <= TR(Sum([TD(header) for header in col_headers]))
for result in data_list:
table <= TR(Sum([TD(value) for value in result]))
print table

The operator <= means "add child" in the DOM tree structure, it avoids
having to nest tags with brackets

- Pierre
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic HTML controls

2010-01-11 Thread alex23
On Jan 12, 1:26 pm, Alan Harris-Reid 
wrote:
> Does anyone know where I can find any decent dynamically-constructed
> HTML control classes (dropdown list, table, input field, checkbox, etc.)
> written in Python.

There's pyWeb[1], which seems pretty close to what you're asking for:

  mytable = table(align='center', cellspacing=0, cellpadding=3,
border=0)
  mytable.add(tr(td("first row"), td("second row")))

While it might be a little heavier than what you're after, you should
also be able to do this with ToscaWidgets[2]. You'd probably have to
make basic widgets for the general HTML controls, but that would give
you a good head-start on writing your own, more complex widgets.
Widgets can be a compilation of Python, HTML, CSS & JS. (I used this
fairly extensively when it used to be called TurboWidgets)

If you want to roll your own from scratch, I'm a big fan of the html
[3] library:

  >>> from html import HTML
  >>> h = HTML()
  >>> with h.table(border='1', width='987'):
  ...   with h.tr:
  ... for header in ['column 1', 'column 2']:
  ...   h.th(header)
  ...
  >>> print h
  
  column 1column 2
  

1: http://www.freenet.org.nz/python/pyweb
2: http://toscawidgets.org
3: http://pypi.python.org/pypi/html/1.7
-- 
http://mail.python.org/mailman/listinfo/python-list


Dynamic HTML controls

2010-01-11 Thread Alan Harris-Reid


Hi,

Does anyone know where I can find any decent dynamically-constructed 
HTML control classes (dropdown list, table, input field, checkbox, etc.) 
written in Python.  For example, for a HTML table I would like something 
like...


MyTable = html_table()   # instantiate class
MyTable.data = data_list# data-list (eg. cursor from SQL SELECT 
statement)
MyTable.border = 1  
MyTable.width = 987  
MyTable.column_headers = col_headers# list or tuple of column-headers 
table_code = MyTable.table.create()   # returns string 
containing appropriate HTML code


I don't mind writing my own classes (it will be good practice for me), 
but I don't want to re-invent the wheel if it can be avoided.



TIA,
Alan Harris-Reid
--
http://mail.python.org/mailman/listinfo/python-list