#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    62
    Rep Power
    11

    This seems to be fairly difficult


    Well, I've been searching the web on how doing this, and to say the truth, it seems to be rather an advanced topic. It involves wxpython panels.
    What about if i had a menu:
    Load panel 1
    Load panel 2
    Load panel 3
    What I'm searching for is a function that load panels on menu or other events...
    On wxpython demo they do something like this, but toooooo difficult to undersand.
    For example in pseudocode:

    If event 1 ocurrs,
    then load panel 1

    if event 2 ocurrs
    then load panel 2

    and so on...
    Anybody knows how this can be done, or knows a program that does this or something similar??
    Thanks in advance
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    62
    Rep Power
    11
    I've made some little progress.
    In my script I have:

    self.nb.AddPage(self.nb_panel_1, "Some text")
    to add a page to the notebook_panel_1

    Then I get the page id as follows:
    page_id = self.nb.GetSelection()

    Then I can erase the page as:
    self.nb.DeletePage(page_id)

    This is some pseudocode:
    Code:
    class wxPrincipal(wx.Frame):
    	def __init__(self,parent,id,title):
    	...
    		self.splitter = wx.SplitterWindow(self,...
    		self.panel_2 = wx.Panel(self.splitter...
    		self.nb = wx.Notebook(self.panel_2...
    		self.panel_1 = wx.Panel(self.splitter...
    		self.tree = wx.TreeCtrl(self.panel_1...
    		self.nb_panel_1 = wx.Panel(self.nb...
                    ....
                    self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged, self.tree)
    
                    ....
    
    	def OnSelChanged(self,event):
    		self.item = event.GetItem()
                    page_id = self.nb.GetSelection()
                    self.nb.DeletePage(page_id)
    So... now I guess I have to replace the erased page with some other page. And well, I know I can use AddPage or InsertPage (I got to try both), but what I dont know... is:
    The new page (added or inserted) will be in another class? And if yes, how do I code such page in my script... I really dont seem to get that, and I've search a lot on google, but still dont give up! Thumbs up!
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    62
    Rep Power
    11
    Ok!!! So this does the trick
    Code:
    	def OnSelChanged(self,event):
    		page_id = self.nb.GetSelection()
    		self.nb.DeletePage(page_id)
    		win = wx.Panel(self.nb, -1)
    		self.nb.AddPage(win, "Some other text")
    EDITED: correct some typos
    What it does is that when you change the selection of items in the TreeCtrl it changes the page for a new one and deletes the old one...
    So now I must figure how to make the new pages, pages with complex data in them and not just empty ones...
    Any ideas?

IMN logo majestic logo threadwatch logo seochat tools logo