Robin Dunn wrote:
Timothy Smith wrote:
everyones been super helpful but i have one last question.
i've got my example adding a row the way i want it to, but now i want to do something like SetValue on the grid, but do it from the MainFrame.
example, on selecting a day in the calendar object, set that date into the top row of each grid.
http://www.open-networks.net/Main_example.py shows my attempt. i realise it's wrong because i need to refference the object, not a method, but at this time of the time i'm either just not getting it or i'm completely off trackself.RosterWorkPanel.RosterTab.BarPanel.RosterWorkSheetGrid.SetCellValue(0,"Monday")
You start out great, but looking at the code the self.RosterWorkPanel object is never given a RosterTab attribute, so there is no way to get to it from self.RosterWorkPanel. Instead you have it as a local variable created just a few lines above:
RosterTab = wx.Notebook(RosterWorkPanel, -1)
BarPanel = TablePanel(RosterTab, 1)I think that the root of your confusion is that you think that the '.' operator is automatically traversing the parent/child window heirarchy. It does not, it is simply doing normal Python attribute access. The statement above is simply looking at the local variable named self, fetching its 'RosterWorkPanel' attribute, and then trying to fetch the 'RosterTab' attribute of that object. Since it was never assigned that attribute then you get an exception.
You might want to review some OOP or OOD texts to better understand the principle of encapsulation.
ah, see i was assuming RosterTab = wx.Notebook(RosterWorkPanel, -1) made RosterTab a child of RosterWorkPanel