[wxPython] wxHTMLWindow and images

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] wxHTMLWindow and images

Mark Jeacocke
Hi.

I'm trying to use the wxHTMLWindow control for the appication help
screen.

Everything is working fine except it doesn't seem to load images.

The same HTML page loads nicely into the wxPython demo program (from
which I liberally stole alot of the HTML code :)
, and for the life of me I can't see any significant differences between
the code.

The error I get is a msgbox saying "Warning: No handler found for this
image", and of course the image simply not displaying.

Anyone seen this behavious before? Any ideas or help would be
appreciated.

Cheers
Mark

--------------------------------------------------------------------------------

class HTMLContents(wxFrame):
    def __init__(self, parent):
        wxFrame.__init__(self, parent, -1,'DiRECTOR!',
wxDefaultPosition, wxDefaultSize)

        self.printer = wxHtmlEasyPrinting()

        self.html = wxHtmlWindow( self, -1 )
       
        self.box = wxBoxSizer(wxVERTICAL)

        subbox = wxBoxSizer(wxHORIZONTAL)
        btn = wxButton(self, 1201, "Contents")
        EVT_BUTTON(self, 1201, self.OnShowDefault)
        subbox.Add(btn, 1, wxGROW | wxALL, 2)

        btn = wxButton(self, 1204, "Back")
        EVT_BUTTON(self, 1204, self.OnBack)
        subbox.Add(btn, 1, wxGROW | wxALL, 2)

        btn = wxButton(self, 1205, "Forward")
        EVT_BUTTON(self, 1205, self.OnForward)
        subbox.Add(btn, 1, wxGROW | wxALL, 2)

        btn = wxButton(self, 1207, "Print")
        EVT_BUTTON(self, 1207, self.OnPrint)
        subbox.Add(btn, 1, wxGROW | wxALL, 2)

        btn = wxButton(self, 1208, "Close")
        EVT_BUTTON(self, 1208, self.OnCloseWindow)
        subbox.Add(btn, 1, wxGROW | wxALL, 2)

        self.box.Add(subbox, 0, wxGROW)
        self.box.Add(self.html, 1, wxGROW)

        self.SetSizer(self.box)
        self.SetAutoLayout(true)

        cwd = path.split(sys.argv[0])[0]
        if not cwd:
            cwd = getcwd()
        self.name = join(cwd, 'html/director.html')

        self.html.LoadPage( self.name )

        self.Maximize( true )

    def OnShowDefault(self, event):
        self.html.LoadPage( self.name )

    def OnBack(self, event):
        if not self.html.HistoryBack():
            wxMessageBox("No more items in history!")


    def OnForward(self, event):
        if not self.html.HistoryForward():
            wxMessageBox("No more items in history!")

    def OnPrint(self, event):
        self.printer.PrintFile(self.html.GetOpenedPage())

    def OnCloseWindow(self, event):
        self.Destroy()

---------------------------------------------------------------

[hidden email] wrote:

