How to change panels/windows

In case you MUST create a new panel each time I suggest using Freeze() and Thaw()

def OnSelected(self, event):
self.Freeze()
self.item = event.GetItem().GetData()

    oldPanel = self.rp
    newPanel = wx.Panel(self.sp)
    newPanel.SetBackgroundColour('#ffffdd')
    self.rsizer = wx.BoxSizer(wx.VERTICAL)
    self.text = wx.StaticText(newPanel, -1, "Selected: %s" % self.item)

    self.rsizer.Add(self.text, 1, wx.EXPAND)
    self.sp.ReplaceWindow(self.rp, newPanel)
    newPanel.SetSizer(self.rsizer)
    self.rp.Destroy()
    self.rp = newPanel
    self.Thaw()

In any other case changing the content of the panel is better (using SetLabel/SetValue in each control).

···

On Wed, Feb 27, 2008 at 4:19 PM, Martin Schmitz martin-schmitz@web.de wrote:

Hello list,

I want to have a wx.SplitterWindow with a wx.ListCtrl on the left and a
panel on the right where details about the selected entry in the list

on the left are displayed. Every time a new item is selected in the
list, the details display on the right should be exchanged.

What I tried is basically this:

sp = SplitterWindow, rp = right Panel, lp = left Panel

def OnSelected(self, event):
self.item = event.GetItem().GetData()
oldPanel = self.rp
newPanel = wx.Panel(self.sp)
newPanel.SetBackgroundColour(‘#ffffdd’)
self.rsizer = wx.BoxSizer(wx.VERTICAL)

   self.text = wx.StaticText(newPanel, -1, "Selected: %s" % \
       self.item) self.rsizer.Add(self.text, 1, wx.EXPAND)
   self.sp.ReplaceWindow(self.rp, newPanel)
   newPanel.SetSizer(self.rsizer)

   self.rp.Destroy()
   self.rp = newPanel

It works perfectly well, despite the fact that everytime the new Panel
is created (everytime a new entry is selected), I see the new Panel
flickering in sight at the top left corner of my frame. This doesn’t

look well and is quite annoying to me.

I tried various ways to update the right panel, removing and adding it
from/to the sizer for example. But everytime a line like
“spam = wx.Panel(parent)” is called, the new panel immediatly appears

on the top left corner of the frame.

So, how am I supposed to update/exchange a wx.Panel/wx.Window without
flickering on screen?

Attached is a full minimal version of my program which shows the
problem.

TIA,
Martin


To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org

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