def __init__(self, drawGrid=False): self.w = Window((350, 20), "Toolbar Test", minSize=(250, 20)) customView = NSSegmentedControl.alloc().initWithFrame_( ((0, 0), (100, 30))) cell = customView.cell() cell.setTrackingMode_(NSSegmentSwitchTrackingSelectOne) cell.setSegmentCount_(2) cell.setImage_forSegment_(NSCursor.arrowCursor().image(), 0) cell.setImage_forSegment_(NSCursor.crosshairCursor().image(), 1) customView.sizeToFit() toolbarItems = [ { "itemIdentifier": "Test Item One", "label": "Test One", "imagePath": iconPath, "imageNamed": iconName, "callback": self.basicCallback }, { "itemIdentifier": "Test Item Two", "label": "Test Two", "imagePath": iconPath, "imageNamed": iconName, "callback": self.basicCallback }, { "itemIdentifier": "Test Item Three", "imagePath": iconPath, "imageNamed": iconName, "callback": self.basicCallback }, { "itemIdentifier": "Test Item Four", "label": "Test Four", "view": customView, "callback": self.basicCallback }, { "itemIdentifier": NSToolbarPrintItemIdentifier, "visibleByDefault": False }, { "itemIdentifier": NSToolbarFlexibleSpaceItemIdentifier }, { "itemIdentifier": NSToolbarCustomizeToolbarItemIdentifier }, ] self.w.addToolbar("Vanilla Test Toolbar", toolbarItems=toolbarItems) self.w.open()
def __init__(self, drawGrid=False): self.w = Window((350, 20), "Toolbar Test", minSize=(250, 20)) customView = NSSegmentedControl.alloc().initWithFrame_(((0, 0), (100, 30))) cell = customView.cell() cell.setTrackingMode_(NSSegmentSwitchTrackingSelectOne) cell.setSegmentCount_(2) cell.setImage_forSegment_(NSCursor.arrowCursor().image(), 0) cell.setImage_forSegment_(NSCursor.crosshairCursor().image(), 1) customView.sizeToFit() toolbarItems = [ {"itemIdentifier": "Test Item One", "label": "Test One", "imagePath": iconPath, "imageNamed": iconName, "callback": self.basicCallback}, {"itemIdentifier": "Test Item Two", "label": "Test Two", "imagePath": iconPath, "imageNamed": iconName, "callback": self.basicCallback}, {"itemIdentifier": "Test Item Three", "imagePath": iconPath, "imageNamed": iconName, "callback": self.basicCallback}, {"itemIdentifier": "Test Item Four", "label": "Test Four", "view": customView, "callback": self.basicCallback}, {"itemIdentifier": NSToolbarPrintItemIdentifier, "visibleByDefault": False}, {"itemIdentifier": NSToolbarFlexibleSpaceItemIdentifier}, {"itemIdentifier": NSToolbarCustomizeToolbarItemIdentifier}, ] self.w.addToolbar("Vanilla Test Toolbar", toolbarItems=toolbarItems) self.w.open()
b = "\x00" d = b * 1024 ns_bitmap = NSBitmapImageRep.alloc().\ initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel_\ ((d, d, d, d, d), 16, 16, 8, 4, True, False, NSDeviceRGBColorSpace, 64, 32) ns_image = NSImage.alloc().initWithSize_((16, 16)) ns_image.addRepresentation_(ns_bitmap) ns_cursor = NSCursor.alloc().initWithImage_hotSpot_(ns_image, (0, 0)) _empty_cursor = Cursor._from_ns_cursor(ns_cursor) _empty_cursor._data = d return _empty_cursor arrow = Cursor._from_ns_cursor(NSCursor.arrowCursor()) ibeam = Cursor._from_ns_cursor(NSCursor.IBeamCursor()) crosshair = Cursor._from_ns_cursor(NSCursor.crosshairCursor()) fist = Cursor._from_ns_cursor(NSCursor.closedHandCursor()) hand = Cursor._from_ns_cursor(NSCursor.openHandCursor()) finger = Cursor._from_ns_cursor(NSCursor.pointingHandCursor()) invisible = _make_empty_cursor() mac_poof = Cursor._from_ns_cursor(NSCursor.disappearingItemCursor()) del NSCursor del Cursor del _make_empty_cursor def empty_cursor(): return invisible
b = bytes([0]) else: b = "\x00" d = b * 1024 ns_bitmap = NSBitmapImageRep.alloc().\ initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel_\ ((d, d, d, d, d), 16, 16, 8, 4, True, False, NSDeviceRGBColorSpace, 64, 32) ns_image = NSImage.alloc().initWithSize_((16, 16)) ns_image.addRepresentation_(ns_bitmap) ns_cursor = NSCursor.alloc().initWithImage_hotSpot_(ns_image, (0, 0)) _empty_cursor = Cursor._from_ns_cursor(ns_cursor) _empty_cursor._data = d return _empty_cursor arrow = Cursor._from_ns_cursor(NSCursor.arrowCursor()) ibeam = Cursor._from_ns_cursor(NSCursor.IBeamCursor()) crosshair = Cursor._from_ns_cursor(NSCursor.crosshairCursor()) fist = Cursor._from_ns_cursor(NSCursor.closedHandCursor()) hand = Cursor._from_ns_cursor(NSCursor.openHandCursor()) finger = Cursor._from_ns_cursor(NSCursor.pointingHandCursor()) invisible = _make_empty_cursor() mac_poof = Cursor._from_ns_cursor(NSCursor.disappearingItemCursor()) del NSCursor del Cursor del _make_empty_cursor def empty_cursor(): return invisible