Hi All,
Been coding Python on and off for a year now, but only just started looking at wx. Got a problem in a larger project I'm working on, trying to remove all items from a GridSizer - I've created the following test code to demonstrate the problem, but to summarize:
- calling .Remove(x) on the last element of the grid returns True but doesn't remove the object from the GUI
- calling .Clear() doesn't remove any items from the GUI
Anyway, code sample...
import wx
class Test:
def __init__(self):
app = wx.App(False)
frame = wx.Frame(None, wx.ID_ANY, "Test App")
panel = wx.Panel(frame)
vboxsizer = wx.BoxSizer(wx.VERTICAL)
self.grid = wx.GridSizer(rows=0, cols=3)
b0 = wx.Button(panel, label="Remove Button 0")
b1 = wx.Button(panel, label="Remove Button 1")
b2 = wx.Button(panel, label="Remove Button 2")
b3 = wx.Button(panel, label="Clear Buttons")
b4 = wx.Button(panel, label="Remove Button 4")
self.grid.Add(b0)
self.grid.Add(b1)
self.grid.Add(b2)
self.grid.Add(b3)
self.grid.Add(b4)
b0.Bind(wx.EVT_BUTTON, self.removeButton0)
b1.Bind(wx.EVT_BUTTON, self.removeButton1)
b2.Bind(wx.EVT_BUTTON, self.removeButton2)
b3.Bind(wx.EVT_BUTTON, self.removeButton3)
b4.Bind(wx.EVT_BUTTON, self.removeButton4)
vboxsizer.Add(self.grid, 1, border=2, flag=wx.EXPAND|wx.ALL)
panel.SetSizer(vboxsizer)
frame.Show(True)
app.MainLoop()
def removeButton0(self,e):
print self.grid.Remove(0)
self.grid.Layout()
def removeButton1(self,e):
print self.grid.Remove(1)
self.grid.Layout()
def removeButton2(self,e):
print self.grid.Remove(2)
self.grid.Layout()
def removeButton3(self,e):
#print self.grid.Remove(3)
self.grid.Clear()
self.grid.Layout()
def removeButton4(self,e):
print self.grid.Remove(4)
self.grid.Layout()
if __name__ == "__main__":
t = Test()
..Oh and as a side note, I could not for the life of me, make a DirDialog that didn't have a create folder button - even though I set the wx.DD_DIR_MUST_EXIST style.
Development system is Fedora 12/Gnome but final code must be cross-platform.
All help/ideas/explanations appreciated..
Thanks in advance