wxPython and HTML based interfaces

Hi all,

I know that’s possible to display HTML pages with wxPython. But I wonder if it’s possible to make HTML based interfaces. I’d like to know if there’s a way to trigger Python functions by clicking on buttons, links or other markups embedded in a HTML page in order to modify dynamically its content.

Regards,

Thierry.

Hi,

Hi all,

I know that's possible to display HTML pages with wxPython. But I wonder if
it's possible to make HTML based interfaces. I'd like to know if there's a
way to trigger Python functions by clicking on buttons, links or other
markups embedded in a HTML page in order to modify dynamically its content.

Have you looked at/played with the HTMLWindow.py and HTML2_WebView.py
demos in the wxPython demo? I believe they provide enough information
for you to get you started.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."

# ------------------------------------------------------------- #
def ask_mailing_list_support(email):

    if mention_platform_and_version() and include_sample_app():
        send_message(email)
    else:
        install_malware()
        erase_hard_drives()
# ------------------------------------------------------------- #

···

On 6 December 2012 09:19, Thierry Brizzi wrote:

Hi all,

I know that’s possible to display HTML pages with wxPython. But I wonder if it’s possible to make HTML based interfaces. I’d like to know if there’s a way to trigger Python functions by clicking on buttons, links or other markups embedded in a HTML page in order to modify dynamically its content.

In a word: yes. WxHtml supports callbacks to do pretty much anything.

However, it does not support modern HTML or CSS or JavaScript.

If you have a mostly layout, small interaction use- case, it may be a good way to go. By the way, you can also embed wx controls in HTML- a pretty nifty feature.

If you want to take advantage of modern web toolkit and/ or methods, you should take a look at wxWebKit.

-Chris

···

On Dec 6, 2012, at 12:19 AM, Thierry Brizzi thierry.brizzi@gmail.com wrote:

Regards,

Thierry.

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

The wx.html2 module does already that for us :slight_smile:

It's only available in wxPython 2.9 (Classic and Phoenix), but I used
it to great success to do the most disparate HTML things (CSS and
JavaScript included).

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."

# ------------------------------------------------------------- #
def ask_mailing_list_support(email):

    if mention_platform_and_version() and include_sample_app():
        send_message(email)
    else:
        install_malware()
        erase_hard_drives()
# ------------------------------------------------------------- #

···

On 6 December 2012 17:07, Chris Barker - NOAA Federal wrote:

On Dec 6, 2012, at 12:19 AM, Thierry Brizzi <thierry.brizzi@gmail.com> > wrote:

Hi all,

I know that's possible to display HTML pages with wxPython. But I wonder if
it's possible to make HTML based interfaces. I'd like to know if there's a
way to trigger Python functions by clicking on buttons, links or other
markups embedded in a HTML page in order to modify dynamically its content.

In a word: yes. WxHtml supports callbacks to do pretty much anything.

However, it does not support modern HTML or CSS or JavaScript.

If you have a mostly layout, small interaction use- case, it may be a good
way to go. By the way, you can also embed wx controls in HTML- a pretty
nifty feature.

If you want to take advantage of modern web toolkit and/ or methods, you
should take a look at wxWebKit.

Hi,

Is it possible to embed python code in the 'file' that is pass to Loadfile(file),
for example:

elem = [data0, data1, data2, data3]

for item in elem:
   <td> item </td>

Assuming that the elem is result of database query while the loop to
dynamically construct table

Thanks,

Sunday Olutayo

···

----- Original Message -----
From: "Andrea Gavana" <andrea.gavana@gmail.com>
To: wxpython-users@googlegroups.com
Sent: Thursday, December 6, 2012 5:13:02 PM
Subject: Re: [wxPython-users] wxPython and HTML based interfaces

On 6 December 2012 17:07, Chris Barker - NOAA Federal wrote:

On Dec 6, 2012, at 12:19 AM, Thierry Brizzi <thierry.brizzi@gmail.com> > wrote:

Hi all,

I know that's possible to display HTML pages with wxPython. But I wonder if
it's possible to make HTML based interfaces. I'd like to know if there's a
way to trigger Python functions by clicking on buttons, links or other
markups embedded in a HTML page in order to modify dynamically its content.

In a word: yes. WxHtml supports callbacks to do pretty much anything.

However, it does not support modern HTML or CSS or JavaScript.

If you have a mostly layout, small interaction use- case, it may be a good
way to go. By the way, you can also embed wx controls in HTML- a pretty
nifty feature.

If you want to take advantage of modern web toolkit and/ or methods, you
should take a look at wxWebKit.

The wx.html2 module does already that for us :slight_smile:

It's only available in wxPython 2.9 (Classic and Phoenix), but I used
it to great success to do the most disparate HTML things (CSS and
JavaScript included).

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."

