appkit

Python 3 No Module Named AppKit

孤者浪人 提交于 2019-12-07 07:41:42
问题 I am trying to run an audio file in python from playsound import playsound def main(): playsound('audio.mp3') main() However, I keep getting the following error: File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/playsound.py", line 55, in _playsoundOSX from AppKit import NSSound ImportError: No module named 'AppKit' I am using Python 3.5.4 on macOS 10.12.6. I have tried installing it via pip but I am returned this error: Using cached AppKit-0.2.8.tar.gz

Shaving a couple levels of indentation off of an NSOutlineView

余生颓废 提交于 2019-12-07 01:50:48
问题 I have an outline view where I don't want to indent the top couple levels (they have a distinctive appearance anyway), but I do want to indent subsequent levels. How can I do this? I've tried overriding -levelForRow: and -levelForItem: to subtract 2 from the return values, but this didn't help. I also tried overriding -frameOfOutlineCellAtRow: to subtract 2 * indentationPerLevel from the frame's width, but that didn't help either, possibly because I'm not showing disclosure triangles. Any

Mac OS X replacement for NSFetchedResultsController

风流意气都作罢 提交于 2019-12-06 22:41:42
问题 So I'm used to iOS development so I'm pretty happy with NSFetchedResultsController. However, this is not present in the Mac OS X environment. I know that I can use NSArrayController as a replacement. I might be using this class terribly wrong but it worked until now. I initialize the NSArrayController as follows: NSArrayController* newConversationsController = [NSArrayController new]; newConversationsController.managedObjectContext = context; newConversationsController.entityName = entityName

Ignoring UI Events in AppKit

谁都会走 提交于 2019-12-06 13:40:31
问题 If I wanted to ignore a touch event in UIKit on the iPhone I would simply do: // Begin ignoring events [[UIApplication sharedApplication] beginIgnoringInteractionEvents]; //Do my code // Stop ignoring events [[UIApplication sharedApplication] endIgnoringInteractionEvents]; This allows my code in between the "ignore" calls to operate without having to worry about user interaction changing any state of the application. My question is, how can I do this if I am writing a Mac OS X app (AppKit vs.

How do I update the expansion tooltip size after calling NSTextField setStringValue:?

孤者浪人 提交于 2019-12-06 13:25:31
When a view contains an NSTextField with the expansion tooltip enabled and the text doesn't fit, then the user hovers the cursor over the field, OS X shows an expansion tooltip. If you then call setStringValue: to change the text content of the NSTextField , the expansion tooltip's size is not updated. For instance, if the original text was 100 characters long but the new text is only 50 characters long, hovering over the new text will show an expansion tooltip large enough for 100 characters containing the new text. This is true even if the new string fits entirely in the NSTextField , which

NSTextField clicked link colour

烂漫一生 提交于 2019-12-06 10:59:38
I have an NSTextField that contains an NSAttributedString which itself contains a clickable link. I've change the colour of the link for my own styling, however when I click on it it becomes blue and underlined. How can I stop this? Seems that I'm not the only one with this problem, and there's a handy class to solve it: https://github.com/laevandus/NSTextFieldHyperlinks This ( http://developer.apple.com/library/mac/#qa/qa1487/_index.html ) may help you. It will show you how to set/change the blue link color and the underlineAttribute. You may also have a look at the methods

Dynamically resize NSWindow based on NSOutlineView height

喜欢而已 提交于 2019-12-06 06:40:56
I have read many answers to questions about dynamically resizing NSWindows and nothing has quite worked yet. I have built a 'popover' like window to be displayed form the menu bar, I couldn't use NSPopover because it isn't quite customisable enough in terms of design. My view hierarchy current looks like this: NSWindow Subclass - NSView (clears the titlebar rendering, draws popover arrow) - NSView (contentView) - NSOutlineView (main table of content) - NSView (window footer) What I need is for the window to expand and contract with items in the NSOutlineView expanding and contracting, so that

How does +[NSColor selectedMenuItemColor] magically draw a gradient?

▼魔方 西西 提交于 2019-12-06 04:43:19
问题 I'm implementing a custom NSMenuItem view that shows a highlight as the user mouses over it. To do this, the code calls NSRectFill after setting [NSColor selectedMenuItemColor] as the active color. However, I noticed that the result is not simply a solid color — it actually draws a gradient instead. Very nice, but wondering how this "magic" works — i.e. if I wanted to define my own color that didn't just draw solid, how would I? 回答1: I don't know how this actually works, but I found a way to

How do I change/modify the displayed title of an NSPopUpButton

白昼怎懂夜的黑 提交于 2019-12-06 02:15:15
I would like an NSPopUpButton to display a different title than the title of the menu item that is selected. Suppose I have an NSPopUpButton that lets the user pick a list of currencies, how can I have the collapsed/closed button show only the currencies abbreviation instead of the menu title of the selected currency (which is the full name of the currency)? I imagine I can override draw in a subclass (of NSPopUpButtonCell ) and draw the entire button myself, but I would prefer a more lightweight approach for now that reuses the system's appearance. The menu items have the necessary

How to Color the “Overshoot” Background of an NSCollectionView

跟風遠走 提交于 2019-12-05 23:48:57
I have implemented a collection view on my Cocoa app following Ray Wenderlich's tutorial (very helpful, given how buggy and broken Apple's API is in this area). In the tutorial, the collection view's canvas is colored black using the following code (all code is in view controller class' viewDidLoad() method): collectionView.layer?.backgroundColor = NSColor.black.cgColor However, the area that "peeks" when you overshoot ("rubber-band") the scroll using -for example- a magic mouse/scrollwheel, is still white and very distracting: I'm trying to make the whole content area black. In my storyboard,