wxNotebook Oddities

Hello all,
   I'm new to this list, but been doing wxPython for quite some time..

  Got a quick question.. I made an empty frame, tried to subclass wxPanel and added a Notebook object to the panel.. but when it adds the "Paneled Notebook"to the main frame, it's only making the NB like 5x5 pixels.. I can't figure it out..

Here is the subclassed Panel:
class infoPane(wxPanel):
     def __init__(self, parent, data):
         wxPanel.__init__(self, parent, -1)

         self.parent = parent

         gs = wxGridSizer(1,1,10,10)

         nID = wxNewId()
         self.nb = wxNotebook(self, nID, style=wxNB_RIGHT)

         win = wxTextCtrl(self.nb, 8505, value=data, style=wxTE_READONLY|wxTE_MULTILINE)
         self.nb.AddPage(win, "Test Data", TRUE)

         gs.Add(self.nb)
         gs.Fit(self)
         self.SetSizer(gs)

Did I just totally screw this up?

Using Python 2.3.2, and wxPython for 2.3

Thanks
Dave

there are functions to assign/set and get imagelist on a wxlistctrl
but there is no function to delete imagelist from a wxlistctrl !?

i need to show a wxlistctrl in REPORT MODE (list), and be able to swith the view like this :
- with icon (small icon)
- with no icons

so i play with wx_SMALL_ICON .. to show/hide this icons
but in my "no icon" view : icons are not here : but empty space stays in place of icons
and this happens because i have assigned an imagelist to the wxlistctrl ...

i'd like to unassign this imagelist in my "no icon" view ... so : theses empty spaces will disapear
(and reassign it in my "icon" view)

Dave wrote:

Hello all,
     I'm new to this list, but been doing wxPython for quite some time..

    Got a quick question.. I made an empty frame, tried to subclass wxPanel and added a Notebook object to the panel.. but when it adds the "Paneled Notebook"to the main frame, it's only making the NB like 5x5 pixels.. I can't figure it out..

from wxPython.wx import *

class infoPane(wxPanel):
     def __init__(self, parent, data):
         wxPanel.__init__(self, parent, -1)

         self.parent = parent

         bs = wxBoxSizer(wxVERTICAL)

         nID = wxNewId()
         self.nb = wxNotebook(self, nID, style=wxNB_RIGHT)

         win = wxTextCtrl(self.nb, 8505, value=data, style=wxTE_READONLY|wxTE_MULTILINE)
         self.nb.AddPage(win, "Test Data", TRUE)

         bs.Add(self.nb, 1, wxEXPAND|wxALL, 10)
         self.SetSizerAndFit(bs)

app = wxPySimpleApp()
frame = wxFrame(None, -1, "sldfkjsldkf")
ip = infoPane(frame, "Hello")
frame.Show()
app.MainLoop()

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

3rs wrote:

there are functions to assign/set and get imagelist on a wxlistctrl
but there is no function to delete imagelist from a wxlistctrl !?

i need to show a wxlistctrl in REPORT MODE (list), and be able to swith the view like this :
- with icon (small icon)
- with no icons

so i play with wx_SMALL_ICON .. to show/hide this icons
but in my "no icon" view : icons are not here : but empty space stays in place of icons
and this happens because i have assigned an imagelist to the wxlistctrl ...

i'd like to unassign this imagelist in my "no icon" view ... so : theses empty spaces will disapear
(and reassign it in my "icon" view)

Does

  list.SetImageList(None)

work?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

no .... i ve tried ... but empty spaces still stay

but i've found a solution
i set an empty imagelist of bitmap of 1x1 pixels ...
and it rules like a charm ...

Robin Dunn wrote:

···

3rs wrote:

there are functions to assign/set and get imagelist on a wxlistctrl
but there is no function to delete imagelist from a wxlistctrl !?

i need to show a wxlistctrl in REPORT MODE (list), and be able to swith the view like this :
- with icon (small icon)
- with no icons

so i play with wx_SMALL_ICON .. to show/hide this icons
but in my "no icon" view : icons are not here : but empty space stays in place of icons
and this happens because i have assigned an imagelist to the wxlistctrl ...

i'd like to unassign this imagelist in my "no icon" view ... so : theses empty spaces will disapear
(and reassign it in my "icon" view)

Does

    list.SetImageList(None)

work?

Still having problems with this one.. I will include a URL to see what's happening.. I have changed my subclass to this:

from wxPython.wx import *

class infoPane(wxPanel):
     def __init__(self, parent, data):
         wxPanel.__init__(self, parent, -1)

         self.parent = parent
         self.data = data

         bs = wxBoxSizer(wxVERTICAL)

         nID = wxNewId()
         self.nb = wxNotebook(self, nID, style=wxNB_RIGHT)

         win = wxTextCtrl(self.nb, 8505, value=self.data, style=wxTE_READONLY|wxTE_MULTILINE)

         self.nb.AddPage(win, "Test Data", TRUE)

         bs.Add(self.nb, 1, wxEXPAND|wxALL, 10)
         self.SetSizerAndFit(bs)

