Removing the caption from wx.Frame

Hi,

I am trying to remove the caption from my frame, but it keeps causing the children widgets to not render correctly. Here is what I am doing:

<code>

wx.Frame.__init__(self, None, wx.ID_ANY, size=(100,100),
                          style=wx.SYSTEM_MENU >wx.FRAME_NO_TASKBAR)

panel = wx.Panel(self, wx.ID_ANY)
self.statBtn = wx.Button(panel, wx.ID_ANY, "Show")
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.statBtn, 1, wx.CENTER|wx.EXPAND, 5)
panel.SetSizer(sizer)

</code>

This makes a dark grey box with part of my button visible in the upper left corner. I tried Refresh(), Update() and Layout() on the frame object and it has no effect. I'm pretty sure this is something silly, but I'm just not seeing it. Your help would be appreciated.

I am using wxPython 2.8.9.2, Python 2.5.2 on Windows XP. Thanks!

Mike

Hello,

···

On Fri, Mar 20, 2009 at 1:48 PM, Mike Driscoll mike@pythonlibrary.org wrote:

Hi,

I am trying to remove the caption from my frame, but it keeps causing the children widgets to not render correctly. Here is what I am doing:

wx.Frame.init(self, None, wx.ID_ANY, size=(100,100),
style=wx.SYSTEM_MENU |wx.FRAME_NO_TASKBAR)

panel = wx.Panel(self, wx.ID_ANY)
self.statBtn = wx.Button(panel, wx.ID_ANY, “Show”)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.statBtn, 1, wx.CENTER|wx.EXPAND, 5)
panel.SetSizer(sizer)

This makes a dark grey box with part of my button visible in the upper left corner. I tried Refresh(), Update() and Layout() on the frame object and it has no effect. I’m pretty sure this is something silly, but I’m just not seeing it. Your help would be appreciated.
Did you try putting the Panel in a sizer and setting that sizer as the Frames?

msizer = wx.BoxSizer(wx.VERTICAL)

msizer.Add(panel, 1, wx.EXPAND)

self.SetSizer(msizer)

Cody

Cody Precord wrote:

Hello,

    Hi,

    I am trying to remove the caption from my frame, but it keeps
    causing the children widgets to not render correctly. Here is what
    I am doing:

    <code>

    wx.Frame.__init__(self, None, wx.ID_ANY, size=(100,100),
                            style=wx.SYSTEM_MENU >wx.FRAME_NO_TASKBAR)

    panel = wx.Panel(self, wx.ID_ANY)
    self.statBtn = wx.Button(panel, wx.ID_ANY, "Show")
    sizer = wx.BoxSizer(wx.VERTICAL)
    sizer.Add(self.statBtn, 1, wx.CENTER|wx.EXPAND, 5)
    panel.SetSizer(sizer)

    </code>

    This makes a dark grey box with part of my button visible in the
    upper left corner. I tried Refresh(), Update() and Layout() on the
    frame object and it has no effect. I'm pretty sure this is
    something silly, but I'm just not seeing it. Your help would be
    appreciated.

Did you try putting the Panel in a sizer and setting that sizer as the Frames?
msizer = wx.BoxSizer(wx.VERTICAL)
msizer.Add(panel, 1, wx.EXPAND)
self.SetSizer(msizer)

I tried that right after I sent the email, but no dice. Here's a small runnable sample:

<code>

import wx

class DockedFrame(wx.Frame): def __init__(self):
        """
        Initialize the frame
        """
        wx.Frame.__init__(self, None, wx.ID_ANY, size=(100,100),
                          style=wx.SYSTEM_MENU
                          >wx.FRAME_NO_TASKBAR)
                                panel = wx.Panel(self, wx.ID_ANY)
        self.statBtn = wx.Button(panel, wx.ID_ANY, "Show")
                       msizer = wx.BoxSizer(wx.VERTICAL)
        msizer.Add(panel, 1, wx.EXPAND)
        self.SetSizer(msizer)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.statBtn, 1, wx.CENTER|wx.EXPAND, 5)
        panel.SetSizer(sizer)
               width, height = wx.DisplaySize()
        x = width - 150
        y = height - 150 self.SetPosition((x, y))
               self.Show()
       class StatusController(wx.App): def __init__(self, redirect=False, filename=None):
        """
        Initialize the application and instantiate the frame
        """
        wx.App.__init__(self, redirect, filename)
        frame = DockedFrame()

