def create(self): # Create a multiline view, and put it in a scroll view. # The scroll view is the native, 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 # Disable all autolayout functionality on the outer widget self.native.translatesAutoresizingMaskIntoConstraints = False # Create the actual text widget self.text = TogaTextView.alloc().init() self.text.editable = True self.text.selectable = True self.text.verticallyResizable = True self.text.horizontallyResizable = False self.text.autoresizingMask = NSViewWidthSizable # Put the text view in the scroll window. self.native.documentView = self.text # 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 = 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): self.native = NSScrollView.alloc().init() self.native.autohidesScrollers = True self.native.borderType = NSNoBorder self.native.backgroundColor = NSColor.windowBackgroundColor # self.native.backgroundColor = NSColor.blueColor self.native.translatesAutoresizingMaskIntoConstraints = False self.native.autoresizesSubviews = True # Add the layout constraints self.add_constraints()
def _construct_alert( title, message, details=None, details_title="Traceback", button_labels=("Ok", ), checkbox_text=None, level="info", icon=None, ): a = NSAlert.alloc().init() a.alertStyle = alert_style_for_level_str[level] a.messageText = title a.informativeText = message a.icon = icon if details: scroll = NSScrollView.alloc().initWithFrame(NSMakeRect(0, 0, 500, 250)) scroll.hasVerticalScroller = True scroll.hasHorizontalScroller = False scroll.autohidesScrollers = False scroll.borderType = NSBezelBorder trace = NSTextView.alloc().init() trace.editable = False trace.verticallyResizable = True trace.horizontallyResizable = True trace.insetText(details) scroll.documentView = trace title = NSTextField.labelWithString(details_title) title.font = Font(SYSTEM, 12, weight=BOLD).bind(factory).native stack = NSStackView.alloc().initWithFrame(NSMakeRect(0, 0, 500, 265)) stack.orientation = NSUserInterfaceLayoutOrientationVertical stack.alignment = NSLayoutAttributeLeading stack.addView(title, inGravity=NSStackViewGravityBottom) stack.addView(scroll, inGravity=NSStackViewGravityBottom) a.accessoryView = stack if checkbox_text: a.showsSuppressionButton = True a.suppressionButton.title = checkbox_text for name in button_labels: a.addButtonWithTitle(name) return a
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): self._view_for_row = dict() # Create a table view, and put it in a scroll view. # The scroll view is the native, 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 self.table = TogaTable.alloc().init() self.table.interface = self.interface self.table._impl = self self.table.columnAutoresizingStyle = NSTableViewColumnAutoresizingStyle.Uniform self.table.usesAlternatingRowBackgroundColors = True self.table.allowsMultipleSelection = self.interface.multiple_select # Create columns for the table 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 heading, accessor in zip(self.interface.headings, self.interface._accessors): self._add_column(heading, accessor) self.table.delegate = self.table self.table.dataSource = self.table self.table.target = self.table self.table.doubleAction = SEL('onDoubleClick:') # Embed the table view in the scroll view self.native.documentView = self.table # Add the layout constraints self.add_constraints()