wxPython probleme

Cliff Wells logiplex at qwest.net
Wed Jul 23 00:27:31 CEST 2003


On Tue, 2003-07-22 at 13:53, Geiregat Jonas wrote:
> Hey,
> here's my piece of code :
> 
> class HtmlWindow(wxHtmlWindow):
>    def __init__(self,parent,id):
>        wxHtmlWindow.__init__(self,parent,id)
> 
> 
class channelTree(wxTreeCtrl):
>    def __init__(self,parent,id):
>        wxTreeCtrl.__init__(self,parent,id)
>        self.root = self.AddRoot("Sites")
>        for i in range(len(names)):
>            self.AppendItem(self.root,names[i])
>        EVT_TREE_SEL_CHANGED(self,105,self.OnCelChanged)
> 
>    def OnCelChanged(self,event):
>        item = event.GetItem()
>        print self.GetItemText(item)
> 
> class MainSplitter(wxSplitterWindow):
>    def __init__(self,parent,id):
>        wxSplitterWindow.__init__(self,parent,id)
>        self.html = HtmlWindow(self,-1)
>        self.html.LoadPage("welcome.html")
>        self.SplitHorizontally(self.html,wxWindow(self,-1),500)
>        self.Show(1)
> 
> 
> If you look at the channelTree class I've created a wxTreeCtrl when you
> change a sel a execute onCelChanged Now I would like that when you
> change a sel he loads an other page into the HtmlWindow. But I don't
> really have an idea on how to do this any help ?

I'm assuming that self.GetItemText() in OnCelChanged() returns a URL? 
In that case you can simply pass that to HtmlWindow.LoadPage().  You'll
need to pass a reference to your HtmlWindow instance to your channelTree
instance so that it can call LoadPage()

class channelTree(wxTreeCtrl):
   def __init__(self,parent,id, htmlWindow):
       wxTreeCtrl.__init__(self,parent,id)
       self.root = self.AddRoot("Sites")
       for i in range(len(names)):
           self.AppendItem(self.root,names[i])
       EVT_TREE_SEL_CHANGED(self,105,self.OnCelChanged)
       self.htmlWindow = htmlWindow

   def OnCelChanged(self,event):
       item = event.GetItem()
       self.htmlWindow.LoadPage(self.GetItemText(item))


Regards,

-- 
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726  (800) 735-0555






More information about the Python-list mailing list