I’ve got a UI panel with many elements on it (mostly comboxes and grids). I’ve divided these element up into groups of elements that I’ve put into their own classes which inherit from wx.Panel. The idea is that I have a top level class that manipulates objects from these classes. Should make it simpler to maintain than if I put everything in one class.
The grouped classes work fine on their own, the problem I’m having is that an event from one class needs to trigger an update in another. For example, I’ve got a file_selector object (several combo boxes) and a stats_display object (grid and some checkboxes). When I select a value from one of the file_selector’s comboboxes, I need to update the data in the stats_display object. However, I can’t find a way to communicate between the two.
I’ve tried custom events, but I can’t get that to work. Currently, the file_selector class handles the event and then tries wx.PostEvent() to pass it up, but that doesn’t work either. Here’s some rough code that should show basically what I’m trying to do…
class MasterPanel(wx.Panel): self.test_selector = TestSelectionPanel() self.data_stats = DataStatsPanel() self.Bind(self.test_selector.EVT_FILE_SELECT, self.OnFileSelect, self.test_selector) class TestSelectionPanel(wx.Panel): self.FileSelect, self.EVT_FILE_SELECT = wx.lib.newevent.NewCommandEvent() self.Bind(wx.EVT_COMBOBOX, self.OnFileSelect, self.file_selector) def OnFileSelect(self, e): e.Skip()
I’ve found a couple pages on events, which have some good info and answers a few question, but I’m having trouble piecing it into a solution.