Feb-23-2017, 01:03 PM
One case more in these things...
Then why does (0, 0) not fullfill the requirements of (w,h) or the requirement of being a position respectively, as is needed by
import wx gridcontent = [["1", "2", "3", "4"], ["5", "6", "7", "8"]] class Mainframe(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title) self.grid = wx.GridBagSizer() for rownum, gridcontentrow in enumerate(gridcontent): for colnum, string in enumerate(gridcontentrow): pos = (rownum, colnum) print pos self.grid.Add(string, pos) self.SetSizer(self.grid) if __name__ == "__main__": app = wx.App(0) preframe = Mainframe(None, -1, "Datenanzeige") app.MainLoop()gives
Error:Traceback (most recent call last):
File "...Gridbagsizerpos01a.py", line 20, in <module>
preframe = Mainframe(None, -1, "Datenanzeige")
File "...Gridbagsizerpos01a.py", line 15, in __init__
self.grid.Add(string, pos)
File "...Python27\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 14086, in Add
return _core_.GridBagSizer_Add(*args, **kwargs)
TypeError: wx.Window, wx.Sizer, wx.Size, or (w,h) expected for item
The wxpython docs claim: "wxPython has typemaps that will automatically convert from a 2-element sequence of integers to a wx.GBPosition, so you can use the more pythonic representation of the position nearly transparently in Python code." Then why does (0, 0) not fullfill the requirements of (w,h) or the requirement of being a position respectively, as is needed by
GridBagSizer.Add(self, item, pos, span=DefaultSpan, flag=0, border=0, userData=None)
?