AW: wxDC - Standalone and with CGI?

Dear Brian,
How do you import wxPython in your cgi? With from wxPythin.wx import * or do
you import the modules you need in your script separately?
Oliver

···

-----Ursprüngliche Nachricht-----
Von: Brian Kelley [mailto:bkelley@wi.mit.edu]
Gesendet: Freitag, 5. Dezember 2003 22:32
An: wxPython-users@lists.wxwindows.org
Betreff: Re: [wxPython-users] wxDC - Standalone and with CGI?

Robin Dunn wrote:

Oliver Walczak wrote:

Dear List,
Is it possible to use wxPython in a server sided CGI script?

No, wxWidnows needs access to the UI in order to be initialized.

That still doesn't prevent it from being used in a cgi script. I use
wxDC's from a python apache server all the time. The trick is not to
open up an gui windows. These tend to annoy anyone looking at the server.

I have a drawer class that draws on a wxMemoryDC() and saves the file to
disk as a "gif"
Here is a small snippet to give you a taste.

class Drawer:
def save(self, filename):
  dc = wxMemoryDC()
  bmp = wxEmptyBitmap(width, height)
  dc.SelectObject(bmp)
  self._draw(dc)
  bmp.SaveFile(filename, type)

usage...
app = wxPySimpleApp()
wxInitAllImageHandlers()
d = Drawer(...)
d.save(filename)

This app sets up the gui environment and writes out a gif file. I think
it can be used in a cgi environment, otherwise you can call this from
your cgi script.

Brian

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

Oliver Walczak wrote:

Dear Brian,
How do you import wxPython in your cgi? With from wxPythin.wx import * or do
you import the modules you need in your script separately?
Oliver

It shouldn't matter much anyway. (GTK) wxPython CAN NOT be initialized
without access to an X-server, whether you actually end up using the GUI
or not. If you are running an X-Server and whoever the user is that runs
the cgi has access to that server, than Brian's method should work fine.

If your server is running and X-server , and things aren't working, you
ahve an X authorization problem (and/or your DISPLAY environment
variable isn't set). See:

man xauth
man xhost

I'm am far from an expert, but for a totally non-secure way to test if
access is your problem, try:

xhost +

That will allow Anyone, Anywhere to connect to the X-server.

-Chris,

Who is still waiting for an angel to arive and tell me how the *&&%^& to
get Xvfb set up!

···

--
Christopher Barker, Ph.D.
Oceanographer
                                        
NOAA/OR&R/HAZMAT (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