Notebook for anything but HTML

I'm using Grayul.py as a design example for a notebook since it dynamically
adds and removes pages with very little code. Its a wonderful example of
what can be done without even using sizers! My pages will hold just about
anything but HTML. The original code is:

    def OnAdd(self,event):
        'Adds a new HTML window'
        file = self.GetFileName()

        if file:
            newWin = wxHtmlWindow(self.note,-1)
            self.note.AddPage(newWin,os.path.split(file)[1],1)
            newWin.LoadPage(file)
How can I populate the page with the usual suspects - windows
and controls ? (what can be substituted for wxHtmlWindow)
Right now I have:

class ButtonFrame (wxFrame):
    'Creates a frame with a single button in the center'
    def __init__ (self):
        wxFrame.__init__ (self, NULL, -1, 'wxPython', wxDefaultPosition, (200, 100))

        button = wxButton (self, 111, 'Click Me!')
        EVT_BUTTON (self, 111, self.onButton)
    #end def __init__
#end class ButtonFrame
...
    def OnAdd (self, event):
        'Adds a new notebook page'

        newWin = wxScrolledWindow (self.notebook, -1)
        self.notebook.AddPage (newWin, 1)

        myframe = ButtonFrame()
        frame.Show(true)
    #end def OnAdd

... which doesn't create new notebook pages at all!
Is there a .Show() or something else I need to do ?
I imagine that -many- people would like to know how to do this.

Thanks

Ray Pasco wrote:

I'm using Grayul.py as a design example for a notebook since it dynamically
adds and removes pages with very little code. Its a wonderful example of
what can be done without even using sizers! My pages will hold just about
anything but HTML. The original code is:

   def OnAdd(self,event):
       'Adds a new HTML window'
       file = self.GetFileName()

       if file:
           newWin = wxHtmlWindow(self.note,-1)
           self.note.AddPage(newWin,os.path.split(file)[1],1)
           newWin.LoadPage(file)

How can I populate the page with the usual suspects - windows
and controls ? (what can be substituted for wxHtmlWindow)
Right now I have:

class ButtonFrame (wxFrame):
   'Creates a frame with a single button in the center'
   def __init__ (self):
       wxFrame.__init__ (self, NULL, -1, 'wxPython', wxDefaultPosition, (200, 100))

       button = wxButton (self, 111, 'Click Me!')
       EVT_BUTTON (self, 111, self.onButton)
   #end def __init__
#end class ButtonFrame

...

if ButtonFrame ends above, to what class does OnAdd belong? And how does it get called?

   def OnAdd (self, event):
       'Adds a new notebook page'

       newWin = wxScrolledWindow (self.notebook, -1)
       self.notebook.AddPage (newWin, 1)

you omitted the second (text) argument to AddPage

       myframe = ButtonFrame()
       frame.Show(true)

Why are you creating a new button frame every time you add a page to the notebook?

   #end def OnAdd

... which doesn't create new notebook pages at all!
Is there a .Show() or something else I need to do ?
I imagine that -many- people would like to know how to do this.

David

David -- I don't know what the unnamed args for Notebook are.
Using named args, notebook pages are now properly being created and destroyed,
but each page is supposed to have a button in it. Right now they are in their own window.
I've also attached what I've done so far in Grayul.new.py. Since I'm so new at using
wxpython, I'm struggling a lot to learn its concepts (I've used tkinter, though).

There's some more comments I've sprinkled in further down...

Ray Pasco

GRAYUL.PY (2.35 KB)

GRAYUL.NEW.PY (3.16 KB)

···

_______________________

David C. Fox wrote:

Ray Pasco wrote:

I'm using Grayul.py as a design example for a notebook since it dynamically
adds and removes pages with very little code. Its a wonderful example of
what can be done without even using sizers! My pages will hold just about
anything but HTML. The original code is:

   def OnAdd(self,event):
       'Adds a new HTML window'
       file = self.GetFileName()

       if file:
           newWin = wxHtmlWindow(self.note,-1)
           self.note.AddPage(newWin,os.path.split(file)[1],1)
           newWin.LoadPage(file)

How can I populate the page with the usual suspects - windows
and controls ? (what can be substituted for wxHtmlWindow)
Right now I have:

class ButtonFrame (wxFrame):
   'Creates a frame with a single button in the center'
   def __init__ (self):
       wxFrame.__init__ (self, NULL, -1, 'wxPython', wxDefaultPosition, (200, 100))

       button = wxButton (self, 111, 'Click Me!')
       EVT_BUTTON (self, 111, self.onButton)
   #end def __init__
#end class ButtonFrame

...

if ButtonFrame ends above, to what class does OnAdd belong? And how does it get called?

OnAdd belongs to BrowserFrame. I've attached my work and Grayul.py for reference.
I very much like the way it creates & desroys notebook pages, only I want controls in it,
not HTML display. All the mechanics of Grayul's setting the contents of its notebook pages
are hidden, unfortunately, so I can't use that as an example.

   def OnAdd (self, event):
       'Adds a new notebook page'

       newWin = wxScrolledWindow (self.notebook, -1)
       self.notebook.AddPage (newWin, 1)

you omitted the second (text) argument to AddPage

What is the second arguments to AddPage supposed to be ?
I want to add controls, not necessarily (just) text. Right now I'm trying to put a button
(anything, really) in it to see it and get its evt handler work. Later I'll put more in the page
once I work out the proper general incantation.

       myframe = ButtonFrame()
       frame.Show(true)

Why are you creating a new button frame every time you add a page to the notebook?

This is just to get -something- to work.

   #end def OnAdd

... which doesn't create new notebook pages at all!
Is there a .Show() or something else I need to do ?
I imagine that -many- people would like to know how to do this.

David

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

Ray Pasco wrote:

   def OnAdd (self, event):
       'Adds a new notebook page'

       newWin = wxScrolledWindow (self.notebook, -1)
       self.notebook.AddPage (newWin, 1)

you omitted the second (text) argument to AddPage

What is the second arguments to AddPage supposed to be ?

the text which appears in the tab of the notebook page

I want to add controls, not necessarily (just) text. Right now I'm trying to put a button
(anything, really) in it to see it and get its evt handler work. Later I'll put more in the page
once I work out the proper general incantation.

       myframe = ButtonFrame()
       frame.Show(true)

Why are you creating a new button frame every time you add a page to the notebook?

You are adding the button to a separate frame. If you want it to appear in the ScrolledWindow, you have to create a button which is a child of Scrolled Window (or a ScrolledWindow subclass).

Personally, though, I would start with a subclass of wxPanel with a button in it, rather than a ScrolledWindow.

For example, if you replace your ButtonFrame with

class ButtonPanel (wxPanel):
     'Creates a panel with a single button in the center'
     def __init__ (self, parent):
         wxPanel.__init__ (self, parent, -1, wxDefaultPosition, (200, 100))

         button = wxButton (self, 111, 'Click Me!')
         EVT_BUTTON (self, 111, self.onButton)
     #end def __init__

     def onButton (self, event):
         'Create a message dialog when the button is clicked'
         dlg = wxMessageDialog(self, 'Ow, quit it.', 'Whine', wxOK)
         dlg.ShowModal()
         dlg.Destroy()
     #end def onButton
#end class ButtonPanel

and then change OnAdd to

     def OnAdd (self, event):
         'Adds a new notebook page'

         newWin = ButtonPanel(self.notebook)
         self.notebook.AddPage (page=newWin, text='XXX', select=true)

then you should get closer to what you want.

David