Notebook class and passing windows

Nm. I think I got it.

Is this an appropiate way of dealing with the problem I mentioned
earlier? I created my notebook instance first, and then any windows I
make refer to that instance as the parent. The class I built is going
to retain all the other functions for a notebook, right?

Also, I've seen other ways of starting the mainloop. Does it make a
difference and impact the program differently?

Stryder

···

############################################################
from wxPython.wx import *

ID_NOTEBOOK = 12
ID_TEXT_ENTRY = 15

class MainWindow(wxFrame):
    def __init__(self, parent, id, title):
        wxFrame.__init__(self, parent, wxID_ANY, title,
                         style =
wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
        nb = Note(self, -1)
        window = wxTextCtrl(nb, ID_NOTEBOOK, style = wxTE_MULTILINE)
        nb.Add(window, "meohmy")
        nb.Add(EditorPage(nb, -1), "editor")
               
class Note(wxNotebook):
    def __init__(self, parent, id):
        wxNotebook.__init__(self, parent, id, style = wxNB_TOP)
    def Add(self, win, title):
        self.AddPage(win, title)
        
class EditorPage (wxPanel):
  def __init__ (self, parent, id):
    wxPanel.__init__ (self, parent, id)
    self.editor = wxTextCtrl (self, 3)

app = wxApp()
frame = MainWindow(None, -1, "my notebooke")
frame.Show(1)
app.MainLoop()

firephreek wrote:

class Note(wxNotebook):
    def __init__(self, parent, id):
        wxNotebook.__init__(self, parent, id, style = wxNB_TOP)
    def Add(self, win, title):
        self.AddPage(win, title)

This doesn't do anything a ww.Notebook doesn't do. Why subclass it? are you intending to add other functionality?

PS: I usually set up my apps this way:

class MyApp(wx.App):
     def OnInit(self):
         frame = MainWindow(None, -1, "Micro App")
         self.SetTopWindow(frame)
         frame.Show()

         return True

app = MyApp(0).Mainloop()

I'm not sure it does anything really different, but sometimes, there is more you want to do in OnInit.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Ahh cripes...you're right.

I was having trouble with the removepage method, and I thought this
might help. In the other program I created, my panels we're only
working when I laid them out just so, and that way didn'tseem to allow
me to get rid of my notebook pages, so wheneve I exite the program, I
got that windows "oops" beep, and on occasion, a virtual function error.
Not too clear on that one.

So, this didn't really do anything....ok...back to the drawing
board....Thanks.

Stryder

···

-----Original Message-----
From: Chris Barker [mailto:Chris.Barker@noaa.gov]
Sent: Tuesday, May 11, 2004 9:34 AM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] Notebook class and passing windows

firephreek wrote:

class Note(wxNotebook):
    def __init__(self, parent, id):
        wxNotebook.__init__(self, parent, id, style = wxNB_TOP)
    def Add(self, win, title):
        self.AddPage(win, title)

This doesn't do anything a ww.Notebook doesn't do. Why subclass it? are
you intending to add other functionality?

PS: I usually set up my apps this way:

class MyApp(wx.App):
     def OnInit(self):
         frame = MainWindow(None, -1, "Micro App")
         self.SetTopWindow(frame)
         frame.Show()

         return True

app = MyApp(0).Mainloop()

I'm not sure it does anything really different, but sometimes, there is
more you want to do in OnInit.

-Chris

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org