本文整理汇总了Python中Foundation.NSTimer.alloc方法的典型用法代码示例。如果您正苦于以下问题:Python NSTimer.alloc方法的具体用法?Python NSTimer.alloc怎么用?Python NSTimer.alloc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Foundation.NSTimer
的用法示例。
在下文中一共展示了NSTimer.alloc方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: applicationDidFinishLaunching_
# 需要导入模块: from Foundation import NSTimer [as 别名]
# 或者: from Foundation.NSTimer import alloc [as 别名]
def applicationDidFinishLaunching_(self, notification):
self.noDevice = None
#Create menu
self.menu = NSMenu.alloc().init()
self.barItem = dict()
# Load images
self.noDeviceImage = NSImage.alloc().initByReferencingFile_('icons/no_device.png')
self.barImage = dict(kb = NSImage.alloc().initByReferencingFile_('icons/kb.png'),
magicMouse = NSImage.alloc().initByReferencingFile_('icons/magic_mouse.png'),
mightyMouse = NSImage.alloc().initByReferencingFile_('icons/mighty_mouse.png'),
magicTrackpad = NSImage.alloc().initByReferencingFile_('icons/TrackpadIcon.png'))
#Define menu items
self.statusbar = NSStatusBar.systemStatusBar()
self.menuAbout = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('About BtBatStat', 'about:', '')
self.separator_menu_item = NSMenuItem.separatorItem()
self.menuQuit = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Quit', 'terminate:', '')
# Get the timer going
self.timer = NSTimer.alloc().initWithFireDate_interval_target_selector_userInfo_repeats_(start_time, 10.0, self, 'tick:', None, True)
NSRunLoop.currentRunLoop().addTimer_forMode_(self.timer, NSDefaultRunLoopMode)
self.timer.fire()
#Add menu items
self.menu.addItem_(self.menuAbout)
self.menu.addItem_(self.separator_menu_item)
self.menu.addItem_(self.menuQuit)
#Check for updates
checkForUpdates()
示例2: start
# 需要导入模块: from Foundation import NSTimer [as 别名]
# 或者: from Foundation.NSTimer import alloc [as 别名]
def start(self):
if not self._status:
self._nsdate = NSDate.date()
self._nstimer = NSTimer.alloc().initWithFireDate_interval_target_selector_userInfo_repeats_(
self._nsdate, self._interval, self, 'callback:', None, True)
NSRunLoop.currentRunLoop().addTimer_forMode_(self._nstimer, NSDefaultRunLoopMode)
_TIMERS.add(self)
self._status = True
示例3: applicationDidFinishLaunching_
# 需要导入模块: from Foundation import NSTimer [as 别名]
# 或者: from Foundation.NSTimer import alloc [as 别名]
def applicationDidFinishLaunching_(self, notification):
global start_time
statusbar = NSStatusBar.systemStatusBar()
# Create the statusbar item
self.statusitem = statusbar.statusItemWithLength_(70.0)
# Set initial image
self.statusitem.setTitle_(self.updateGeektime())
# Let it highlight upon clicking
self.statusitem.setHighlightMode_(1)
self.menu = NSMenu.alloc().init()
menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Quit', 'terminate:', '')
self.menu.addItem_(menuitem)
self.statusitem.setMenu_(self.menu)
self.timer = NSTimer.alloc().initWithFireDate_interval_target_selector_userInfo_repeats_(start_time, 0.65, self, 'tick:', None, True)
NSRunLoop.currentRunLoop().addTimer_forMode_(self.timer, NSDefaultRunLoopMode)
self.timer.fire()
示例4: __init__
# 需要导入模块: from Foundation import NSTimer [as 别名]
# 或者: from Foundation.NSTimer import alloc [as 别名]
def __init__(self, callback, interval):
self.set_callback(callback)
self._nsdate = NSDate.date()
self._nstimer = NSTimer.alloc().initWithFireDate_interval_target_selector_userInfo_repeats_(
self._nsdate, interval, self, 'callback:', None, True)
NSRunLoop.currentRunLoop().addTimer_forMode_(self._nstimer, NSDefaultRunLoopMode)