window style question

I have this code:

import wx

class MyPanel(wx.Panel):
     def __init__(self, parent):
         wx.Panel.__init__(self, parent, -1)#, style=wx.SUNKEN_BORDER)
         # print self.GetWindowStyle()
         # self.SetWindowStyle(wx.SUNKEN_BORDER)
         self.SetWindowStyle(self.GetWindowStyle()|wx.SUNKEN_BORDER)

class MyFrame(wx.Frame):
     def __init__(self, title):
         wx.Frame.__init__(self, None, -1, title=title)
         panel = MyPanel(self)
app = wx.App(0)
f = MyFrame("Test Bed")
f.SetMinSize((100, 100))
f.Show()
app.MainLoop()

Now that throws
wx._core.PyAssertionError: C++ assertion "wxAssertFailure" failed in ..\..\src\msw\window.cpp(1180): unknown border style

why does that happen?

all I want is to add a certain style to the window after creation so.. I get the current style and add the border bit... what am I doing wrong.

specs: WinXP, py2.3.4, wxpy 2.5.3.1RC2

···

--
Peter Damoc
Hacker Wannabe
http://www.sigmacore.net/

Peter Damoc wrote:

I have this code:

import wx

class MyPanel(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, -1)#, style=wx.SUNKEN_BORDER)
        # print self.GetWindowStyle()
        # self.SetWindowStyle(wx.SUNKEN_BORDER)
        self.SetWindowStyle(self.GetWindowStyle()|wx.SUNKEN_BORDER)

class MyFrame(wx.Frame):
    def __init__(self, title):
        wx.Frame.__init__(self, None, -1, title=title)
        panel = MyPanel(self)
app = wx.App(0)
f = MyFrame("Test Bed")
f.SetMinSize((100, 100))
f.Show()
app.MainLoop()

Now that throws
wx._core.PyAssertionError: C++ assertion "wxAssertFailure" failed in ..\..\src\msw\window.cpp(1180): unknown border style

why does that happen?

You need to turn off the existing border style. Try it like this:

         style = self.GetWindowStyle() & ~wx.BORDER_MASK
         self.SetWindowStyle(style | wx.SUNKEN_BORDER)

···

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