Modifying windows style after init in Linux?

Hi.

So I've been having some trouble setting window and panel styles after initialization. It seems to work just fine in Windows, but not in Ubuntu, which is my primary OS.

The difference should be visible to anyone trying to execute the code below in Windows and Linux; in Windows, I get two panels with a simple border. In Ubuntu, I get one panel with a simple border, and one panel without border.

I've tried using Update(), Refresh(), SendSizeEvent() and UpdateWindowUI(). Both on the panel in question, and on the frame itself.

I really am at a loss here, and sincerely hope there's someone out there who can shed some light on the subject... Right now, I'm tempted to write it off as a limitation in GTK and try to not depend on (or even use) this function.

So, any ideas?

//Mikael "Krank" Bergstr�m

···

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

import wx
MyApp = wx.App()

class MyKindOfBox (wx.Frame):
     def __init__(self):
         wx.Frame.__init__(self, None)
         self.SetSizer(wx.BoxSizer(wx.VERTICAL))

         self.panel1 = wx.Panel(self, -1, style=wx.SIMPLE_BORDER)
         self.panel2 = wx.Panel(self, -1, style=wx.NO_BORDER)

         self.panel2.SetWindowStyleFlag(wx.SIMPLE_BORDER)

         self.GetSizer().Add(self.panel1, 1, wx.EXPAND | wx.ALL, border=10)
         self.GetSizer().Add(self.panel2, 1, wx.EXPAND | wx.ALL, border=10)

         self.Show()

MyBox = MyKindOfBox()
MyApp.MainLoop()

Hi.

So I've been having some trouble setting window and panel styles after
initialization. It seems to work just fine in Windows, but not in
Ubuntu, which is my primary OS.

The difference should be visible to anyone trying to execute the code
below in Windows and Linux; in Windows, I get two panels with a simple
border. In Ubuntu, I get one panel with a simple border, and one panel
without border.

I've tried using Update(), Refresh(), SendSizeEvent() and
UpdateWindowUI(). Both on the panel in question, and on the frame itself.

I really am at a loss here, and sincerely hope there's someone out there
who can shed some light on the subject...

Settings styles after init is an undefined behavior in wx, which loosely translated means that for some styles it will work and for others it wont, and it can vary by platform.

Right now, I'm tempted to
write it off as a limitation in GTK and try to not depend on (or even
use) this function.

So, any ideas?

The only way to ensure that it works everywhere is to recreate the widget and destroy the old, but that can have its own set of problems depending on the situation. Or you could draw your own borders.

···

On 2/12/10 7:30 AM, Krank wrote:

--
Robin Dunn
Software Craftsman