Who framed the notebook?

Hello Donn,

Now, I am not exactly married to the "always stick stuff into a panel"
approach, but I was wondering what was going on here. Perhaps
I'm supposed to use sizers?

Mhm, probably "married" is a very big word :slight_smile: , but I always found easier to put stuff inside a wx.Panel than inside a wx.Frame. Moreover, almost all the controls behave erratically when directly placed inside a frame. One exception is wx.Notebook (at least on Windows), and I think also wx.ScrolledThings. In any case, if you want to put the notebook inside the panel, I would go with sizers with something like this:

import wx

class NB(wx.Notebook):
    def __init__(self, parent):
        wx.Notebook.__init__(self, parent)
        win = wx.Panel(self)
        self.AddPage(win, "Blue")

App = wx.PySimpleApp()
frame = wx.Frame(None,-1,"title")
pn = wx.Panel(frame)
sizer = wx.BoxSizer(wx.VERTICAL)
nb = NB(pn)
sizer.Add(nb, 1, wx.EXPAND)
pn.SetSizer(sizer)
sizer.Layout()
##nb = NB(frame)
frame.Show()
App.MainLoop()

HTH.

Andrea.

···

_________________________________________
Andrea Gavana (gavana@kpo.kz)
Reservoir Engineer
KPDL
4, Millbank
SW1P 3JA London

Direct Tel: +44 (0) 20 717 08936
Mobile Tel: +44 (0) 77 487 70534
Fax: +44 (0) 20 717 08900
Web: http://xoomer.virgilio.it/infinity77
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

-----Original Message-----
From: news [mailto:news@sea.gmane.org] On Behalf Of Donn Ingle
Sent: 11 May 2006 15:03
To: wxpython-users@lists.wxwidgets.org
Subject: [wxPython-users] Who framed the notebook?

PLATFORM:
Fedora Core 3 (Linux i686 AMD Athlon)
Python 2.3 and 2.4 depending on the Gods of the command-line.

wxPython, as reported by rpm -qa | grep wxPython
wxPython2.6-gtk2-unicode-2.6.3.2-fc2_py2.3

OUTLINE
Hello again! Colourful thread titles aside, I have a short question:

I am trying to use a notebook control for the first time.
After much head scratching and hacking, I have found that if
I put a notebook directly into a frame it will display okay,
if I put the notebook into a panel on the frame it will not.

Now, I am not exactly married to the "always stick stuff into a panel"
approach, but I was wondering what was going on here. Perhaps
I'm supposed to use sizers?

Code attached. A small change at the end can switch between
frame/panel approach to see what I mean.

This behaviour is the same under Linux and Windows XP Home
(SP2). I can't give the Windows specs of wxPython because I'm
at my Linux box at the moment.

Donn.

Gavana, Andrea wrote:

Mhm, probably "married" is a very big word :slight_smile: , but I always found easier
to put stuff inside a wx.Panel than inside a wx.Frame. Moreover, almost
all the controls behave erratically when directly placed inside a frame.
One exception is wx.Notebook (at least on Windows), and I think also
wx.ScrolledThings. In any case, if you want to put the notebook inside the
panel, I would go with sizers with something like this:

sizer.Layout()

Ah right. I forgot this line when I tried to use a sizer. Thanks.

Well, thanks for the help!

Hi Andrea,
I have heard a similar statement before:
quote: "Moreover, almost all the controls behave erratically when directly placed inside a frame."

Could you elaborate on this please ?

I'm puzzle by this - I'm using wxWindows (now wxWidgets) for 5 years now and I don't remember any "official word" from the documentation on this !
Is this statement based on "cross platform porting experience" ?

Thanks
Sebastian Haase

Gavana, Andrea wrote:

···

Hello Donn,

Now, I am not exactly married to the "always stick stuff into a panel"
approach, but I was wondering what was going on here. Perhaps I'm supposed to use sizers?

Mhm, probably "married" is a very big word :slight_smile: , but I always found easier to put stuff inside a wx.Panel than inside a wx.Frame. Moreover, almost all the controls behave erratically when directly placed inside a frame. One exception is wx.Notebook (at least on Windows), and I think also wx.ScrolledThings. In any case, if you want to put the notebook inside the panel, I would go with sizers with something like this:

import wx

class NB(wx.Notebook):
    def __init__(self, parent):
        wx.Notebook.__init__(self, parent)
        win = wx.Panel(self)
        self.AddPage(win, "Blue")

App = wx.PySimpleApp()
frame = wx.Frame(None,-1,"title")
pn = wx.Panel(frame)
sizer = wx.BoxSizer(wx.VERTICAL)
nb = NB(pn)
sizer.Add(nb, 1, wx.EXPAND)
pn.SetSizer(sizer)
sizer.Layout()
##nb = NB(frame)
frame.Show()
App.MainLoop()

HTH.

Andrea.

_________________________________________
Andrea Gavana (gavana@kpo.kz)
Reservoir Engineer
KPDL
4, Millbank
SW1P 3JA London
Direct Tel: +44 (0) 20 717 08936
Mobile Tel: +44 (0) 77 487 70534
Fax: +44 (0) 20 717 08900
Web: http://xoomer.virgilio.it/infinity77
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

-----Original Message-----
From: news [mailto:news@sea.gmane.org] On Behalf Of Donn Ingle
Sent: 11 May 2006 15:03
To: wxpython-users@lists.wxwidgets.org
Subject: [wxPython-users] Who framed the notebook?