here is the pic:
http://dave.voygr.com/lists/wxNotebook.jpg

Thanks guys..

**snip**

···

At 07:36 PM 10/10/03, you wrote:

class infoPane(wxPanel):
    def __init__(self, parent, data):
        wxPanel.__init__(self, parent, -1)

        self.parent = parent

        bs = wxBoxSizer(wxVERTICAL)

        nID = wxNewId()
        self.nb = wxNotebook(self, nID, style=wxNB_RIGHT)

        win = wxTextCtrl(self.nb, 8505, value=data, style=wxTE_READONLY|wxTE_MULTILINE)
        self.nb.AddPage(win, "Test Data", TRUE)

        bs.Add(self.nb, 1, wxEXPAND|wxALL, 10)
        self.SetSizerAndFit(bs)

app = wxPySimpleApp()
frame = wxFrame(None, -1, "sldfkjsldkf")
ip = infoPane(frame, "Hello")
frame.Show()
app.MainLoop()

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

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

Dave wrote:

Still having problems with this one.. I will include a URL to see what's happening.. I have changed my subclass to this:

from wxPython.wx import *

class infoPane(wxPanel):
    def __init__(self, parent, data):
        wxPanel.__init__(self, parent, -1)

        self.parent = parent
        self.data = data

        bs = wxBoxSizer(wxVERTICAL)

        nID = wxNewId()
        self.nb = wxNotebook(self, nID, style=wxNB_RIGHT)

        win = wxTextCtrl(self.nb, 8505, value=self.data, style=wxTE_READONLY|wxTE_MULTILINE)

        self.nb.AddPage(win, "Test Data", TRUE)

        bs.Add(self.nb, 1, wxEXPAND|wxALL, 10)
        self.SetSizerAndFit(bs)

How is the infoPane created? What manages its size? (If it is not the only child of the frame then you'll need to do a sizer for the frame too.)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

The main wxFrame class of the APP Creates it..

I will also try to make a sizer on that as well, which may be my problem..

Thanks for the help.. I usually use Tabs inside splitters, but didn't want splitters for this one..

:slight_smile:

Dave

···

At 03:51 PM 10/13/03, you wrote:

Dave wrote:

Still having problems with this one.. I will include a URL to see what's happening.. I have changed my subclass to this:
from wxPython.wx import *
class infoPane(wxPanel):
    def __init__(self, parent, data):
        wxPanel.__init__(self, parent, -1)
        self.parent = parent
        self.data = data
        bs = wxBoxSizer(wxVERTICAL)
        nID = wxNewId()
        self.nb = wxNotebook(self, nID, style=wxNB_RIGHT)
        win = wxTextCtrl(self.nb, 8505, value=self.data, style=wxTE_READONLY|wxTE_MULTILINE)
        self.nb.AddPage(win, "Test Data", TRUE)

        bs.Add(self.nb, 1, wxEXPAND|wxALL, 10)
        self.SetSizerAndFit(bs)

How is the infoPane created? What manages its size? (If it is not the only child of the frame then you'll need to do a sizer for the frame too.)

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

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

As it happens, I *just* dealt with this problem. Do the
following to properly size the wxNotebook:

···

On Mon, Oct 13, 2003 at 08:57:09AM -0500, Dave wrote:

Still having problems with this one.. I will include a URL to see what's
happening.. I have changed my subclass to this:

-------------------------------------------
import wx
...
    self.sizer = wx.BoxSizer(wx.VERTICAL)
    ...
    self.nb = wx.Notebook(self, -1)
    self.nbs = wx.NotebookSizer(self.nb)
    self.sizer.Add(self.nbs, 0, wx.ALIGN_LEFT)
    ...
    self.sizer.Layout()

-------------------------------------------

As far as I can tell, what is happening is that a notebook
attached to a frame directly is automatically sized and
doesn't need wx.NotebookSizer. Anywhere else (a sub-panel,
a notebook within a notebook, etc.) and it needs the
wx.NotebookSizer to be used as shown above. If you don't
have a sizer you're adding components to for some reason,
you can call Layout() directly on the wx.NotebookSizer
object. You could just always talk to wx.NotebookSizer, but
I at least tend to size the original sizer for the object,
then let it deal with its children as needed.

/begin rant

If you ask me the wx.Notebook class should have a function
to set its size to its contents either automatically when in a
generic sizer or on demand.....as you found, the above
creates the same issue being seen by person after person,
when you should be able to just call "self.nb.AutoLayout()"
or something.

/end rant :slight_smile:

Hope this helps.

--David

from wxPython.wx import *

class infoPane(wxPanel):
    def __init__(self, parent, data):
        wxPanel.__init__(self, parent, -1)

        self.parent = parent
        self.data = data

        bs = wxBoxSizer(wxVERTICAL)

        nID = wxNewId()
        self.nb = wxNotebook(self, nID, style=wxNB_RIGHT)

        win = wxTextCtrl(self.nb, 8505, value=self.data,
style=wxTE_READONLY|wxTE_MULTILINE)

        self.nb.AddPage(win, "Test Data", TRUE)

        bs.Add(self.nb, 1, wxEXPAND|wxALL, 10)
        self.SetSizerAndFit(bs)

here is the pic:
http://dave.voygr.com/lists/wxNotebook.jpg

Thanks guys..

At 07:36 PM 10/10/03, you wrote:
**snip**
>class infoPane(wxPanel):
> def __init__(self, parent, data):
> wxPanel.__init__(self, parent, -1)
>
> self.parent = parent
>
> bs = wxBoxSizer(wxVERTICAL)
>
> nID = wxNewId()
> self.nb = wxNotebook(self, nID, style=wxNB_RIGHT)
>
> win = wxTextCtrl(self.nb, 8505, value=data,
>style=wxTE_READONLY|wxTE_MULTILINE)
> self.nb.AddPage(win, "Test Data", TRUE)
>
> bs.Add(self.nb, 1, wxEXPAND|wxALL, 10)
> self.SetSizerAndFit(bs)
>
>
>
>app = wxPySimpleApp()
>frame = wxFrame(None, -1, "sldfkjsldkf")
>ip = infoPane(frame, "Hello")
>frame.Show()
>app.MainLoop()
>
>
>
>--
>Robin Dunn
>Software Craftsman
>http://wxPython.org Java give you jitters? Relax with wxPython!
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
>For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
>
>

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

Thanks David..

Ill Try this out tomorrow to see how it works.. I appreciate all the help!

Dave

···

At 07:22 PM 10/13/2003, you wrote:

On Mon, Oct 13, 2003 at 08:57:09AM -0500, Dave wrote:
> Still having problems with this one.. I will include a URL to see what's
> happening.. I have changed my subclass to this:

As it happens, I *just* dealt with this problem. Do the
following to properly size the wxNotebook:

-------------------------------------------
import wx
...
    self.sizer = wx.BoxSizer(wx.VERTICAL)
    ...
    self.nb = wx.Notebook(self, -1)
    self.nbs = wx.NotebookSizer(self.nb)
    self.sizer.Add(self.nbs, 0, wx.ALIGN_LEFT)
    ...
    self.sizer.Layout()

-------------------------------------------

As far as I can tell, what is happening is that a notebook
attached to a frame directly is automatically sized and
doesn't need wx.NotebookSizer. Anywhere else (a sub-panel,
a notebook within a notebook, etc.) and it needs the
wx.NotebookSizer to be used as shown above. If you don't
have a sizer you're adding components to for some reason,
you can call Layout() directly on the wx.NotebookSizer
object. You could just always talk to wx.NotebookSizer, but
I at least tend to size the original sizer for the object,
then let it deal with its children as needed.

