当前位置: 首页>>代码示例>>Python>>正文


Python NSTimer.alloc方法代码示例

本文整理汇总了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()
开发者ID:Ku2f,项目名称:btbatstat,代码行数:35,代码来源:BtBatStat.py

示例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
开发者ID:philippeowagner,项目名称:rumps,代码行数:10,代码来源:rumps.py

示例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()
开发者ID:jezdez-archive,项目名称:GeekTime.app,代码行数:20,代码来源:GeekTime.py

示例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)
开发者ID:mjhea0,项目名称:rumps,代码行数:8,代码来源:rumps.py


注:本文中的Foundation.NSTimer.alloc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。