···

On Fri, Mar 20, 2009 at 1:48 PM, Mike Driscoll <mike@pythonlibrary.org > <mailto:mike@pythonlibrary.org>> wrote:

#-------------------------------------------------------------
# Run program
if __name__ == "__main__":
    app = StatusController()
    app.MainLoop()

</code>

I found that if I call panel.Fit(), the entire button will appear, albeit still stuck in the upper left corner with the rest being dark gray.

Mike

Hello,

···

On Fri, Mar 20, 2009 at 2:08 PM, Mike Driscoll mike@pythonlibrary.org wrote:

I found that if I call panel.Fit(), the entire button will appear, albeit still stuck in the upper left corner with the rest being dark gray.

Add a ‘self.SendSizeEvent()’ right before you show the frame.

Cody

Cody Precord wrote:

Hello,

    I found that if I call panel.Fit(), the entire button will appear,
    albeit still stuck in the upper left corner with the rest being
    dark gray.
     
Add a 'self.SendSizeEvent()' right before you show the frame.

That does the trick, thanks! I don't suppose you know why that is required?

Mike

···

On Fri, Mar 20, 2009 at 2:08 PM, Mike Driscoll <mike@pythonlibrary.org > <mailto:mike@pythonlibrary.org>> wrote:

Hello,

···

On Fri, Mar 20, 2009 at 2:27 PM, Mike Driscoll mike@pythonlibrary.org wrote:

Cody Precord wrote:

Hello,

On Fri, Mar 20, 2009 at 2:08 PM, Mike Driscoll <mike@pythonlibrary.org mailto:mike@pythonlibrary.org> wrote:

I found that if I call panel.Fit(), the entire button will appear,
albeit still stuck in the upper left corner with the rest being
dark gray.

Add a ‘self.SendSizeEvent()’ right before you show the frame.

Cody

That does the trick, thanks! I don’t suppose you know why that is required?

I just tried with self.Layout() and that works too (didn’t try before because you said you did it).

Without taking a peek at the wxWidgets source (which I dont’ have in front of me at the moment) I am not sure why a frame with a border will do the layout automaticaly and one without will not, or if its intended to work this way or not either.

Cody

Cody Precord wrote:

Hello,

    Cody Precord wrote:

        Hello,

           I found that if I call panel.Fit(), the entire button will
        appear,
           albeit still stuck in the upper left corner with the rest being
           dark gray.
                    Add a 'self.SendSizeEvent()' right before you show the frame.
           Cody

    That does the trick, thanks! I don't suppose you know why that is
    required?

I just tried with self.Layout() and that works too (didn't try before because you said you did it).
Without taking a peek at the wxWidgets source (which I dont' have in front of me at the moment) I am not sure why a frame with a border will do the layout automaticaly and one without will not, or if its intended to work this way or not either.

Odd. It works now for me too. I must have done something stupid, like calling Layout() before I added the panel to a sizer. Oh well. Sorry about that! Thanks for the help!

Mike

···

On Fri, Mar 20, 2009 at 2:27 PM, Mike Driscoll <mike@pythonlibrary.org > <mailto:mike@pythonlibrary.org>> wrote:
        On Fri, Mar 20, 2009 at 2:08 PM, Mike Driscoll > <mike@pythonlibrary.org <mailto:mike@pythonlibrary.org> > <mailto:mike@pythonlibrary.org > <mailto:mike@pythonlibrary.org>>> wrote:

Cody Precord wrote:

    That does the trick, thanks! I don't suppose you know why that is
    required?

I just tried with self.Layout() and that works too (didn't try before because you said you did it).
Without taking a peek at the wxWidgets source (which I dont' have in front of me at the moment) I am not sure why a frame with a border will do the layout automaticaly and one without will not, or if its intended to work this way or not either.

It's probably a side-effect of how Windows is implemented. <speculation> When there is a border and the frame is shown then Windows will send it a size event as it is adjusted to accommodate the border. When there is no border then there is no extra size event, and since your frame's size was set before the sizer was added then the sizer's Layout is not called. </speculation>

···

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