>
> Send wxPython-users mailing list submissions to
>         [hidden email]
>
> To subscribe or unsubscribe via the web, visit
>         http://starship.python.net/mailman/listinfo/wxpython-users
> or, via email, send a message with subject or body 'help' to
>         [hidden email]
> You can reach the person managing the list at
>         [hidden email]
>
> When replying, please edit your Subject line so it is more specific than
> "Re: Contents of wxPython-users digest..."
>
> Today's Topics:
>
>   1. Re: Exiting dialog (Robin Dunn)
>   2. Help! My GTK hates me ... (Matt Gushee)
>   3. wxPython installation (Dr. Gottfried Olbrich)
>   4. Images colors (Cristian Echeverria)
>   5. laying out a dialog box (Bob Klimek)
>   6. RE: laying out a dialog box (Cristian Echeverria)
>   7. FW: [wxPython] laying out a dialog box (Cristian Echeverria)
>
> --__--__--
>
> Message: 1
> From: "Robin Dunn" <[hidden email]>
> To: "Robin Dunn" <[hidden email]>,
> "=?Windows-1252?Q?Przemys=B3aw_G._Gawro=F1ski?=" <[hidden email]>,
> <[hidden email]>
> Subject: Re: [wxPython] Exiting dialog
> Date: Thu, 16 Dec 1999 12:39:10 -0800
> charset="Windows-1252"
>
> > >
> > > If you close the dialog by the close button everything goes well and
> > > under Windows, the console window is also destroyed, but if you exit by
> > > hitting the ESC key, the dialog window closes (greate), but the console
> > > windows stays :-(
> > >
> > > What do I have to do to make the console window close also (besides just
> > > closing it)
> > >
> >
> > The window still exists so the application hasn't exited.
> >
> > The call to dialog.ShowModal() doesn't return until you complete a dialog
> > with ESC, or clicking on a button with wxID_OK or wxID_CANCEL ID's, so it
> is
> > at this point that you want to call Destroy().
> >
> >
>
> Oops!  I've just proved myself wrong.  There is a bug in MSW wxDialog that is
> causing this, but only for the ESC key.  Using buttons with an ID of wxID_OK
> or wxID_CANCEL works as expected.  I'll get it fixed but I'm not sure what to
> do for a workaround...
>
> --
> Robin Dunn
> Software Craftsman
> [hidden email]
> http://AllDunn.com/robin/
> http://AllDunn.com/wxPython/  Check it out!
>
> --__--__--
>
> Message: 2
> Date: Thu, 16 Dec 1999 18:06:03 -0500 (EST)
> From: Matt Gushee <[hidden email]>
> To: "wxPython Users' List" <[hidden email]>
> Subject: [wxPython] Help! My GTK hates me ...
>
> Hi, Folks--
>
> Well, I just installed wxWindows and wxPython the other day. But when
> I try to run a wxPython program (including the demos), I get the
> following:
>
>     GLib-WARNING **: getpwuid_r(): failed due to: No such user 500.
>
>     Gdk-ERROR **: an x io error occurred
>     aborting...
>
> Note that this doesn't happen with the wxGTK demos, so it appears to
> be wxPython-specific.
>
> Also, the 'getpwuid_r()' error goes away if I run the program as root,
> which sort of makes sense, but the x io error remains.
>
> Here's my setup:
>
>        Red Hat Linux 5.2 (kernel 2.0.36, glibc 2.0.7)
>        egcs 2.90.29
>        XFree86 3.3.3.1 (Japanese distribution patched for
>          TrueType font support)
>        GTK/Glib 1.2.3
>        wxGTK 2.1.11 (built from SRPM, installed under /usr)
>        wxPython 2.1.11 (built from tarball, installed under
>          /usr/local)
>
> So, anybody have an idea what's wrong here? I'm eager to try this
> wonderful wxPython that everybody's raving about, but I'm not getting
> very far this way.
>
> Any clues would be much appreciated.
>
> Matt Gushee
> Portland, Maine, USA
>
> --__--__--
>
> Message: 3
> Date: Fri, 17 Dec 1999 16:08:37 +0100
> From: "Dr. Gottfried Olbrich" <[hidden email]>
> To: [hidden email]
> Subject: [wxPython] wxPython installation
>
> Hi all,
>
> I am working on a PII with 300 MHz, using SuSE 6.3 and KDE 1.1.2.
>
> I installed wxGTK 2.1.11 and wxPython 2.1.11 and did some tests. The
> wxGTK tests (samples) worked as they should, however, every time I
> touched a python program, one of the provided demos or of my own
> programs I got the error message:
>
> .../wxmodule.so: undefined symbol : __pure_virtual
>
> Can anybody help me or tell me what I did wrong ?
>
> Gottfried
>
> -------------------------------------------------------------------------
> Dr. Gottfried Olbrich
> MPI fuer Strahlenchemie                          Tel: ++49(0)208 306
> 3696
> Stiftstrasse 34-36                               Fax: ++49(0)208 306
> 3951
> D-45470 Muelheim/Ruhr                  email:
> [hidden email]
> -------------------------------------------------------------------------
>
> --__--__--
>
> Message: 4
> From: Cristian Echeverria <[hidden email]>
> To: "'wxPython Users'" <[hidden email]>
> Date: Fri, 17 Dec 1999 12:17:42 -0400
> Subject: [wxPython] Images colors
>
> Hi ...
>
> Python 1.5.2, wxPython 2.1.11, Win95/98
>
> I had noticed that wxListCtrl and wxTreeCtrl accept only
> 16 colours images, but buttons accepts more and when
> you use a dc to paint an image on a panel it accept more
> colours too.
> How many colours may have Images in diferents parts of wxWindows?
> Is there a reason for this ?
> Does it happend on the gtk version too?
>
> Thanks in advice
>
> Cristian Echeverria
>
> --__--__--
>
> Message: 5
> Date: Fri, 17 Dec 1999 11:12:21 -0500
> From: Bob Klimek <[hidden email]>
> Organization: NASA Glenn Research
> To: wxPython Post <[hidden email]>
> Subject: [wxPython] laying out a dialog box
>
> Hi All,
>
> Does anybody know (or have sample code) how to construct a dialog box
> with OK and Cancel buttons already nicely layed out no matter what the
> size and shape of the dialog box is?
>
> Currently I construct my dialog boxes by hard coding the positions of
> the OK and Cancel buttons but that's slow because no dialog box is the
> same.
>
> I've tried generating two panels, each holding some contents which were
> positioned by sizers, and then putting them into another panel in a
> dialog box but couldn't get it to work right. There's got to be a
> simpler way of doing it. Any ideas?
>
> Bob
>
> --__--__--
>
> Message: 6
> From: Cristian Echeverria <[hidden email]>
> To: "'Bob Klimek'" <[hidden email]>,
> wxPython Post
> <[hidden email]>
> Subject: RE: [wxPython] laying out a dialog box
> Date: Fri, 17 Dec 1999 13:39:18 -0400
>
> ------ =_NextPart_000_01BF4894.1E85AD20
> Content-Type: text/plain; charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
>
> You can use wxBoxSizer.
> I send you an example file
>
> Cristian Echeverr=EDa
>
> =20
>
> -----Original Message-----
> From:   Bob Klimek [SMTP:[hidden email]]
> Sent:   Friday, December 17, 1999 12:12 PM
> To:     wxPython Post
> Subject:        [wxPython] laying out a dialog box
>
> Hi All,
>
> Does anybody know (or have sample code) how to construct a dialog box
> with OK and Cancel buttons already nicely layed out no matter what the
> size and shape of the dialog box is?
>
> ------ =_NextPart_000_01BF4894.1E85AD20
> Content-Type: text/plain; name="base.py"
> Content-Transfer-Encoding: quoted-printable
>
> #- <00> =
> -----------------------------------------------------------------------
> # CRISTIAN ECHEVERR=CDA RAB=CD
> # Archivo           : <Nombre> -- <Version> -- <Fecha>
> # Descripci=F3n       : <Descripci=F3n>
>
> from wxPython.wx import *
> from wxPython.html import *
>
> #- <00> =
> -----------------------------------------------------------------------
>
> texto =3D """
> <HTML>
> <BODY BGCOLOR=3D"#99CCFF">
> <CENTER>
> <TABLE BGCOLOR=3D"#003399" WIDTH=3D"100%%" CELLSPACING=3D"0" =
> CELLPADDING=3D"0" BORDER=3D"1">
> <TR>
>     <TD ALIGN=3D"CENTER"><H1><FONT COLOR=3D"#99CCFF">GIA =
> V0.1</FONT></H1></TD>
> </TR>
> </TABLE>
>
> <P><B>GIA</B> IS UNA APLICACI=D3N QUE PERMITE OBTENER INFORMES DE GASTOS =
> DE OBRAS
> DESDE LA CONTABILIDAD DE ENDESA Y TRANSELEC.</P>
>
> <P><B>GIA</B> HA SIDO DESARROLLADA POR POR PERSONAL DE LA GERENCIA DE =
> EXPLOTACI=D3N.</P>
> </CENTER>
> <P>
> <UL>
>         <LI>MANUEL ESCOBAR
>         <LI>LUIS HERN=C1NDEZ
>     <LI>CRISTIAN ECHEVERR=CDA
> </UL>
> </P>
> <P><CENTER><FONT SIZE=3D"-1"><I>TRANSELEC 1999</I></FONT></P></CENTER>
> </BODY>
> </HTML>
> """
>
> ------ =_NextPart_000_01BF4894.1E85AD20--
>
> --__--__--
>
> Message: 7
> From: Cristian Echeverria <[hidden email]>
> To: "'Bob Klimek'" <[hidden email]>
> Cc: "'wxPython Users'" <[hidden email]>
> Subject: FW: [wxPython] laying out a dialog box
> Date: Fri, 17 Dec 1999 13:47:02 -0400
>
> ------ =_NextPart_000_01BF4895.339E42C0
> Content-Type: text/plain; charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
>
> SORRY , SORRY
> I SEND THE WRONG  FILE.
> THIS IS THE RIGHT ONE
>
> =20
>
> -----Original Message-----
> From:   Echeverr=EDa, Cristian=20
> Sent:   Friday, December 17, 1999 1:39 PM
> To:     'Bob Klimek'; wxPython Post
> Subject:        RE: [wxPython] laying out a dialog box
> Importance:     High
>
> You can use wxBoxSizer.
> I send you an example file
>
> Cristian Echeverr=EDa
>
> ------ =_NextPart_000_01BF4895.339E42C0
> Content-Type: text/plain; name="demo.py"
> Content-Transfer-Encoding: 7bit
>
> #- <00> -----------------------------------------------------------------------
> # Archivo           : demo.py -- 17/12/1999
>
> from wxPython.wx import *
>
> #- <00> -----------------------------------------------------------------------
>
> class MyDialog(wxDialog):
>     def __init__(self,parent,title):
>         wxDialog.__init__(self,parent,-1,title)
>
>         box = wxBoxSizer(wxVERTICAL)
>
>         box1 = wxBoxSizer(wxHORIZONTAL)
>         # You can put your widgets here
>         widget = wxPanel(self,-1,size=(200,200))
>         box1.Add(widget,0,wxALL,5)
>         box.Add(box1,0,wxALL,2)
>
>         boxX = wxBoxSizer(wxHORIZONTAL)
>         okbut = wxButton(self,wxID_OK,"Aceptar")
>         okbut.SetDefault()
>         boxX.Add(okbut,0,wxALL,5)
>         boxX.Add(wxButton(self,wxID_CANCEL,"Cancelar"),0,wxALL,5)
>         box.Add(boxX,0,wxCENTER)
>
>         self.SetAutoLayout(true)
>         self.SetSizer(box)
>         box.Fit(self)
>         box.SetSizeHints(self)
>
> #- <00> -----------------------------------------------------------------------
>
> class MainFrame(wxFrame):
>     def __init__(self, parent,title):
>         wxFrame.__init__(self, parent, -1, title,
>                          wxDefaultPosition, wxSize(400,300))
>
>         mainmenu = wxMenuBar()
>         menu = wxMenu()
>         menu.Append(100,"Dialog...","Display Dialog")
>         mainmenu.Append(menu, "&Archivo")
>         self.SetMenuBar(mainmenu)
>         EVT_MENU(self,100,self.OnDisplayDialog)
>
>         self.Center(wxBOTH)
>
>     def OnDisplayDialog(self,event):
>         dlg = MyDialog(self,"Dialog Sample")
>         dlg.Center(wxBOTH)
>         opcion = dlg.ShowModal()
>         dlg.Destroy()
>
>     def OnCloseWindow(self,event):
>         self.Destroy()
>
> #- <00> -----------------------------------------------------------------------
>
> class MainApp(wxApp):
>     def OnInit(self):
>         frame = MainFrame(NULL,"Wx-Template")
>         frame.Show(true)
>         self.SetTopWindow(frame)
>         return true
>
> #- <00> -----------------------------------------------------------------------
>
> def main():
>     app = MainApp(0)
>     app.MainLoop()
>
> #- <99> -----------------------------------------------------------------------
>
> if __name__ == '__main__':
>     main()
>
> ------ =_NextPart_000_01BF4895.339E42C0--
>
> --__--__--
>
> _______________________________________________
> wxPython-users maillist  -  [hidden email]
> http://starship.python.net/mailman/listinfo/wxpython-users
>
> End of wxPython-users Digest

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] wxHTMLWindow and images

Robin Dunn
>
> I'm trying to use the wxHTMLWindow control for the appication help
> screen.
>
> Everything is working fine except it doesn't seem to load images.
>

You need to load image handlers.  If you look in the demo's Main.py you'll
find this:

        wxImage_AddHandler(wxJPEGHandler())
        wxImage_AddHandler(wxPNGHandler())
        wxImage_AddHandler(wxGIFHandler())

Or you can also use the new wxInitAllImageHandlers().


--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users