app with standalone gui and web interface

johan.h.lindberg at gmail.com johan.h.lindberg at gmail.com
Tue Oct 3 13:22:18 CEST 2006


> Johan, your way of doing it resembles XUL somewhat, although I can't
> say I fully understand XUL I just took a look some days ago. Let me
> see if I understand your approach:

Yes it's a lot like XUL, but there are some major differences. The most
important one is that, at least back then, you had to use JavaScript.
Also, XUL had (has) a much more limited set of widgets and you can't
escape the surrounding Browser.

> If you want to have something very dynamical you do it the way you
> described with the wxwml source getting parsed, converted to wxpython
> and then run by python all at once. At the same time the webserver can
> fetch the same wxwml source, convert it into html/xml and send that to
> the web client. Now if one wants to bypass wxbrowser and the real time
> conversion to wxpython, then, sacrificing some level of dynamicness,
> why not convert the wxwml source 'statically' into wxpython, bundle
> that as an app and at the same time convert it also to xml/html
> 'statically' and have that served by a webserver. In this way any time
> the gui changes one needs to go through both convertions once, bundle
> the desktop app again, update the webserver but there won't be any
> security whole or any magic that is not pure python or not pure
> html/xml. Does this sound reasonable or am I misunderstanding
> something?
>
> In fact something like that is the thing I'm looking for, some
> language that can specify a gui and can be used to generate
> 'statically' both wxpython source (or some other widget set) or
> html/xml source.

Ok, there are ways to do that... sort of.

You could modify or extend the wxBrowser to do this but you should
really have a look at extending XRC (have a look at XRCed which comes
with wxPython if you don't know what it is). Even though it doesn't do
*everything* you want it's a good place to start.

An XRC-file is an XML-specification of a wx GUI which can be loaded by
a wxApp to generate a "static" GUI. However, if you want any sort of
functionality to go with your program you're going to have to find a
way to also include the equivalent of HTML script-tags that you can
hook into wx event-handlers. I don't think XRC has that.

Also, last time I looked, XRC is very sensitive so if you do change the
format here and there to include other stuff, make sure to remove it
before you try to parse it in the wxApp (it complains otherwise, or at
least it used to).

The wxBrowser does all of this for you, but at run time, there's
currently no way of packaging it all up in one big XML file that could
be saved as wxPython source. But it's sure doable. I don't know which
is easier but either way, I'm guessing that you're going to have to
write some code of your own.

If you decide to extend/modify the wxBrowser, let me know, I might be
able to help you out.

BR
Johan Lindberg
johan at pulp.se

PS
You should also ask around at the wxPython-users list
(http://aspn.activestate.com/ASPN/Mail/Browse/Threaded/wxPython-users).




More information about the Python-list mailing list