[wxPython-users] No Highlight of text selection

Robin Dunn robin at alldunn.com
Tue Jan 2 12:42:47 PST 2007


Morton Publications wrote:
> Robin,
> 
> Attached is a working example of my popup app using Python 2.4 and 
> WxPython 2.8.
> 
> Notice how the text highlight goes over every word with the cursor (as 
> it should with the mouse motion event), but I need this highlight to be 
> hidden or transparent.
> 
> Second, put the cursor on a reference in the bottom line and the popup 
> will display and stay up, even if the cursor is moved down in blank 
> space. I would like the popup to leave when the cursor leaves the 
> boundary of the reference.
> 
> Is there anyway to capture an event when the cursor changes from a 
> "text" cursor to the default "arrow" cursor when it leaves text?

I think that I would take a different approach.  Instead of using the 
brute force method using the mouse motion event and selections in the 
html widget, use the html widget's ability to parse the content and 
notify you of where in the document you are.  The wx.html.HtmlWindow 
parses the doc into fragments called cells, and calls an overridable 
method whenever the mouse hovers over a cell, so you can derive a class 
from wx.html.HtmlWindow and implement a OnCellMouseHover method.  (Or in 
2.8 you can instead just bind a handler for the EVT_HTML_CELL_HOVER 
event.)  Something like this (untested):

class MyHtml(wx.html.HtmlWindow):
     def OnCellMouseHover(self, cell, x, y):
         # get the text of the cell and do something with it
         text = cell.ConvertToText(None)
         print text

There are also overridable methods for a cell being clicked, for a link 
being clicked, etc.



-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list