def add_row(self, filename): dict_manager.start_loading(filename) index = len(self.dictionary_controls) sizer = wx.BoxSizer(wx.HORIZONTAL) up = wx.BitmapButton(self, bitmap=self.up_bitmap) up.Bind(wx.EVT_BUTTON, lambda e: self.move_row_down(index - 1)) if len(self.dictionary_controls) == 0: up.Disable() else: self.dictionary_controls[-1].down.Enable() sizer.Add(up) down = wx.BitmapButton(self, bitmap=self.down_bitmap) down.Bind(wx.EVT_BUTTON, lambda e: self.move_row_down(index)) down.Disable() sizer.Add(down) remove = wx.BitmapButton(self, bitmap=self.remove_bitmap) remove.Bind(wx.EVT_BUTTON, lambda e: wx.CallAfter(self.remove_row, index)) sizer.Add(remove) label = wx.StaticText(self, label=filename) sizer.Add(label) controls = self.DictionaryControls(sizer, up, down, remove, label) self.dictionary_controls.append(controls) self.dicts_sizer.Add(sizer) self.FitInside()
def add_row(self, filename): dict_manager.start_loading(filename) index = len(self.dictionary_controls) sizer = wx.BoxSizer(wx.HORIZONTAL) up = wx.BitmapButton(self, bitmap=self.up_bitmap) up.Bind(wx.EVT_BUTTON, lambda e: self.move_row_down(index-1)) if len(self.dictionary_controls) == 0: up.Disable() else: self.dictionary_controls[-1].down.Enable() sizer.Add(up) down = wx.BitmapButton(self, bitmap=self.down_bitmap) down.Bind(wx.EVT_BUTTON, lambda e: self.move_row_down(index)) down.Disable() sizer.Add(down) remove = wx.BitmapButton(self, bitmap=self.remove_bitmap) remove.Bind(wx.EVT_BUTTON, lambda e: wx.CallAfter(self.remove_row, index)) sizer.Add(remove) label = wx.StaticText(self, label=filename) sizer.Add(label) controls = self.DictionaryControls(sizer, up, down, remove, label) self.dictionary_controls.append(controls) self.dicts_sizer.Add(sizer) if self.GetSizer(): self.GetSizer().Layout()