def __init__( self, parent, initial_dict ): wx.Panel.__init__( self, parent ) self._listctrl = ClientGUICommon.SaneListCtrl( self, 120, [ ( 'key', 200 ), ( 'value', -1 ) ], delete_key_callback = self.Delete, activation_callback = self.Edit ) self._add = ClientGUICommon.BetterButton( self, 'add', self.Add ) self._edit = ClientGUICommon.BetterButton( self, 'edit', self.Edit ) self._delete = ClientGUICommon.BetterButton( self, 'delete', self.Delete ) # for display_tuple in initial_dict.items(): self._listctrl.Append( display_tuple, display_tuple ) # button_hbox = wx.BoxSizer( wx.HORIZONTAL ) button_hbox.AddF( self._add, CC.FLAGS_VCENTER ) button_hbox.AddF( self._edit, CC.FLAGS_VCENTER ) button_hbox.AddF( self._delete, CC.FLAGS_VCENTER ) vbox = wx.BoxSizer( wx.VERTICAL ) vbox.AddF( self._listctrl, CC.FLAGS_EXPAND_BOTH_WAYS ) vbox.AddF( button_hbox, CC.FLAGS_BUTTON_SIZER ) self.SetSizer( vbox )
def __init__( self, parent, bandwidth_rules ): ClientGUICommon.StaticBox.__init__( self, parent, 'bandwidth rules' ) columns = [ ( 'type', -1 ), ( 'time delta', 120 ), ( 'max allowed', 80 ) ] self._listctrl = ClientGUICommon.SaneListCtrl( self, 100, columns, delete_key_callback = self._Delete, activation_callback = self._Edit ) self._add_button = ClientGUICommon.BetterButton( self, 'add', self._Add ) self._edit_button = ClientGUICommon.BetterButton( self, 'edit', self._Edit ) self._delete_button = ClientGUICommon.BetterButton( self, 'delete', self._Delete ) # for rule in bandwidth_rules.GetRules(): sort_tuple = rule display_tuple = self._GetDisplayTuple( sort_tuple ) self._listctrl.Append( display_tuple, sort_tuple ) # hbox = wx.BoxSizer( wx.HORIZONTAL ) hbox.AddF( self._add_button, CC.FLAGS_LONE_BUTTON ) hbox.AddF( self._edit_button, CC.FLAGS_LONE_BUTTON ) hbox.AddF( self._delete_button, CC.FLAGS_LONE_BUTTON ) self.AddF( self._listctrl, CC.FLAGS_EXPAND_PERPENDICULAR ) self.AddF( hbox, CC.FLAGS_BUTTON_SIZER )