/begin rant

If you ask me the wx.Notebook class should have a function
to set its size to its contents either automatically when in a
generic sizer or on demand.....as you found, the above
creates the same issue being seen by person after person,
when you should be able to just call "self.nb.AutoLayout()"
or something.

/end rant :slight_smile:

Hope this helps.

--David

> from wxPython.wx import *
>
> class infoPane(wxPanel):
> def __init__(self, parent, data):
> wxPanel.__init__(self, parent, -1)
>
> self.parent = parent
> self.data = data
>
> bs = wxBoxSizer(wxVERTICAL)
>
> nID = wxNewId()
> self.nb = wxNotebook(self, nID, style=wxNB_RIGHT)
>
> win = wxTextCtrl(self.nb, 8505, value=self.data,
> style=wxTE_READONLY|wxTE_MULTILINE)
>
> self.nb.AddPage(win, "Test Data", TRUE)
>
> bs.Add(self.nb, 1, wxEXPAND|wxALL, 10)
> self.SetSizerAndFit(bs)
>
> here is the pic:
> http://dave.voygr.com/lists/wxNotebook.jpg
>
> Thanks guys..
>
> At 07:36 PM 10/10/03, you wrote:
> **snip**
> >class infoPane(wxPanel):
> > def __init__(self, parent, data):
> > wxPanel.__init__(self, parent, -1)
> >
> > self.parent = parent
> >
> > bs = wxBoxSizer(wxVERTICAL)
> >
> > nID = wxNewId()
> > self.nb = wxNotebook(self, nID, style=wxNB_RIGHT)
> >
> > win = wxTextCtrl(self.nb, 8505, value=data,
> >style=wxTE_READONLY|wxTE_MULTILINE)
> > self.nb.AddPage(win, "Test Data", TRUE)
> >
> > bs.Add(self.nb, 1, wxEXPAND|wxALL, 10)
> > self.SetSizerAndFit(bs)
> >
> >app = wxPySimpleApp()
> >frame = wxFrame(None, -1, "sldfkjsldkf")
> >ip = infoPane(frame, "Hello")
> >frame.Show()
> >app.MainLoop()
> >
> >--
> >Robin Dunn
> >Software Craftsman
> >http://wxPython.org Java give you jitters? Relax with wxPython!
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
> >For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
> For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
>

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