# ------------------------------------------------------------- #
def ask_mailing_list_support(email):

    if mention_platform_and_version() and include_sample_app():
        send_message(email)
    else:
        install_malware()
        erase_hard_drives()
# ------------------------------------------------------------- #

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

wxHTML doesn't support that -- it is, after all, a control written in
(and used by) C++.

However, there are any number of templating systems for Python that
let you do that -- so you can read in the file with python, process it
with a templating system, and pass the result to wxHTML. (i.e. with
SetPage)

-Chris

···

On Tue, Dec 11, 2012 at 2:28 AM, SUNDAY A. OLUTAYO <olutayo@sadeeb.com>

Is it possible to embed python code in the 'file' that is pass to Loadfile(file),
for example:

elem = [data0, data1, data2, data3]

for item in elem:
   <td> item </td>

--

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

Chris,

I referring to stuff like mako, I will appreciate more light.

Thanks,

Sunday Olutayo

···

----- Original Message -----
From: "Chris Barker - NOAA Federal" <chris.barker@noaa.gov>
To: wxpython-users@googlegroups.com
Sent: Tuesday, December 11, 2012 5:53:38 PM
Subject: Re: [wxPython-users] wxPython and HTML based interfaces

On Tue, Dec 11, 2012 at 2:28 AM, SUNDAY A. OLUTAYO <olutayo@sadeeb.com>

Is it possible to embed python code in the 'file' that is pass to Loadfile(file),
for example:

elem = [data0, data1, data2, data3]

for item in elem:
   <td> item </td>

wxHTML doesn't support that -- it is, after all, a control written in
(and used by) C++.

However, there are any number of templating systems for Python that
let you do that -- so you can read in the file with python, process it
with a templating system, and pass the result to wxHTML. (i.e. with
SetPage)

-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

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Thanks for all your advices.

Anybody knows when wxPython 2.9 is planned to be release as a stable version ?

···

Le jeudi 6 décembre 2012 09:19:10 UTC+1, Thierry Brizzi a écrit :

Hi all,

I know that’s possible to display HTML pages with wxPython. But I wonder if it’s possible to make HTML based interfaces. I’d like to know if there’s a way to trigger Python functions by clicking on buttons, links or other markups embedded in a HTML page in order to modify dynamically its content.

Regards,

Thierry.

Thanks for all your advices.

Anybody knows when wxPython 2.9 is planned to be release as a stable version
?

It's already as stable as a framework can possibly be. wxPython 2.9 is
now almost 3 years old and I have been using it since the very
beginning. This "stable" / "unstable" thing really needs to be wiped
out.

···

On 13 December 2012 08:47, Thierry Brizzi wrote:

Le jeudi 6 décembre 2012 09:19:10 UTC+1, Thierry Brizzi a écrit :

Hi all,

I know that's possible to display HTML pages with wxPython. But I wonder
if it's possible to make HTML based interfaces. I'd like to know if there's
a way to trigger Python functions by clicking on buttons, links or other
markups embedded in a HTML page in order to modify dynamically its content.

Regards,

Thierry.

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

--
Andrea.

"Imagination Is The Only Weapon In The War Against Reality."

# ------------------------------------------------------------- #
def ask_mailing_list_support(email):

    if mention_platform_and_version() and include_sample_app():
        send_message(email)
    else:
        install_malware()
        erase_hard_drives()
# ------------------------------------------------------------- #

Anybody knows when wxPython 2.9 is planned to be release as a stable version

It's already as stable as a framework can possibly be. wxPython 2.9 is
now almost 3 years old and I have been using it since the very
beginning. This "stable" / "unstable" thing really needs to be wiped
out.

To be clear, and repeat what's been said many, many times --
"unstable" in this context means "the API might change a bit in future
releases", not "the library has bugs that will make it crash".

So if you use 2.9.x, there is a chance that you will need to change a
tiny bit of your code when upgrading to 2.9.x+1, that's it -- I say go
ahead and use it.

-Chris

···

On Thu, Dec 13, 2012 at 12:04 AM, Andrea Gavana <andrea.gavana@gmail.com> wrote:

Le jeudi 6 décembre 2012 09:19:10 UTC+1, Thierry Brizzi a écrit :

Hi all,

I know that's possible to display HTML pages with wxPython. But I wonder
if it's possible to make HTML based interfaces. I'd like to know if there's
a way to trigger Python functions by clicking on buttons, links or other
markups embedded in a HTML page in order to modify dynamically its content.

Regards,

Thierry.

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

--
Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://www.infinity77.net

# ------------------------------------------------------------- #
def ask_mailing_list_support(email):

    if mention_platform_and_version() and include_sample_app():
        send_message(email)
    else:
        install_malware()
        erase_hard_drives()
# ------------------------------------------------------------- #

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

--

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

