BoxSizer seems to fail when Frame style is wx.SIMPLE_BORDER

Hi.

I'm trying to use wxPython to write little note tool. For the note
window, I want there is only a TextCtrl inside, no border, no menu
bar, no tool bar, no status bar, no maximum icon/minimize icon. So I
use following code:

import wx

class MyNote(wx.Frame):
    def __init__(self, parent):
# super(MyNote, self).__init__(parent, style=wx.SIMPLE_BORDER)
        super(MyNote, self).__init__(parent)

        self.InitUI()

        self.Center()
        self.Show(True)

    def InitUI(self):
        panel = wx.Panel(self, )
        hbox1 = wx.BoxSizer(wx.HORIZONTAL)
        vbox = wx.BoxSizer(wx.VERTICAL)
        tc = wx.TextCtrl(panel, style=wx.TE_MULTILINE)
        hbox1.Add(tc, 1, flag=wx.EXPAND)
        vbox.Add(hbox1, 1, flag=wx.EXPAND)

        panel.SetSizer(vbox)

app = wx.App()
frame = MyNote(None)
app.MainLoop()

···

*****

I thought when this piece code running, there will be a window with a
thin border & text contral filled up the whole window.
But, I found the TextCtrl is only at the letf-up corner of the window
& the size is not expanded.

Only if I remove the "style=wx.SIMPLE_BORDER" in the Frame __init__
method, then everything will work correctly, but there will be thick
border, maximum icons, not like a stick note but a wierd window.

Any body got any idea? I can't find any clue in wxPyton API doc.
Thanks in advance.

Hi,

what about making your TextCtrl with “wx.NO_BORDER”.

Greetings,
Alex

No luck..

If I change Frame's style from wx.SIMPLE_BORDER to wx.CAPTION, then
TextCtrl can fill the window.

But why it can't work with wx.SIMPLE_BORDER?

···

On Sep 30, 4:41 pm, Alex Hefner <H._A...@web.de> wrote:

Hi,

what about making your TextCtrl with "wx.NO_BORDER".

Greetings,
Alex

You missunderstand me. Try this:

import wx

class MyNote(wx.Frame):

def __init__(self, parent):

    super(MyNote, self).__init__(parent)

    self.InitUI()

    self.Center()

    self.Show(True)

def InitUI(self):

    panel = wx.Panel(self)

    hbox1 = wx.BoxSizer(wx.HORIZONTAL)

    vbox = wx.BoxSizer(wx.VERTICAL)

    tc = wx.TextCtrl(panel, style=wx.TE_MULTILINE|wx.NO_BORDER)

    hbox1.Add(tc, 1, flag=wx.EXPAND)

    vbox.Add(hbox1, 1, flag=wx.EXPAND)

    panel.SetSizer(vbox)

app = wx.App()

frame = MyNote(None)

app.MainLoop()

···

With your code, I still get all the thick border & maxinum/mininum icon in the top.

I want something like win7’s stick note.

···

2011/9/30 Alex Hefner H._Alex@web.de

You missunderstand me. Try this:

import wx

class MyNote(wx.Frame):

def __init__(self, parent):

super(MyNote, self).init(parent)

    self.InitUI()



    self.Center()

    self.Show(True)



def InitUI(self):

panel = wx.Panel(self)

hbox1 = wx.BoxSizer(wx.HORIZONTAL)

    vbox = wx.BoxSizer(wx.VERTICAL)

tc = wx.TextCtrl(panel, style=wx.TE_MULTILINE|wx.NO_BORDER)

hbox1.Add(tc, 1, flag=wx.EXPAND)

    vbox.Add(hbox1, 1, flag=wx.EXPAND)



    panel.SetSizer(vbox)

app = wx.App()

frame = MyNote(None)

app.MainLoop()


To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

The automatic layout code happens in a Window's default EVT_SIZE event, including the feature where a frame will resize its only child (if there is only one) to fill the client area of the frame. Normally there is an initial size event when a frame is shown, in addition to others when something causes the frame to change size. In this case however there is is no size change, and there is also no initial size event because of the frame style. If you add a call to self.SendSizeEvent() after the frame's content has been created then it will behave as you expect.

···

On 9/29/11 11:59 PM, crow wrote:

I thought when this piece code running, there will be a window with a
thin border& text contral filled up the whole window.
But, I found the TextCtrl is only at the letf-up corner of the window
& the size is not expanded.

Only if I remove the "style=wx.SIMPLE_BORDER" in the Frame __init__
method, then everything will work correctly, but there will be thick
border, maximum icons, not like a stick note but a wierd window.

Any body got any idea? I can't find any clue in wxPyton API doc.
Thanks in advance.

--
Robin Dunn
Software Craftsman

Thanks Robin.

You are right, after I add self.SendSizeEvent(), everything works fine now.

Alex, thanks for your help, too.

···

2011/9/30 Robin Dunn robin@alldunn.com

On 9/29/11 11:59 PM, crow wrote:

I thought when this piece code running, there will be a window with a

thin border& text contral filled up the whole window.

But, I found the TextCtrl is only at the letf-up corner of the window

& the size is not expanded.

Only if I remove the “style=wx.SIMPLE_BORDER” in the Frame init

method, then everything will work correctly, but there will be thick

border, maximum icons, not like a stick note but a wierd window.

Any body got any idea? I can’t find any clue in wxPyton API doc.

Thanks in advance.

The automatic layout code happens in a Window’s default EVT_SIZE event, including the feature where a frame will resize its only child (if there is only one) to fill the client area of the frame. Normally there is an initial size event when a frame is shown, in addition to others when something causes the frame to change size. In this case however there is is no size change, and there is also no initial size event because of the frame style. If you add a call to self.SendSizeEvent() after the frame’s content has been created then it will behave as you expect.

Robin Dunn

Software Craftsman

http://wxPython.org

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en