basic wxpython help
Vamp4L
vampiro4l at gmail.com
Sat Feb 16 11:04:35 EST 2008
Hello,
I'm brand new to wxpython, trying to implement some code to add rows
in the GUI dynamically. What I want to do is when you click on the
Add Row button, a new row gets added after the first row, before the
button. This code adds a row in the right place, but it overlaps the
button because it doesn't shift the button down. Here's what I have
so far:
class TestPanel(wx.Panel):
def __init__(self, parent, log):
self.log = log
wx.Panel.__init__(self, parent, -1)
fgs = self.fgs = wx.FlexGridSizer(cols=1, hgap=10, vgap=10)
fgs.Add(wx.StaticText(self, -1, "Label 1"))
a1a = self.a1a = wx.FlexGridSizer(cols=5, hgap=10, vgap=10)
fgs.Add(a1a)
a1a.Add(wx.StaticText(self, -1, "User:"))
cc = wx.Choice(self, -1, choices=["A", "B"])
a1a.Add(cc)
cc = FileSelectorCombo(self, size=(250, -1))
a1a.Add((10,10))
a1a.Add(wx.StaticText(self, -1, "Path:"))
a1a.Add(cc)
b = wx.Button(self, -1, "Add Row", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButtonIE7, b)
fgs.Add(b)
box = wx.BoxSizer()
box.Add(fgs, 1, wx.EXPAND|wx.ALL, 20)
self.SetSizer(box)
a1 = wx.FlexGridSizer(cols=5, hgap=10, vgap=10)
fgs.Add(a1)
b = wx.Button(self, -1, "Run Report", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButtonRun, b)
a1.Add(b)
b = wx.Button(self, -1, "Close", (50,50))
self.Bind(wx.EVT_BUTTON, self.OnButtonClose, b)
a1.Add(b)
def OnButtonIE7(self, evt):
self.a1a.Add(wx.StaticText(self, -1, "Label 1"))
self.a1a.Layout()
def OnButtonRun(self, evt):
wx.StaticText(self, -1, "User:")
def OnButtonClose(self, evt):
dlg = wx.MessageDialog(self, "Are you sure you want to exit?",
"Exit", wx.YES_NO | wx.ICON_QUESTION)
if dlg.ShowModal() == wx.ID_YES:
self.Destroy() # frame
sys.exit(1)
dlg.Destroy()
Any suggestions?
Thanks!
More information about the Python-list
mailing list