Anybody knows when wxPython 2.9 is planned to be release as a stable version

It's already as stable as a framework can possibly be. wxPython 2.9 is
now almost 3 years old and I have been using it since the very
beginning. This "stable" / "unstable" thing really needs to be wiped
out.

To be clear, and repeat what's been said many, many times --
"unstable" in this context means "the API might change a bit in future
releases", not "the library has bugs that will make it crash".

Indeed. In fact, at this point I would say that overall 2.9 is less buggy than 2.8.

If anybody has ideas for better terminology to use rather than stable/unstable that doesn't imply that one series is better than the other, then please suggest it. There have been a couple suggestions already but none have really grabbed my attention yet.

So if you use 2.9.x, there is a chance that you will need to change a
tiny bit of your code when upgrading to 2.9.x+1, that's it -- I say go
ahead and use it.

Yes, yes, yes. If you are starting or have recently started a new project there is no reason to not use 2.9. If you have an existing large project using 2.8 then it's less clear and the needs of your project will need to be evaluated, but IMO the only reason to not upgrade to 2.9 is if you have huge number of lines of UI code without the man-power to migrate or you have a major deadline looming on the horizon and have lots of other things to do before then.

If you are working on or deploying to Linux and don't have stock packages available for 2.9 yet then please ask/cajole/plead/beg/bribe the maintainer of the wx packages for your distro to add packages for 2.9. If done correctly then they should be able to coexist with 2.8 packages, so there shouldn't be any reason to have to wait for all the dependent packages to be ported to 2.9 first.

···

On 12/13/12 8:40 AM, Chris Barker - NOAA Federal wrote:

On Thu, Dec 13, 2012 at 12:04 AM, Andrea Gavana <andrea.gavana@gmail.com> wrote:

--
Robin Dunn
Software Craftsman

Anybody knows when wxPython 2.9 is planned to be release as a stable version

It's already as stable as a framework can possibly be. wxPython 2.9 is
now almost 3 years old and I have been using it since the very
beginning. This "stable" / "unstable" thing really needs to be wiped
out.

To be clear, and repeat what's been said many, many times --
"unstable" in this context means "the API might change a bit in future
releases", not "the library has bugs that will make it crash".

That is perfectly clear to everyone in this list and to everyone with
some experience with wxPython. My rantings are only about the
semantic/terminology of the whole "stable" / "unstable" thingy.
Especially for non-native English speakers (like me) and in many
languages (and I can only speak of the ones derived from Latin/Greek -
a big chunk of them), "unstable" has many meanings, all of them bad to
very bad.

So if you use 2.9.x, there is a chance that you will need to change a
tiny bit of your code when upgrading to 2.9.x+1, that's it -- I say go
ahead and use it.

Indeed, +INF to this.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."

# ------------------------------------------------------------- #
def ask_mailing_list_support(email):

    if mention_platform_and_version() and include_sample_app():
        send_message(email)
    else:
        install_malware()
        erase_hard_drives()
# ------------------------------------------------------------- #

···

On 13 December 2012 17:40, Chris Barker - NOAA Federal wrote:

On Thu, Dec 13, 2012 at 12:04 AM, Andrea Gavana <andrea.gavana@gmail.com> wrote:

to native english speakers, too -- truly, the concept of "unstable"
software often specifically means software that crashes.

So we do need a new term:

"in flux"

"development" - kind of implies not ready for production, also.

or do we need a word at all -- it's just "version 2.9" IN the docs, we
can use works like the above:

"The 2.8 series has a fixed API -- future changes will be bug-fixes
only, with no API changes"

"In the 2.9 series, there may be some small alterations to the API
from point release to point release"

-Chris

···

On Fri, Dec 14, 2012 at 12:15 AM, Andrea Gavana <andrea.gavana@gmail.com> wrote:

My rantings are only about the
semantic/terminology of the whole "stable" / "unstable" thingy.
Especially for non-native English speakers (like me) and in many
languages (and I can only speak of the ones derived from Latin/Greek -
a big chunk of them), "unstable" has many meanings, all of them bad to
very bad.

--

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

Hi Chris,

My rantings are only about the
semantic/terminology of the whole "stable" / "unstable" thingy.
Especially for non-native English speakers (like me) and in many
languages (and I can only speak of the ones derived from Latin/Greek -
a big chunk of them), "unstable" has many meanings, all of them bad to
very bad.

to native english speakers, too -- truly, the concept of "unstable"
software often specifically means software that crashes.

So we do need a new term:

"in flux"

"development" - kind of implies not ready for production, also.

or do we need a word at all -- it's just "version 2.9" IN the docs, we
can use works like the above:

"The 2.8 series has a fixed API -- future changes will be bug-fixes
only, with no API changes"

"In the 2.9 series, there may be some small alterations to the API
from point release to point release"

