ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> wxPython-users
wxPython-users
[wxPython-users] Bug in GridBagSizer subclasses
by Ed Leafe other posts by this author
Dec 5 2004 3:24PM messages near this date
Re: [wxPython-users] Re: Howto get default gtk icons | [wxPython-users] wxXmlResource - LoadMenuBar()-Error...
If a subclass of wx.GridBagSizer is added to another sizer, it loses 
all references to all of its subclass information, and acts like a base 
class wx.GridBagSizer. Subclasses of wx.BoxSizer do not display this 
problem; they work as expected.

	I've created a small test application that demonstrates this problem 
(code below my sig). I first noticed it when working with some Dabo 
sizer subclasses, and thought it might be something in our code. But 
this is pure wxPython-only code, and it shows the same behavior.

	I've run this code on wxPython 2.5.2.8/OS X and 2.5.2.7/Win 2K; both 
are running Python 2.3.3.

      ___/
     /
    __/
   /
  ____/
  Ed Leafe
  http://leafe.com/
  http://dabodev.com/


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
- - - - - -
import wx

class xSizer(wx.BoxSizer):
	CustomAttribute = 42

class xGridSizer(wx.GridBagSizer):
	CustomAttribute = 42

class SizerFrame(wx.Frame):
	def __init__(self, parent, id, title):
		super(SizerFrame, self).__init__(parent, id, title)
		btnID = wx.NewId()
		btn = wx.Button(self, btnID, "Run Test")
		self.Bind(wx.EVT_BUTTON, self.test)
		
	def test(self, evt):
		sz = wx.BoxSizer(wx.VERTICAL)
		self.SetSizer(sz)
		print "-" * 66
		print "Form's sizer:", sz
		print
		
		grdSz = xGridSizer()
		print "Grid Sizer:", grdSz
		print "Grid Sizer class:", grdSz.__class__
		print "Grid Sizer Attribute:", hasattr(grdSz,"CustomAttribute")
		print
		
		boxSz = xSizer()
		print "Box Sizer:", boxSz
		print "Box Sizer class:", boxSz.__class__
		print "Box Sizer Attribute:", hasattr(boxSz,"CustomAttribute")
		print
		
		sz.Add(grdSz)
		sz.Add(boxSz)
		szChildren = sz.GetChildren()
		# There are only two children, the grid sizer
		# and the box sizer
		childGridSz = szChildren[0].GetSizer()
		childBoxSz = szChildren[1].GetSizer()
		
		print "Child grid sizer:", childGridSz
		print "Child grid class:", childGridSz.__class__
		print "Child grid Attribute:", hasattr(childGridSz, "CustomAttribute")
		print
		
		print "Child box sizer:", childBoxSz		
		print "Child box class:", childBoxSz.__class__
		print "Child box Attribute:", hasattr(childBoxSz, "CustomAttribute")
		print "-" * 66

		self.Destroy()

def main():
	app = wx.PySimpleApp()
	frame = SizerFrame(None, -1, "Sizer Test")
	frame.Show(1)
	app.MainLoop()
	
if __name__ == "__main__":
	main()
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
- - - - - -


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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved