def main(): ##Kick off an app with the event handlers to deal with the GURL Apple events app = NSApplication.sharedApplication() delegate = AppDelegate.alloc().init() delegate.dirty_init() app.setDelegate_(delegate) AppHelper.runEventLoop()
def init(): print "init ui cocoa" global browserwindow app = NSApplication.sharedApplication() app.setActivationPolicy_(1) start_taskbar() app.finishLaunching() _browserwindow = NSWindow.alloc() icon = NSImage.alloc().initByReferencingFile_(settings.mainicon) app.setApplicationIconImage_(icon) deleg = Delegate.alloc() deleg.init() app.setDelegate_(deleg) signal.signal(signal.SIGINT, mac_sigint) from .input import BrowserDelegate bd = BrowserDelegate.alloc() bd.init() browserwindow = draw_browser(_browserwindow, bd) from .... import ui ui.log.debug('using cocoa') atexit.register(exit) gevent_timer(deleg) ui.module_initialized.set() sys.exit = exit AppHelper.runEventLoop()
def main(): app = NSApplication.sharedApplication() delegate = AppDelegate.alloc().init() app.setDelegate_(delegate) AppHelper.runEventLoop()
def run(self, **options): """Performs various setup tasks including creating the underlying Objective-C application, starting the timers, and registering callback functions for click events. Then starts the application run loop. .. versionchanged:: 0.2.1 Accepts `debug` keyword argument. :param debug: determines if application should log information useful for debugging. Same effect as calling :func:`rumps.debug_mode`. """ dont_change = object() debug = options.get('debug', dont_change) if debug is not dont_change: debug_mode(debug) nsapplication = NSApplication.sharedApplication() nsapplication.activateIgnoringOtherApps_(True) # NSAlerts in front self._nsapp = NSApp.alloc().init() self._nsapp._app = self.__dict__ # allow for dynamic modification based on this App instance nsapplication.setDelegate_(self._nsapp) if _NOTIFICATIONS: NSUserNotificationCenter.defaultUserNotificationCenter().setDelegate_(self._nsapp) setattr(App, '*app_instance', self) # class level ref to running instance (for passing self to App subclasses) t = b = None for t in getattr(timer, '*timers', []): t.start() for b in getattr(clicked, '*buttons', []): b(self) # we waited on registering clicks so we could pass self to access _menu attribute del t, b self._nsapp.initializeStatusBar() AppHelper.runEventLoop()
def gui_main(): IEDLog.IEDLogToController = True IEDLog.IEDLogToSyslog = True IEDLog.IEDLogToStdOut = True IEDLog.IEDLogStdOutLogLevel = IEDLog.IEDLogLevelDebug logFile = os.path.join(get_log_dir(), u"AutoDMG-%s.log" % get_date_string()) try: IEDLog.IEDLogFileHandle = open(logFile, u"a", buffering=1) IEDLog.IEDLogToFile = True except IOError as e: IEDLog.IEDLogToFile = False LogWarning(u"Couldn't open %s for writing" % (logFile)) import AppKit from PyObjCTools import AppHelper # import modules containing classes required to start application and load MainMenu.nib import IEDAppDelegate import IEDController import IEDSourceSelector import IEDAddPkgController import IEDAppVersionController # pass control to AppKit AppHelper.runEventLoop(unexpectedErrorAlert=gui_unexpected_error_alert) return os.EX_OK
def run(self): NSApplication.sharedApplication() self.delegate = AppDelegate.alloc().init() self.delegate.event_sniffer = self NSApp().setDelegate_(self.delegate) self.workspace = NSWorkspace.sharedWorkspace() nc = self.workspace.notificationCenter() # This notification needs OS X v10.6 or later nc.addObserver_selector_name_object_( self.delegate, 'applicationActivated:', 'NSWorkspaceDidActivateApplicationNotification', None) nc.addObserver_selector_name_object_( self.delegate, 'screenSleep:', 'NSWorkspaceScreensDidSleepNotification', None) # I don't think we need to track when the screen comes awake, but in case # we do we can listen for NSWorkspaceScreensDidWakeNotification NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_( self.options.active_window_time, self.delegate, 'writeActiveApp:', None, True) # Start the application. This doesn't return. AppHelper.runEventLoop()
def run(self): osxVersion, _, _ = platform.mac_ver() majorVersion = int(osxVersion.split(".")[0]) minorVersion = int(osxVersion.split(".")[1]) logging.debug("major: %s; minor: %s", majorVersion, minorVersion) app = NSApplication.sharedApplication() guiApp = GuiApplicationOSX.alloc().init() app.setDelegate_(guiApp) guiApp.setMembers(self.executable, self.iconPath) messenger = None # OSX 10.8 and greater has a built-in notification system we can take advantage of if minorVersion >= 8: messenger = MessengerOSXMountainLion.alloc().init() else: messenger = MessengerOSXLegacy.alloc().init() # Multiple inheritance not working with NSObject?? messenger.setMembers(self.notificationTimeout, MESSAGE_TITLE) self.initialize(messenger, guiApp) AppHelper.runEventLoop()
def run(self): # set up the application self.app = NSApplication.sharedApplication() self.delegate = self.createAppDelegate().alloc().init() self.delegate.activity_tracker = self.activity_tracker self.app.setDelegate_(self.delegate) self.app.setActivationPolicy_(NSApplicationActivationPolicyAccessory) self.workspace = NSWorkspace.sharedWorkspace() # start listeners for event recorders self.cr = ClickRecorder(self) self.cr.start_click_listener() self.kr = KeyRecorder(self) self.kr.start_key_listener() self.mr = MoveRecorder(self) self.mr.start_move_listener() self.sr = ScrollRecorder(self) self.sr.start_scroll_listener() self.clr = ClipboardRecorder(self) # AppRecorder starts accessibility listeners that need to be on a # separate thread self.ar = AppRecorder(self) self.art = threading.Thread(target=self.ar.start_app_observers) self.art.start() #TODO add file system tracking # https://developer.apple.com/library/mac/documentation/Darwin/Conceptual/FSEvents_ProgGuide/UsingtheFSEventsFramework/UsingtheFSEventsFramework.html # run the Traces application AppHelper.runEventLoop()
def main(self): app = NSApplication.sharedApplication() self._controller.start() delegate = AppDelegate.alloc().init() NSApp().setDelegate_(delegate) win = NSWindow.alloc() frame = ((200.0, 300.0), (250.0, 100.0)) win.initWithContentRect_styleMask_backing_defer_ (frame, 15, 2, 0) win.setTitle_ ('BinDownloader') win.setLevel_ (3) hel = NSButton.alloc().initWithFrame_ (((10.0, 10.0), (80.0, 80.0))) win.contentView().addSubview_ (hel) hel.setBezelStyle_( 4 ) hel.setTitle_( 'Hello!' ) hel.setTarget_( app.delegate() ) hel.setAction_( "sayHello:" ) win.display() win.orderFrontRegardless() AppHelper.runEventLoop()
def start(self, pipe): self.pipe = pipe self.start_time = NSDate.date() app = NSApplication.sharedApplication() delegate = self.alloc().init() app.setDelegate_(delegate) AppHelper.runEventLoop()
def run(self): NSApplication.sharedApplication() delegate = self.createAppDelegate().alloc().init() NSApp().setDelegate_(delegate) NSApp().setActivationPolicy_(NSApplicationActivationPolicyProhibited) self.workspace = NSWorkspace.sharedWorkspace() AppHelper.runEventLoop()
def run(app, time_base, clock_class, ui_class): clock_obj=clock_class(time_base) ticker=Ticker.alloc().init() ticker.dosetup(time_base, clock_obj, None) NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(time_base/1000, ticker, 'tick:', None, True) #@UndefinedVariable AppHelper.runEventLoop(installInterrupt=True)
def main(): try: app = NSApplication.sharedApplication() delegate = AppDelegate.alloc().init() NSApp().setDelegate_(delegate) AppHelper.runEventLoop() except KeyboardInterrupt: AppHelper.stopEventLoop()
def main( ): global app loopPool=NSAutoreleasePool.alloc().init(); app = NSApplication.sharedApplication( ) graphicsRect = NSMakeRect(100, 100, 640, 530) myWindow = NSWindow.alloc().initWithContentRect_styleMask_backing_defer_( graphicsRect, NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask | NSMiniaturizableWindowMask, NSBackingStoreBuffered, False).autorelease() myWindow.setTitle_('webcam') # myView = DemoView.alloc( ).initWithFrame_(graphicsRect) # myWindow.setContentView_(myView) # myDelegate = AppDelegate.alloc( ).init( ) # myWindow.setDelegate_(myDelegate) iSight = QTCaptureDevice.defaultInputDeviceWithMediaType_(QTMediaTypeVideo) iSight.open_(None) myInput = QTCaptureDeviceInput.deviceInputWithDevice_(iSight) print iSight session = QTCaptureSession.alloc().init().autorelease() print session session.addInput_error_(myInput,None) outputView = QTCaptureView.alloc().init().autorelease() outputView.setCaptureSession_(session) myDelegate = AppDelegate.alloc().init().autorelease() captureOutput = QTCaptureDecompressedVideoOutput.alloc().init().autorelease() captureOutput.setDelegate_(myDelegate) session.addOutput_error_(captureOutput, None) print session button = NSButton.alloc().initWithFrame_(NSMakeRect(300, 10, 60, 30)).autorelease() button.setBezelStyle_(NSRoundedBezelStyle) button.setTitle_('Click') button.setAction_('snap'); outputView.setFrame_(NSMakeRect(0,50,640,480)) print outputView myWindow.contentView().addSubview_(outputView) myWindow.contentView().addSubview_(button) myWindow.setDelegate_(myDelegate) session.startRunning() # myWindow.setContentView_(myview) myWindow.display( ) myWindow.orderFrontRegardless( ) print myWindow AppHelper.runEventLoop() #app.run( ) loopPool.drain() print 'Done'
def run(self): app = NSApplication.sharedApplication() osxthing = MacOSXThing.alloc().init() osxthing.indicator = self app.setDelegate_(osxthing) try: AppHelper.runEventLoop() except: traceback.print_exc()
def main(): config.read(os.path.expanduser('~/Library/Preferences/url-open-handler.cfg')) app = NSApplication.sharedApplication() delegate = AppDelegate.alloc().init() app.setDelegate_(delegate) AppHelper.runEventLoop()
def main(): print("Launching keylogger…") global __client args = parser.parse_args() __client = SimpleClient(args.host, args.port) app = NSApplication.sharedApplication() delegate = AppDelegate.alloc().init() NSApp().setDelegate_(delegate) AppHelper.runEventLoop()
def main(): # Hide the dock icon info = NSBundle.mainBundle().infoDictionary() info["LSBackgroundOnly"] = "1" app = NSApplication.sharedApplication() delegate = MenubarNotifier.alloc().init() app.setDelegate_(delegate) AppHelper.runEventLoop()
def main(): """ Setup and start Cocoa GUI main loop """ app = NSApplication.sharedApplication() delegate = darwin.ApafAppWrapper.alloc().init() delegate.setMainFunction_andReactor_(start_apaf, reactor) app.setDelegate_(delegate) AppHelper.runEventLoop()
def serve_forever(): app = AppKit.NSApplication.sharedApplication() app.setDelegate_(sys_tray) # Listen for network change nc = AppKit.CFNotificationCenterGetDarwinNotifyCenter() AppKit.CFNotificationCenterAddObserver(nc, None, networkChanged, "com.apple.system.config.network_change", None, AppKit.CFNotificationSuspensionBehaviorDeliverImmediately) fetchCurrentService('IPv4') AppHelper.runEventLoop()
def executeVanillaTest(cls, **kwargs): """ Execute a Vanilla UI class in a mini application. """ app = NSApplication.sharedApplication() delegate = _VanillaMiniAppDelegate.alloc().init() app.setDelegate_(delegate) cls(**kwargs) app.activateIgnoringOtherApps_(True) AppHelper.runEventLoop()
def main(): global __file__ __file__ = os.path.abspath(__file__) if os.path.islink(__file__): __file__ = getattr(os, 'readlink', lambda x: x)(__file__) os.chdir(os.path.dirname(os.path.abspath(__file__))) app = NSApplication.sharedApplication() delegate = GoAgentOSX.alloc().init() app.setDelegate_(delegate) AppHelper.runEventLoop()
def run(self): NSApplication.sharedApplication() delegate = self.createAppDelegate().alloc().init() NSApp().setDelegate_(delegate) NSApp().setActivationPolicy_(NSApplicationActivationPolicyProhibited) self.workspace = NSWorkspace.sharedWorkspace() def handler(signal, frame): AppHelper.stopEventLoop() signal.signal(signal.SIGINT, handler) AppHelper.runEventLoop()
def run_main_loop(): global _current_main_loop_instance global _is_main_loop_running if _unittests_running and not _active_test: _current_main_loop_instance += 1 # kill any enqueued tasks raise Exception("UITestCase must be used for tests that use the message_loop.") assert not _is_main_loop_running _is_main_loop_running = True # we will never ever ever return from here. :'( AppHelper.runEventLoop(installInterrupt=True,unexpectedErrorAlert=False)
def main(): try: from PyObjCTools import AppHelper from Cocoa import NSApplication except ImportError: raise app = NSApplication.sharedApplication(); app viewController = _initiate_the_contrller_with_an_xib() viewController.showWindow_(viewController) _bring_app_to_the_top() AppHelper.runEventLoop()
def run(app, argv, unexpected_error_callback, use_pdb): # initialize class definitions (referenced in nib?) import editxt.platform.mac.cells import editxt.platform.mac.views.linenumberview import editxt.platform.mac.views.splitview import editxt.platform.mac.views.textview register_value_transformers() AppDelegate.app = app # HACK global. Would prefer to set an instance variable if not use_pdb: AppDelegate.updater = load_sparkle() AppHelper.runEventLoop(argv, unexpected_error_callback, pdb=use_pdb)
def run(self): self.app = NSApplication.sharedApplication() self.delegate = self.createAppDelegate().alloc().init() self.app.setDelegate_(self.delegate) self.app.setActivationPolicy_(NSApplicationActivationPolicyAccessory) self.workspace = NSWorkspace.sharedWorkspace() # listen for events thrown by the Experience sampling window s = objc.selector(self.makeAppActive_,signature='v@:@') NSNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, s, 'makeAppActive', None) s = objc.selector(self.takeExperienceScreenshot_,signature='v@:@') NSNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, s, 'takeExperienceScreenshot', None) AppHelper.runEventLoop()
def start(self): # Load today's count data back from data file super(KeyCounter, self).start() NSApplication.sharedApplication() self.delegate = self._create_app_delegate().alloc().init() NSApp().setDelegate_(self.delegate) NSApp().setActivationPolicy_(NSApplicationActivationPolicyProhibited) signal.signal(signal.SIGINT, self.stop) signal.signal(signal.SIGTERM, self.stop) self._check_for_access() self.delegate.initializeStatusBar() AppHelper.runEventLoop()
def run(self): self._syncer = Syncer() self._syncer.start() app = NSApplication.sharedApplication() app.setActivationPolicy_(2) # Hide from dock app.setApplicationIconImage_(create_icon('appicon.png')) self.traymenu = TrayMenu.alloc() self.traymenu.init() app.setDelegate_(self.traymenu) self._observer = setup_observer(self) self._cron = setup_syncing_cronjobs() AppHelper.runEventLoop()
def runModal(self, title, message, help_link, text = ''): pool = NSAutoreleasePool.alloc().init() try: app = NSApplication.sharedApplication() if app.isRunning(): death_event = Event() app_delegate = BootErrorAppDelegate(title, message, help_link, text, death_event) AppHelper.callAfter(app_delegate.applicationWillFinishLaunching_, None) death_event.wait() else: AppHelper.installMachInterrupt() app_delegate = BootErrorAppDelegate(title, message, help_link, text, None) app.setDelegate_(app_delegate) AppHelper.runEventLoop() finally: del pool
def run(self): NSApplication.sharedApplication() delegate = self.createAppDelegate().alloc().init() NSApp().setDelegate_(delegate) self.workspace = NSWorkspace.sharedWorkspace() AppHelper.runEventLoop()
# # __main__.py # GraphicsBindings # # Created by Fred Flintstone on 11.02.05. # Copyright (c) 2005 __MyCompanyName__. All rights reserved. # from PyObjCTools import AppHelper from Foundation import NSProcessInfo import GraphicsBindingsDocument import Circle import GraphicsArrayController import JoystickView import GraphicsView # start the event loop import objc objc.setVerbose(1) AppHelper.runEventLoop(argv=[])
def serve_forever(): app = NSApplication.sharedApplication() delegate = MacTrayObject.alloc().init() app.setDelegate_(delegate) AppHelper.runEventLoop()
def main(): app = NSApplication.sharedApplication() delegate = AppDelegate.alloc().init() NSApp().setDelegate_(delegate) AppHelper.callLater(_BUCKET_SIZE_SECONDS, record) AppHelper.runEventLoop()
def main(): clientsocket.connect(('localhost', 8089)) app = NSApplication.sharedApplication() delegate = AppDelegate.alloc().init() NSApp().setDelegate_(delegate) AppHelper.runEventLoop()
self.p_interacting = v def isAutoScroll(self): return self.p_autoScroll def setAutoScroll_(self, v): self.p_autoScroll = v def characterIndexForInput(self): return self.p_characterIndexForInput def setCharacterIndexForInput_(self, idx): self.p_characterIndexForInput = idx self.moveAndScrollToIndex_(idx) def historyView(self): return self.p_historyView def setHistoryView_(self, v): self.p_historyView = v def singleLineInteraction(self): return self.p_singleLineInteraction def setSingleLineInteraction_(self, v): self.p_singleLineInteraction = v if __name__ == '__main__': AppHelper.runEventLoop(installInterrupt=True)
def main(): app = NSApplication.sharedApplication() delegate = AppDelegate.alloc().init() NSApp().setDelegate_(delegate) AppHelper.runEventLoop()
# # main.py # EyeTracker # # Created by David Cox on 11/13/08. # Copyright Harvard University 2008. All rights reserved. # #import modules required by application import objc import Foundation import AppKit from PyObjCTools import AppHelper # import modules containing classes required to start application and load MainMenu.nib import EyeTrackerController from EyeTrackerController import * import TrackerCameraView # pass control to AppKit AppHelper.runEventLoop()
""" Display the useful contents of /var/db/dhcpd_leases This lets you see what IP addresses are leased out when using Internet Connection Sharing """ from PyObjCTools import AppHelper # import classes required to start application import TableModelAppDelegate # start the event loop AppHelper.runEventLoop(argv=[], installInterrupt=False)