本文整理汇总了Python中Foundation.NSDictionary.dictionaryWithObjectsAndKeys_方法的典型用法代码示例。如果您正苦于以下问题:Python NSDictionary.dictionaryWithObjectsAndKeys_方法的具体用法?Python NSDictionary.dictionaryWithObjectsAndKeys_怎么用?Python NSDictionary.dictionaryWithObjectsAndKeys_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Foundation.NSDictionary
的用法示例。
在下文中一共展示了NSDictionary.dictionaryWithObjectsAndKeys_方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeDragImage
# 需要导入模块: from Foundation import NSDictionary [as 别名]
# 或者: from Foundation.NSDictionary import dictionaryWithObjectsAndKeys_ [as 别名]
def makeDragImage(self):
if self.delegate is None:
return
image = NSImage.alloc().initWithSize_(self.frame().size)
image.lockFocus()
frame = self.frame()
frame.origin = NSZeroPoint
rect = NSInsetRect(frame, 1.5, 1.5)
if self.conferencing and not self.draggedOut:
NSColor.selectedControlColor().colorWithAlphaComponent_(0.7).set()
else:
NSColor.whiteColor().colorWithAlphaComponent_(0.7).set()
path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(rect, 5.0, 5.0)
path.fill()
if self.selected:
path.setLineWidth_(3)
NSColor.grayColor().set()
else:
path.setLineWidth_(1)
NSColor.grayColor().set()
path.stroke()
NSColor.blackColor().set()
point = NSMakePoint(8, NSMaxY(frame)-20)
uri = format_identity_to_string(self.delegate.sessionController.remotePartyObject, check_contact=False, format='compact')
NSString.stringWithString_(uri).drawAtPoint_withAttributes_(point,
NSDictionary.dictionaryWithObjectsAndKeys_(NSFont.boldSystemFontOfSize_(12), NSFontAttributeName))
point = NSMakePoint(8, 6)
if self.conferencing:
NSString.stringWithString_(NSLocalizedString("Drop outside to remove from conference", "Audio session label")).drawAtPoint_withAttributes_(point,
NSDictionary.dictionaryWithObjectsAndKeys_(NSFont.systemFontOfSize_(10), NSFontAttributeName))
else:
audio_sessions = [sess.hasStreamOfType("audio") for sess in NSApp.delegate().contactsWindowController.sessionControllersManager.sessionControllers]
if self.delegate.transferEnabled:
text = NSLocalizedString("Drop this over a session or contact", "Audio session label") if len(audio_sessions) > 1 else NSLocalizedString("Drop this over a contact to transfer", "Audio session label")
else:
text = NSLocalizedString("Drop this over a session to conference", "Audio session label")
NSString.stringWithString_(text).drawAtPoint_withAttributes_(point,
NSDictionary.dictionaryWithObjectsAndKeys_(NSFont.systemFontOfSize_(10), NSFontAttributeName))
icon = NSImage.imageNamed_("NSEveryone")
rect = frame
s = icon.size()
p = NSMakePoint(NSWidth(rect) - s.width - 8, rect.size.height - s.height - 8)
r = NSMakeRect(0, 0, s.width, s.height)
icon.drawAtPoint_fromRect_operation_fraction_(p, r, NSCompositeSourceOver, 0.5)
image.unlockFocus()
return image
示例2: paramsDictionary
# 需要导入模块: from Foundation import NSDictionary [as 别名]
# 或者: from Foundation.NSDictionary import dictionaryWithObjectsAndKeys_ [as 别名]
def paramsDictionary(self):
self.fCutoff = min(self.fCutoff, self.sampleRate/2.)
return NSDictionary.dictionaryWithObjectsAndKeys_(
self.mean, BLWN_MEAN_KEY,
self.var, BLWN_VAR_KEY,
self.fCutoff, BLWN_FREQ_KEY,
self.nPoles, BLWN_NPOLES_KEY,
self.sampleRate, BLWN_SAMPLE_RATE_KEY,
self.length, BLWN_LENGTH_KEY,
pickle.dumps(self.rSource.get_state()[:3]), BLWN_RANDOM_STATE_KEY,
numpy.__version__, 'numpyVersion',
None)
示例3: refreshLibrary
# 需要导入模块: from Foundation import NSDictionary [as 别名]
# 或者: from Foundation.NSDictionary import dictionaryWithObjectsAndKeys_ [as 别名]
def refreshLibrary(self):
if not self.history:
return
settings = SIPSimpleSettings()
own_icon_path = settings.presence_state.icon
selected_icon = None
def md5sum(filename):
md5 = hashlib.md5()
with open(filename,'rb') as f:
for chunk in iter(lambda: f.read(128*md5.block_size), b''):
md5.update(chunk)
return md5.hexdigest()
if os.path.exists(self.storage_folder):
files = os.listdir(self.storage_folder)
else:
files = []
array = NSMutableArray.array()
knownFiles = set()
for item in self.contentArrayController.arrangedObjects():
knownFiles.add(unicode(item.objectForKey_("path")))
seen_md5sum = {}
i = 0
for f in files:
if not f.startswith('user_icon') and not f.startswith('photo') and f != 'default_user_icon.tiff':
continue
p = os.path.normpath(self.storage_folder + "/" + f)
if p not in knownFiles:
photos_folder = unicodedata.normalize('NFC', self.storage_folder)
filename = os.path.join(photos_folder, f)
checksum = md5sum(filename)
try:
seen_md5sum[filename]
except KeyError:
seen_md5sum[filename] = checksum
image = NSImage.alloc().initWithContentsOfFile_(p)
if not image:
continue
item = NSDictionary.dictionaryWithObjectsAndKeys_(image, "picture", p, "path")
array.addObject_(item)
if own_icon_path is not None and filename == unicode(own_icon_path):
selected_icon = i
i += 1
if array.count() > 0:
self.contentArrayController.addObjects_(array)
if selected_icon is not None:
self.libraryCollectionView.setSelectionIndexes_(NSIndexSet.indexSetWithIndex_(selected_icon))
示例4: renderDailyEntries
# 需要导入模块: from Foundation import NSDictionary [as 别名]
# 或者: from Foundation.NSDictionary import dictionaryWithObjectsAndKeys_ [as 别名]
def renderDailyEntries(self, results):
getFirstContactMatchingURI = NSApp.delegate().contactsWindowController.getFirstContactMatchingURI
self.dayly_entries = NSMutableArray.array()
for result in results:
contact = getFirstContactMatchingURI(result[2], exact_match=True)
if contact:
remote_uri = '%s <%s>' % (contact.name, result[2])
else:
remote_uri = result[2]
entry = NSDictionary.dictionaryWithObjectsAndKeys_(result[1], "local_uri", remote_uri, "remote_uri", result[2], "remote_uri_sql", result[0], 'date', result[3], 'type')
self.dayly_entries.addObject_(entry)
self.dayly_entries.sortUsingDescriptors_(self.indexTable.sortDescriptors())
self.indexTable.reloadData()
if self.search_uris and not self.dayly_entries:
self.contactTable.deselectAll_(True)
示例5: drawRect_
# 需要导入模块: from Foundation import NSDictionary [as 别名]
# 或者: from Foundation.NSDictionary import dictionaryWithObjectsAndKeys_ [as 别名]
def drawRect_(self, rect):
r = self.bounds()
r.size.width -= 0.5
r.size.height += 4
if self.draggedOut:
NSColor.colorWithDeviceWhite_alpha_(0.4, 1.0).set()
path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(r, 5, 5)
path.fill()
else:
if self == self.switcher.activeItem():
NSColor.controlColor().set()
else:
NSColor.colorWithDeviceWhite_alpha_(0.6, 1.0).set()
path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(r, 5, 5)
path.fill()
NSColor.colorWithDeviceRed_green_blue_alpha_(0.3, 0.3, 0.3, 1.0).set()
path.stroke()
if self.badgeLabel and not self.mouseInside and not self.busyIndicator and not self.composing:
# draw the number in redbadge indicator
gradient = NSGradient.alloc().initWithStartingColor_endingColor_(
NSColor.colorWithDeviceRed_green_blue_alpha_(0.9, 0.2, 0.2, 1),
NSColor.colorWithDeviceRed_green_blue_alpha_(1.0, 0.2, 0.2, 1))
size = self.badgeLabel.size()
size.width += 4
if size.width < 12:
size.width = 12
bez = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(NSMakeRect(3, 5, size.width, 12), 6, 6)
gradient.drawInBezierPath_angle_(bez, 90+45)
self.badgeLabel.drawInRect_(NSMakeRect(3, 5, size.width, 12))
if not self.mouseInside and not self.busyIndicator and self.composing:
rect = NSZeroRect.copy()
rect.size = self.composeIcon.size()
self.composeIcon.drawAtPoint_fromRect_operation_fraction_(NSMakePoint(1, 3), rect, NSCompositeSourceOver, 1)
if not self.busyIndicator and self.screen_sharing_active:
rect = NSZeroRect.copy()
rect.size = self.screenIcon.size()
self.screenIcon.drawAtPoint_fromRect_operation_fraction_(NSMakePoint(17, 3), rect, NSCompositeSourceOver, 1)
if not self.draggedOut:
shadow = NSShadow.alloc().init()
shadow.setShadowOffset_(NSMakeSize(0, -1))
if self == self.switcher.activeItem():
shadow.setShadowColor_(NSColor.whiteColor())
else:
shadow.setShadowColor_(NSColor.colorWithDeviceWhite_alpha_(0.7, 1.0))
para = NSParagraphStyle.defaultParagraphStyle().mutableCopy()
para.setLineBreakMode_(NSLineBreakByTruncatingTail)
para.setAlignment_(NSCenterTextAlignment)
attribs = NSDictionary.dictionaryWithObjectsAndKeys_(NSFont.systemFontOfSize_(11), NSFontAttributeName,
shadow, NSShadowAttributeName,
para, NSParagraphStyleAttributeName)
rect = self.bounds()
rect.origin.y -= 3
rect.origin.x += 20
rect.origin.x = rect.origin.x + 12 if self.screen_sharing_active else rect.origin.x
rect.size.width -= 46
rect.size.width = rect.size.width - 12 if self.screen_sharing_active else rect.size.width
self.label.drawInRect_withAttributes_(rect, attribs)