I have a application that mainly works with a Notebook widget. When the user make a menu selection a new notebook page is created and the
notebook page’s TextCtrl widget is populated with the contents of file. I’m using the wx.EVT_NOTEBOOK_PAGE_CHANGED
and a callback to find out the page number. All of this is working.
PROBLEM:
I have multiple notebook pages, and the user selects a specific page (I can find out which specific page has been chosen,).
How do I reference the editor widget (wx.TextCtrl) for the selected page, so I can get the editor’s content.
The code used to create each notebook page is below.
def CreateTestCasePage (self, file):
scroll = wx.ScrolledWindow(self.notebook, -1, style ......)
# The new page will become the Top page
self.notebook.AddPage(page = scroll, select =True, text=tabName)
.
.
id = wx.NewId()
editor = wx.TextCtrl(scroll, id, size = (700,400), style = wx.TE_MULTILINE | wx.HSCROLL)
editor.AppendText(file)
sizer.AddWindow(editor, flag = wx.EXPAND)
scroll.SetSizer(sizer)
scroll.SetScrollRate(20,20)
scroll.SetAutoLayout(True)
scroll.Layout()
Hello!
You have a number of options, for example:
- Subclass the wx.ScrolledWindow and store reference to editor in a member variable.
class MyScroll( wx.ScrolledWindow ):
def init( … )
.....
self.editor = wx.TextCtrl( ... )
- “Inject” reference to the editor in a scroll variable itself.
scroll.editor = wx.TextCtrl( … )
- If editor is guarantied to be only one “child” control of scroll then GetChildren() function can be used:
editor = scroll.GetChildren()[0]
-
Give a name to editor control and then use scroll.FindWindowByName to locate it.
Vladimir
···
----- Original Message -----
From:
Lanuez, Javier
To: wxpython-users@lists.wxwidgets.org
Sent: Saturday, November 06, 2004 1:33 AM
Subject: [wxPython-users] WxNotebook page reference help
I have a application that mainly works with a Notebook widget. When the user make a menu selection a new notebook page is created and the
notebook page’s TextCtrl widget is populated with the contents of file. I’m using the wx.EVT_NOTEBOOK_PAGE_CHANGED
and a callback to find out the page number. All of this is working.
PROBLEM:
I have multiple notebook pages, and the user selects a specific page (I can find out which specific page has been chosen,).
How do I reference the editor widget (wx.TextCtrl) for the selected page, so I can get the editor’s content.
The code used to create each notebook page is below.
def CreateTestCasePage (self, file):
scroll = wx.ScrolledWindow(self.notebook, -1, style ......)
# The new page will become the Top page
self.notebook.AddPage(page = scroll, select =True, text=tabName)
.
.
id = wx.NewId()
editor = wx.TextCtrl(scroll, id, size = (700,400), style = wx.TE_MULTILINE | wx.HSCROLL)
editor.AppendText(file)
sizer.AddWindow(editor, flag = wx.EXPAND)
scroll.SetSizer(sizer)
scroll.SetScrollRate(20,20)
scroll.SetAutoLayout(True)
scroll.Layout()