The wxTextCtrl can manipualte urls, if it is instantiated with
the wxTE_RICH style with the EVT_TEXT_URL event.
When a user mouse-overs or clicks on the URL, how do I capture
this event, and how to I get the string (the URL) that was
clicked on?
I have :
EVT_TEXT_URL(self.text, self.text.GetId(), self.OnClick)
in my code, but can not get the URL, just the entire line
that it is on.
Thanks,
John
···
--
John Taylor Terry College of Business
jft@terry.uga.edu University of Georgia
Try:
textctrl.GetRange(event.GetURLStart(),
event.GetURLEnd())
as in the following test code:
···
--- John Taylor <jft@terry.uga.edu> wrote:
The wxTextCtrl can manipualte urls, if it is instantiated with
the wxTE_RICH style with the EVT_TEXT_URL event.
When a user mouse-overs or clicks on the URL, how do I capture
this event, and how to I get the string (the URL) that was
clicked on?
I have :
EVT_TEXT_URL(self.text, self.text.GetId(), self.OnClick)
in my code, but can not get the URL, just the entire line
that it is on.
============================================================
#!/usr/bin/env python
from wxPython.wx import *
class URLTextCtrl(wxTextCtrl):
def __init__(self, parent, id):
wxTextCtrl.__init__(self, parent, id,
style=wxTE_RICH|
wxTE_MULTILINE|
wxTE_AUTO_URL)
EVT_TEXT_URL(self, self.GetId(), self.onOver)
def onOver(self, event):
urlString = self.GetRange(event.GetURLStart(),
event.GetURLEnd())
print urlString
class MyFrame(wxFrame):
def __init__(self):
wxFrame.__init__(self, None, -1, 'URL Demo',
size=(350, 150))
text1 = URLTextCtrl(self, -1)
class MyApp(wxApp):
def OnInit(self):
frame = MyFrame()
frame.Show(1)
return 1
app = MyApp(0)
app.MainLoop()
=====
Donnal Walter
Arkansas Children's Hospital
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.