[wxPython-users] confused,
where do widgets lie after adding to a gridbag?
Dj Gilcrease
digitalxero at gmail.com
Sun Jul 15 18:07:44 PDT 2007
On 7/15/07, krishnakant Mane <researchbase at gmail.com> wrote:
> hello,
> I had posted a question a few hours back along with attached code
> asking about accessibg the widgets and their attributes.
> I probably found (at last ) the source of my problem.
> the problem is that I can't say self.TXTCtrl1.GetValue after it is
> added to a gridbag sizer.
You can access a control after you add it to the GridBagSizer, the
problem is you are attempting to create the widgets all wrong.
import wx
class SizerFrame (wx.Frame):
def __init__ (self):
wx.Frame.__init__ (self,None, -1, 'Blocks')
self.panel = wx.Panel ( self, -1 )
self.sizer = wx.GridBagSizer ( 2, 2 )
self.lblID = wx.StaticText(self.panel, wx.ID_ANY, 'Block ID'),
self.sizer.Add(self.lblID, (1, 0) )
self.txtID = wx.TextCtrl( self.panel, wx.ID_ANY)
self.sizer.Add (self.txtID, (1, 1))
self.lblName = wx.StaticText(self.panel, wx.ID_ANY, 'Block Name')
self.sizer.Add(self.lblName, ( 2, 0))
self.txtID = wx.TextCtrl(self.panel, wx.ID_ANY)
self.sizer.Add (self.txtID, ( 2, ))
self.lblBlockHead = wx.StaticText(self.panel, wx.ID_ANY, 'Block Head')
self.sizer.Add(self.lblBlockHead, ( 3, 0))
self.txtBlockHead = wx.TextCtrl(self.panel, wx.ID_ANY)
self.sizer.Add (self.txtBlockHead, ( 3, 1))
self.CMDNew = wx.Button(self.panel, wx.ID_ANY, 'New' )
self.sizer.Add (self.CMDNew, ( 8, 0))
self.CMDEdit = wx.Button(self.panel, wx.ID_ANY, 'Edit ')
self.sizer.Add (self.CMDEdit, ( 8, 1))
self.CMDSave = wx.Button(self.panel, wx.ID_ANY, 'Save' )
self.sizer.Add (self.CMDSave, ( 8, 2))
self.CMDDelete = wx.Button(self.panel, wx.ID_ANY, 'Delete' )
self.sizer.Add (self.CMDDelete, ( 8, 3))
self.CMDClose = wx.Button (self.panel, wx.ID_ANY, 'Close' )
self.sizer.Add (self.CMDClose, ( 8, 4))
self.Bind(wx.EVT_BUTTON, self.closeme, self.CMDClose)
self.panel.SetSizerAndFit(self.sizer)
self.SetClientSize (self.panel.GetSize())
self.CenterOnParent()
self.Show()
def closeme(self,event):
self.Hide()
application = wx.PySimpleApp()
window = SizerFrame()
application.MainLoop()
More information about the wxpython-users
mailing list