def _create_timer(self): timer = NSTimer.alloc() \ .initWithFireDate_interval_target_selector_userInfo_repeats_( start_time, 1, self, 'tick:', None, True) NSRunLoop.currentRunLoop().addTimer_forMode_(timer, NSDefaultRunLoopMode) timer.fire()
def applicationDidFinishLaunching_(self, _n): self.statusbar = NSStatusBar.systemStatusBar() self.statusitem = self.statusbar.statusItemWithLength_(NSVariableStatusItemLength) self.image = NSImage.alloc().initByReferencingFile_("mydock.icns") for i in self.toggles: self.toggle_images[i] = NSImage.alloc().initByReferencingFile_(i+".png") #self.statusitem.setTitle_(u"Set up %s" % NAME) self.statusitem.setImage_(self.image) self.statusitem.setHighlightMode_(1) self.statusitem.setToolTip_("Docker tray tool") self.menu = NSMenu.alloc().init() # menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Kill', 'killornot:', '') # menuitem.setState_(NSOnState if not self.kill else NSOffState) # self.menu.addItem_(menuitem) # menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Docker instances', 'instances:', '') # self.menu.addItem_(menuitem) menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Quit', 'terminate:', '') self.menu.addItem_(menuitem) self.statusitem.setMenu_(self.menu) # Get config if there is any self.restore_config() #print("interval: %s" % self.interval) self.timer = NSTimer.alloc().initWithFireDate_interval_target_selector_userInfo_repeats_(start_time, self.interval, self, 'loop:', None, True) getattr(self, self.loop_func)("Bs?")
def gevent_timer(deleg): timer = NSTimer.alloc( ).initWithFireDate_interval_target_selector_userInfo_repeats_( NSDate.date(), 0.1, deleg, 'gevent:', None, True) NSRunLoop.currentRunLoop().addTimer_forMode_(timer, NSDefaultRunLoopMode) timer.fire() print "started gevent timer"
def _create_timer(self): timer = NSTimer.alloc() \ .initWithFireDate_interval_target_selector_userInfo_repeats_( start_time, 1, self, 'tick:', None, True) NSRunLoop.currentRunLoop().addTimer_forMode_( timer, NSDefaultRunLoopMode) timer.fire()
def openSocketIO(cookies): print 'opening SocketIO' global sio sio = SocketIO('localhost', 8778, Namespace=Namespace, cookies=cookies) # horrible hack to get around a pesky 3 second stutter # as websocket.py times out on receiving some combination of bytes # this doesn't hurt us now, but it might in the future if it is causing # messages to be dropped sio._transport._connection.settimeout(0.00001) sioeventstimer = SocketIOEventTimer.alloc().init() start_time = NSDate.date() interval = 0.05 timer = NSTimer.alloc().initWithFireDate_interval_target_selector_userInfo_repeats_( start_time, interval, sioeventstimer, 'tick:', None, True) NSRunLoop.currentRunLoop().addTimer_forMode_(timer, NSDefaultRunLoopMode) timer.fire()
def change_icon(self, name): if name == 'syncing': if self._last_icon is not None and \ self._last_icon.startswith('syncing'): return self.change_icon('syncing1') self._syncing_icon_timer = NSTimer.alloc() \ .initWithFireDate_interval_target_selector_userInfo_repeats_( start_time, 1.0, self, 'animateSyncingIcon:', None, True) NSRunLoop.currentRunLoop().addTimer_forMode_( self._syncing_icon_timer, NSDefaultRunLoopMode) self._syncing_icon_timer.fire() return self._last_icon = name self.trayicon.setImage_(ICONS[name])
def gevent_timer(deleg): timer = NSTimer.alloc().initWithFireDate_interval_target_selector_userInfo_repeats_( NSDate.date(), 0.1, deleg, 'gevent:', None, True) NSRunLoop.currentRunLoop().addTimer_forMode_(timer, NSDefaultRunLoopMode) timer.fire() print "started gevent timer"