def create_main_surface(): pygame.init() surface = pygame.display.set_mode((320, 240)) SDL_QuartzWindow = objc.lookUpClass('SDL_QuartzWindow') class SDL_QuartzWindow(objc.Category(SDL_QuartzWindow)): def canBecomeKeyWindow(self): return True def canBecomeMainWindow(self): return True def acceptsFirstResponder(self): return True def becomeFirstResponder(self): return True def resignFirstResponder(self): return True global window_controller window_controller = WindowController() # run the run loop just once to finish setting up the window NSRunLoop.mainRunLoop().runMode_beforeDate_(NSDefaultRunLoopMode, NSDate.date()) return surface
def createKnownNetwork(networkDict): print 'Creating KnownNetworks entry' # There were some MacBook Airs that shipped with 10.5 path = '/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist' # Set to root as the owner for good measure uid = 0 gid = 80 if os.path.exists(path): plist = NSMutableDictionary.dictionaryWithContentsOfFile_(path) else: plist = NSMutableDictionary.alloc().init() plist['KnownNetworks'] = {} guid = networkDict['guid'] plist['KnownNetworks'][guid] = {} plist['KnownNetworks'][guid]['SSID_STR'] = networkDict['ssid'] plist['KnownNetworks'][guid]['Remembered channels'] = [networkDict['chan'],] plist['KnownNetworks'][guid]['SecurityType'] = networkDict['sect'] # If we are adding a non WPA2 Enterprise network add the keychain item if networkDict['type'] == 'WPA2': plist['KnownNetworks'][guid]['Unique Password ID'] = networkDict['keyc'] plist['KnownNetworks'][guid]['_timeStamp'] = NSDate.date() exportFile = path plist.writeToFile_atomically_(exportFile,True) try: os.chown(path,uid,gid) except: print 'Path not found %s' % path
def create_main_surface(): pygame.init() surface = pygame.display.set_mode((320, 240)) try: SDL_QuartzWindow = objc.lookUpClass('SDL_QuartzWindow') except objc.nosuchclass_error: # SDL2 doesn't have this class or need the runtime patch pass else: class SDL_QuartzWindow(objc.Category(SDL_QuartzWindow)): def canBecomeKeyWindow(self): return True def canBecomeMainWindow(self): return True def acceptsFirstResponder(self): return True def becomeFirstResponder(self): return True def resignFirstResponder(self): return True global window_controller window_controller = WindowController() # run the run loop just once to finish setting up the window NSRunLoop.mainRunLoop().runMode_beforeDate_(NSDefaultRunLoopMode, NSDate.date()) return surface
def events(self): store = CalCalendarStore.defaultCalendarStore() # Pull all events starting now from all calendars in the CalendarStore allEventsPredicate = ( CalCalendarStore.eventPredicateWithStartDate_endDate_calendars_( NSDate.date(), NSDate.distantFuture(), store.calendars())) return store.eventsWithPredicate_(allEventsPredicate)
def showTaskCreationDialog_(self, sender): # Set default values for the title, start date and priority # Cocoa bindings will clear out the related fields in the sheet self._.calItemTitle = None self._.calItemStartDate = NSDate.date() NSApp.beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo_( self.taskCreationDialog, self.mainWindow, self, 'didEndSheet:returnCode:contextInfo:', None)
def showEventCreationDialog_(self, sender): # Set default values for the title and start/end date # Cocoa bindings will clear out the related fields in the sheet self._.calItemTitle = None self._.calItemStartDate = NSDate.date() self._.calItemEndDate = NSDate.dateWithTimeIntervalSinceNow_(3600) NSApp.beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo_( self.eventCreationDialog, self.mainWindow, self, 'didEndSheet:returnCode:contextInfo:', None)
def send_notification(title, subtitle, info_text, delay=0, sound=False, userInfo={}): notification = NSUserNotification.alloc().init() notification.setTitle_(title) notification.setSubtitle_(subtitle) notification.setInformativeText_(info_text) notification.setUserInfo_(userInfo) if sound: notification.setSoundName_("NSUserNotificationDefaultSoundName") notification.setDeliveryDate_(NSDate.dateWithTimeInterval_sinceDate_(delay, NSDate.date())) NSUserNotificationCenter.defaultUserNotificationCenter().scheduleNotification_(notification)
## # Copyright (c) 2010-2015 Apple Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ## from __future__ import print_function import eventkitframework as EventKit from Cocoa import NSDate store = EventKit.EKEventStore.alloc().init() calendars = store.calendarsForEntityType_(0) print(calendars) raise SystemExit predicate = store.predicateForEventsWithStartDate_endDate_calendars_( NSDate.date(), NSDate.distantFuture(), [calendars[2]]) print(store.eventsMatchingPredicate_(predicate))
## # Copyright (c) 2010-2017 Apple Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ## from __future__ import print_function import eventkitframework as EventKit from Cocoa import NSDate store = EventKit.EKEventStore.alloc().init() calendars = store.calendarsForEntityType_(0) print(calendars) raise SystemExit predicate = store.predicateForEventsWithStartDate_endDate_calendars_( NSDate.date(), NSDate.distantFuture(), [calendars[2]]) print(store.eventsMatchingPredicate_(predicate))