Martin, you are recreating a new panel each time you select an item.
I've modified you code such that the StaticText control is placed on the
right panel in __init__ and set the label to "". Then all you have to do
is update the label in your OnSelected method. I didn't notice any
flicker on my end, try the attached sample and see if it works for you.
-Kyle Rickey
wxtest.py (1.68 KB)
···
-----Original Message-----
From: martin-schmitz@web.de [mailto:martin-schmitz@web.de]
Sent: Wednesday, February 27, 2008 8:20 AM
To: wxPython-users@lists.wxwidgets.org
Subject: [wxPython-users] How to change panels/windows
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