def _add_column(self, heading, accessor): column_identifier = at(accessor) self.column_identifiers[accessor] = column_identifier column = NSTableColumn.alloc().initWithIdentifier(column_identifier) self.table.addTableColumn(column) self.columns.append(column) column.headerCell.stringValue = heading
def create(self): # Create a tree view, and put it in a scroll view. # The scroll view is the _impl, because it's the outer container. self.native = NSScrollView.alloc().init() self.native.hasVerticalScroller = True self.native.hasHorizontalScroller = False self.native.autohidesScrollers = False self.native.borderType = NSBezelBorder # Create the Tree widget self.tree = TogaTree.alloc().init() self.tree.interface = self.interface self.tree._impl = self self.tree.columnAutoresizingStyle = NSTableViewColumnAutoresizingStyle.Uniform self.tree.usesAlternatingRowBackgroundColors = True self.tree.allowsMultipleSelection = self.interface.multiple_select # Create columns for the tree self.columns = [] # Cocoa identifies columns by an accessor; to avoid repeated # conversion from ObjC string to Python String, create the # ObjC string once and cache it. self.column_identifiers = {} for i, (heading, accessor) in enumerate( zip(self.interface.headings, self.interface._accessors)): column_identifier = at(accessor) self.column_identifiers[id(column_identifier)] = accessor column = NSTableColumn.alloc().initWithIdentifier( column_identifier) # column.editable = False column.minWidth = 16 # if self.interface.sorting: # sort_descriptor = NSSortDescriptor.sortDescriptorWithKey(column_identifier, ascending=True) # column.sortDescriptorPrototype = sort_descriptor self.tree.addTableColumn(column) self.columns.append(column) column.headerCell.stringValue = heading # Put the tree arrows in the first column. self.tree.outlineTableColumn = self.columns[0] self.tree.delegate = self.tree self.tree.dataSource = self.tree self.tree.target = self.tree self.tree.doubleAction = SEL('onDoubleClick:') # Embed the tree view in the scroll view self.native.documentView = self.tree # Add the layout constraints self.add_constraints()
def create(self): # Create a tree view, and put it in a scroll view. # The scroll view is the _impl, because it's the outer container. self.native = NSScrollView.alloc().init() self.native.hasVerticalScroller = True self.native.hasHorizontalScroller = False self.native.autohidesScrollers = False self.native.borderType = NSBezelBorder # Create the Tree widget self.tree = TogaTree.alloc().init() self.tree.interface = self.interface self.tree._impl = self self.tree.columnAutoresizingStyle = NSTableViewUniformColumnAutoresizingStyle self.tree.allowsMultipleSelection = self.interface.multiple_select # Create columns for the tree self.columns = [] # Cocoa identifies columns by an accessor; to avoid repeated # conversion from ObjC string to Python String, create the # ObjC string once and cache it. self.column_identifiers = {} for i, (heading, accessor) in enumerate( zip(self.interface.headings, self.interface._accessors)): column_identifier = at(accessor) self.column_identifiers[id(column_identifier)] = accessor column = NSTableColumn.alloc().initWithIdentifier( column_identifier) self.tree.addTableColumn(column) self.columns.append(column) cell = TogaIconCell.alloc().init() column.dataCell = cell column.headerCell.stringValue = heading # Put the tree arrows in the first column. self.tree.outlineTableColumn = self.columns[0] self.tree.delegate = self.tree self.tree.dataSource = self.tree # Embed the tree view in the scroll view self.native.documentView = self.tree # Add the layout constraints self.add_constraints()
def create(self): # Create a List, and put it in a scroll view. # The scroll view is the _impl, because it's the outer container. self.native = RefreshableScrollView.alloc().init() self.native.interface = self.interface self.native.impl = self self.native.hasVerticalScroller = True self.native.hasHorizontalScroller = False self.native.autohidesScrollers = False self.native.borderType = NSBezelBorder # Create the List widget self.detailedlist = TogaList.alloc().init() self.detailedlist.interface = self.interface self.detailedlist.impl = self self.detailedlist.columnAutoresizingStyle = NSTableViewColumnAutoresizingStyle.Uniform # TODO: Optionally enable multiple selection self.detailedlist.allowsMultipleSelection = False self.native.detailedlist = self.detailedlist # Create the column for the detailed list column = NSTableColumn.alloc().initWithIdentifier('data') self.detailedlist.addTableColumn(column) self.columns = [column] cell = TogaDetailedCell.alloc().init() column.dataCell = cell # Hide the column header. self.detailedlist.headerView = None self.detailedlist.delegate = self.detailedlist self.detailedlist.dataSource = self.detailedlist # Embed the tree view in the scroll view self.native.documentView = self.detailedlist # Add the layout constraints self.add_constraints()