Am I the only one who reads this discussion and comes to the conclusion that wxWidgets just has figure out a way to put out a new stable release version more than once a decade or so? :wink:

You can debate what unstable should mean or how to word it, but regardless, the 2.9 release cycle signifies that "we're not just fixing bugs, we're changing APIs around and adding/removing functionality", which is just another way of saying "the 3.0 release is still under construction." So the simple question becomes, exactly when is 3.0 done? A lot of people out there prefer to wait until the project is done with a stable release and commits to just bug fixes. It's totally a reasonable position to take from my viewpoint, and I think they're not going to take kindly to persuasion like "you know, you don't REALLY need to wait for the stable version," no matter how you try to finesse the terms stable and unstable. :wink:

TBH, I really feel that wxWidgets is kind of wandering in the woods at this point, from a project management standpoint. No one's steering the ship. There aren't clear future goals nor any real plan for any practical purpose, there's too much hesitance to do new and cool or disruptive things for fear of 'failure', and if you do contribute, you'll have to deal with things like VC6 compatibility, pre-STL data types, mucking with bakefiles, and a lot of other overhead you don't see with other projects. Plus, who knows when your contribution will even make it into an actual release. (Even dev releases average about once a year.)

To outsiders at least, I think the project looks like it's starting to slow to a crawl, and when you add all the hassles of contributing to that, I think it really makes it hard to get excited about contributing to the project. wxPython and its work on things like Phoenix is the only thing that keeps me excited about the project doing new and cool things. :slight_smile:

Regards,

Kevin

···

On Dec 14, 2012, at 10:10 AM, Chris Barker - NOAA Federal wrote:

On Fri, Dec 14, 2012 at 12:15 AM, Andrea Gavana <andrea.gavana@gmail.com> wrote:

-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

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Chris,

Are you referring to stuff like mako, I will appreciate more light.

Thanks,

Sunday Olutayo

···

----- Original Message -----
From: "Chris Barker - NOAA Federal" <chris.barker@noaa.gov>
To: wxpython-users@googlegroups.com
Sent: Tuesday, December 11, 2012 5:53:38 PM
Subject: Re: [wxPython-users] wxPython and HTML based interfaces

On Tue, Dec 11, 2012 at 2:28 AM, SUNDAY A. OLUTAYO <olutayo@sadeeb.com>

Is it possible to embed python code in the 'file' that is pass to Loadfile(file),
for example:

elem = [data0, data1, data2, data3]

for item in elem:
   <td> item </td>

wxHTML doesn't support that -- it is, after all, a control written in
(and used by) C++.

However, there are any number of templating systems for Python that
let you do that -- so you can read in the file with python, process it
with a templating system, and pass the result to wxHTML. (i.e. with
SetPage)

-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

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

SUNDAY A. OLUTAYO wrote:

Are you referring to stuff like mako, I will appreciate more light.

That's one option. There are a lot of Python templating systems.
Cheetah is my favorite.

However, you'll need to consider whether it's worth the trouble for what
you're doing. If you only have a few substitutions, it's probably
easier to keep it all in Python.

    for item in elems:
        print "<td>%s</td>" % item

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Chris,

How can python be embedded in wx.html?
I will appreciate your help.

Thanks,

Sunday Olutayo

···

----- Original Message -----
From: "Tim Roberts" <timr@probo.com>
To: wxpython-users@googlegroups.com
Sent: Tuesday, December 11, 2012 6:56:06 PM
Subject: Re: [wxPython-users] wxPython and HTML based interfaces

SUNDAY A. OLUTAYO wrote:

Are you referring to stuff like mako, I will appreciate more light.

That's one option. There are a lot of Python templating systems.
Cheetah is my favorite.

However, you'll need to consider whether it's worth the trouble for what
you're doing. If you only have a few substitutions, it's probably
easier to keep it all in Python.

    for item in elems:
        print "<td>%s</td>" % item

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

SUNDAY A. OLUTAYO wrote:

How can python be embedded in wx.html?
I will appreciate your help.

Step back and think about it a little bit. wx.html is nothing more than
a very limited web browser. You create an HTML page as a string, and
you pass the whole string to the control using SetPage.

So, you are in exactly the same situation as someone writing a web
application on a web server. You really want to know "how can I create
an HTML page with embedded Python?" That's the question Chris and I
both tried to answer. You would need a template system of some kind. I
happen to like Cheetah, but there are lots of others.

As I said in my original reply, however, you'll have to decide whether
you have enough substitution to make it worthwhile. If you only have a
couple of loops, it would be better just to keep it all in Python:

    html = '<html><body>'
    html += '<table> <tr> '
    for item in elems:
        html += "<td>%s</td>" % item

There are lots of ways to do this kind of thing -- that's a brute force
example.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.