app with standalone gui and web interface

D

Daniel Nogradi

What would the simplest way to make an application that has both a web
interface and runs from behind a web server but also can be used as a
standalone app with a gui? More precisely is it possible to avoid
creating an html/xml/whatever based web interface for the web version
and separately creating a gui (wxpython for example) for the
standalone version and instead create a graphical frontend at once
that can be used for both?
 
J

johan.h.lindberg

Hi Daniel.
What would the simplest way to make an application that has both a web
interface and runs from behind a web server but also can be used as a
standalone app with a gui? More precisely is it possible to avoid
creating an html/xml/whatever based web interface for the web version
and separately creating a gui (wxpython for example) for the
standalone version and instead create a graphical frontend at once
that can be used for both?

I was experimenting with something roughly similar a couple of years
ago. You might find it interesting. What I did may or may not work in
your case. It depends on what you want to be able to do in the
application.

I built an application that consisted of some server side Java/JSPs
that gave out XML. I used two stylesheets to transform the data into
either HTML (for the web version) or another XML-format called wxWML
(for the wxPython version). Desktop users accessed the application via
a custom "webbrowser" that translates the wxWML to wxPython code which
is executed to generate the GUI. This way, anyone with the wxBrowser
installed could access the application as if it was a desktop app.

But you should know that this was an experiment. We ended up not using
it because it felt weird and because there was not much extra gain to
be had from the desktop part. You should also know that the wxBrowser
is a HUGE security hole which is a good reason not to use it.

You can still download the code I wrote and a "tutorial" PDF from
http://www.pulp.se/wx/ but I haven't touched it since last summer so
I'm not sure it works with the latest version of wxPython. Also, I just
noted that the example URL that I point to on that page doesn't work
because I've moved my hosting since then, but that can be fixed.

Good luck
Johan Lindberg
(e-mail address removed)
 
D

Daniel Nogradi

What would the simplest way to make an application that has both a web
I was experimenting with something roughly similar a couple of years
ago. You might find it interesting. What I did may or may not work in
your case. It depends on what you want to be able to do in the
application.

I built an application that consisted of some server side Java/JSPs
that gave out XML. I used two stylesheets to transform the data into
either HTML (for the web version) or another XML-format called wxWML
(for the wxPython version). Desktop users accessed the application via
a custom "webbrowser" that translates the wxWML to wxPython code which
is executed to generate the GUI. This way, anyone with the wxBrowser
installed could access the application as if it was a desktop app.

But you should know that this was an experiment. We ended up not using
it because it felt weird and because there was not much extra gain to
be had from the desktop part. You should also know that the wxBrowser
is a HUGE security hole which is a good reason not to use it.

You can still download the code I wrote and a "tutorial" PDF from
http://www.pulp.se/wx/ but I haven't touched it since last summer so
I'm not sure it works with the latest version of wxPython. Also, I just
noted that the example URL that I point to on that page doesn't work
because I've moved my hosting since then, but that can be fixed.


Thanks for the suggestions, I'll look into both methods. Having a
local webserver seems pretty easy and convenient.

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:

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.
 
J

johan.h.lindberg

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
(e-mail address removed)

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top