PLATFORM:
Fedora Core 3 (Linux i686 AMD Athlon)
Python 2.3 and 2.4 depending on the Gods of the command-line.

wxPython, as reported by rpm -qa | grep wxPython
wxPython2.6-gtk2-unicode-2.6.3.2-fc2_py2.3

OUTLINE
Hello again! Colourful thread titles aside, I have a short question:

I am trying to use a notebook control for the first time. After much head scratching and hacking, I have found that if I put a notebook directly into a frame it will display okay, if I put the notebook into a panel on the frame it will not.

Now, I am not exactly married to the "always stick stuff into a panel"
approach, but I was wondering what was going on here. Perhaps I'm supposed to use sizers?

Code attached. A small change at the end can switch between frame/panel approach to see what I mean.

This behaviour is the same under Linux and Windows XP Home (SP2). I can't give the Windows specs of wxPython because I'm at my Linux box at the moment.

Donn.

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

Hello Sebastian,

I don’t know how the situation is now with wxPython (almost 2.7) and wxWidgets 2.7, but not very far in the past [1] I saw quite a lot of problems in placing controls directly on a frame. I am not talking about controls like wx.Panel, wx.Notebook, wx.SplitterWindow obviously. These are usually “containers”. I wrote that sentence about controls like wx.TextCtr, wx.Choice, wx.RadioButton and all the “simpler” widgets.

By reading those messages and experiencing on my own skin the troubles caused by placing the widgets directly on a Frame, I switched almost instantaneously to my current approach: place the controls on a wx.Panel, wx.ScrolledThing
, wx.Notebook and the like. For that reason I don’t know if everything now works smoothly also by putting widgets directly on a frame, and sure as hell I won’t experiment it anymore :slight_smile:

However, if there are no more problem about that, I am happy for those users who use a different coding style than mine :wink:

Andrea.

[1] http://permalink.gmane.org/gmane.comp.python.wxpython.devel/1148

···

On 5/17/06, Sebastian Haase haase@msg.ucsf.edu wrote:

Hi Andrea,
I have heard a similar statement before:
quote: "Moreover, almost all the controls behave erratically when

directly placed inside a frame."

Could you elaborate on this please ?

I’m puzzle by this - I’m using wxWindows (now wxWidgets) for 5 years now
and I don’t remember any “official word” from the documentation on this !

Is this statement based on “cross platform porting experience” ?

Thanks
Sebastian Haase

Gavana, Andrea wrote:

Hello Donn,

Now, I am not exactly married to the “always stick stuff into a panel”

approach, but I was wondering what was going on here. Perhaps
I’m supposed to use sizers?

Mhm, probably “married” is a very big word :slight_smile: , but I always found easier to

put stuff inside a wx.Panel than inside a wx.Frame.
Moreover, almost all the controls behave erratically when directly placed inside a frame.
One exception is wx.Notebook (at least on Windows), and I think also wx.ScrolledThings.
In any case, if you want to put the notebook inside the panel, I would go with sizers
with something like this:

import wx

class NB(wx.Notebook):
def init(self, parent):

    wx.Notebook.__init__(self, parent)
    win = wx.Panel(self)
    self.AddPage(win, "Blue")

App = wx.PySimpleApp()
frame = wx.Frame(None,-1,“title”)

pn = wx.Panel(frame)
sizer = wx.BoxSizer(wx.VERTICAL)
nb = NB(pn)
sizer.Add(nb, 1, wx.EXPAND)
pn.SetSizer(sizer)
sizer.Layout()
##nb = NB(frame)
frame.Show()

App.MainLoop()

HTH.

Andrea.


Andrea Gavana (gavana@kpo.kz)
Reservoir Engineer

KPDL
4, Millbank
SW1P 3JA London

Direct Tel: +44 (0) 20 717 08936
Mobile Tel: +44 (0) 77 487 70534
Fax: +44 (0) 20 717 08900
Web:
http://xoomer.virgilio.it/infinity77

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

-----Original Message-----
From: news [mailto:
news@sea.gmane.org] On Behalf Of Donn Ingle
Sent: 11 May 2006 15:03
To: wxpython-users@lists.wxwidgets.org
Subject: [wxPython-users] Who framed the notebook?

PLATFORM:
Fedora Core 3 (Linux i686 AMD Athlon)
Python 2.3 and 2.4 depending on the Gods of the command-line.

wxPython, as reported by rpm -qa | grep wxPython

wxPython2.6-gtk2-unicode-2.6.3.2-fc2_py2.3

OUTLINE
Hello again! Colourful thread titles aside, I have a short question:

I am trying to use a notebook control for the first time.

After much head scratching and hacking, I have found that if
I put a notebook directly into a frame it will display okay,
if I put the notebook into a panel on the frame it will not.

Now, I am not exactly married to the “always stick stuff into a panel”
approach, but I was wondering what was going on here. Perhaps
I’m supposed to use sizers?

Code attached. A small change at the end can switch between
frame/panel approach to see what I mean.

This behaviour is the same under Linux and Windows XP Home
(SP2). I can’t give the Windows specs of wxPython because I’m

at my Linux box at the moment.

Donn.


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


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


“Imagination Is The Only Weapon In The War Against Reality.”


http://xoomer.virgilio.it/infinity77/

Sebastian Haase wrote:

Hi Andrea,
I have heard a similar statement before:
quote: "Moreover, almost all the controls behave erratically when directly placed inside a frame."

Could you elaborate on this please ?

Frames don't have support for tab traversal between controls, panels do. Frames are best at being containers for other containers.

···

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