Html Popup Window

I'm working on a popup html window that acts similiar to
wxPopupWindow. (This will allow unicode text and all the html
attributes to be in a popup). It is basically just a borderless frame
with an htmlWindow with no scrollbars. It is working pretty well
except I can't find a way to measure the window height with the text
inserted with SetPage(). The width is fixed (450)

I've tried GetBestSize on both the frame and htmlwindow but it only
returns the minimum size (20, 20). GetTextExtent returns the text
length as a single line i.e. (1000, 13). Is there a way to get the
height a window needs to be for a set width so the popup size can be
set?

Thanks,
Tim

···

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

tsmorton wrote:

I'm working on a popup html window that acts similiar to
wxPopupWindow. (This will allow unicode text and all the html
attributes to be in a popup). It is basically just a borderless frame
with an htmlWindow with no scrollbars. It is working pretty well
except I can't find a way to measure the window height with the text
inserted with SetPage(). The width is fixed (450)

well, I know a way to do it, but it seems kludgy. You can render to a bitmap with a wx.html.HtmlDCRenderer(), then call its GetTotalHeight() method to get the height, then draw it to your popup window.

There must be a way to get at the wx.htmlwindows renderer and call it's GetTotalHeight method, but I can't see it with a quick look through the docs.

Maybe this is enough of a hint to help you find it, though.

Enclosed is a little example of using wx.html.HtmlDCRenderer() to render html into an off-screen bitmap.

HTH,

-Chris

OffScreenHTML.py (2.42 KB)

···

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

As seen in the demo/About.py module:

     def __init__(self, parent):
         wx.Dialog.__init__(self, parent, -1, 'About the wxPython demo',)
         html = wx.html.HtmlWindow(self, -1, size=(420, -1))
         if "gtk2" in wx.PlatformInfo:
             html.SetStandardFonts()
         py_version = sys.version.split()[0]
         txt = self.text % (wx.VERSION_STRING,
                            ", ".join(wx.PlatformInfo[1:]),
                            py_version
                            )
         html.SetPage(txt)
         ir = html.GetInternalRepresentation()
         html.SetSize( (ir.GetWidth()+25, ir.GetHeight()+25) )
         self.SetClientSize(html.GetSize())
         self.CentreOnParent(wx.BOTH)

···

On 5/18/10 3:24 PM, tsmorton wrote:

I'm working on a popup html window that acts similiar to
wxPopupWindow. (This will allow unicode text and all the html
attributes to be in a popup). It is basically just a borderless frame
with an htmlWindow with no scrollbars. It is working pretty well
except I can't find a way to measure the window height with the text
inserted with SetPage(). The width is fixed (450)

I've tried GetBestSize on both the frame and htmlwindow but it only
returns the minimum size (20, 20). GetTextExtent returns the text
length as a single line i.e. (1000, 13). Is there a way to get the
height a window needs to be for a set width so the popup size can be
set?

--
Robin Dunn
Software Craftsman

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

Thanks Robin and Chris.

These tips are exactly what I was looking for. My app's popups will be
much more robust now that html can be used.

Tim

···

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