#minimal app showing splitter bug w/ urls
import wx

class MainFrame(wx.Frame):
    """
    This handles the main mud output and a history window.  Currently, the history
    window is just a duplicate of the main output, if memory becomes an issue I can
    put a maximum length on the history window or make the main window a STC so the
    text styles can be rebuilt as needed.  For now, this will do.
    """
    def __init__(self, parent):
        wx.Frame.__init__(self, parent)
        self.splitwin = Splitter(self)
        self.splitwin.Show()
        
class Splitter(wx.SplitterWindow):
    def __init__(self, parent):
        wx.SplitterWindow.__init__(self, parent)
        self.mainscroll= wx.TextCtrl(self, -1, style=wx.TE_MULTILINE|wx.TE_AUTO_SCROLL|wx.TE_RICH2|wx.TE_READONLY|wx.TE_AUTO_URL)
        self.histscroll = wx.TextCtrl(self, -1, style=wx.TE_MULTILINE|wx.TE_AUTO_SCROLL|wx.TE_RICH2|wx.TE_READONLY|wx.TE_AUTO_URL)
        self.histscroll.Bind(wx.EVT_TEXT_URL, self.OnUrl)
        self.SplitHorizontally(self.histscroll,self.mainscroll, 0)
        self.histscroll.AppendText("http://www.google.com")
        
    def OnUrl(self, event):
        url_start = event.GetURLStart()
        url_end = event.GetURLEnd() 
        url = self.histscroll.GetRange(url_start,url_end)
        wx.LaunchDefaultBrowser(url)

app = wx.App(False)
frame = MainFrame(None)
frame.Show()
app.MainLoop()