Gnumed.wxpython.gmTimer API documentation
Description: GNUmed wx.Timer proxy object …

# Module `Gnumed.wxpython.gmTimer`

GNUmed wx.Timer proxy object.

@copyright: author(s)

## Functions

`def shutdown()`
  Expand source code

      def shutdown():
              global _timers
              _log.info('shutting down %s pending timers', len(_timers))
              for timer in _timers:
                      _log.debug('timer [%s]', timer.cookie)
                      timer.Stop()
              _timers = []

## Classes

`class cTimer (callback=None, delay=300, cookie=None)`
  Expand source code

      class cTimer(wx.Timer):
              """wx.Timer proxy.

              It would be quite useful to tune the delay
              according to current network speed either at
              application startup or even during runtime.
              """
              def __init__(self, callback = None, delay = 300, cookie = None):
                      """Set up our timer with reasonable defaults.

                      - delay default is 300ms as per Richard Terry's experience
                      - delay should be tailored to network speed/user speed
                      - <cookie> is passed to <callback> when <delay> is up
                      """
                      # sanity check
                      if not callable(callback):
                              raise ValueError("[%s]: <callback> %s is not a callable()" % (self.__class__.__name__, callback))

                      if cookie is None:
                              self.cookie = id(self)
                      else:
                              self.cookie = cookie
                      self.__callback = callback
                      self.__delay = delay

                      wx.Timer.__init__(self)

                      _log.debug('setting up timer: cookie [%s], delay %sms', self.cookie, self.__delay)

                      global _timers
                      _timers.append(self)
              #-----------------------------------------------------------------------
              def Start(self, milliseconds=-1, oneShot=False):
                      if milliseconds == -1:
                              milliseconds = self.__delay
                      wx.Timer.Start(self, milliseconds=milliseconds, oneShot=oneShot)

              #-----------------------------------------------------------------------
              def Notify(self):
                      self.__callback(self.cookie)

              #-----------------------------------------------------------------------
              def set_cookie(self, cookie=None):
                      if cookie is None:
                              self.cookie = id(self)
                      else:
                              self.cookie = cookie

  wx.Timer proxy.

  It would be quite useful to tune the delay according to current network speed either at application startup or even during runtime.

  Set up our timer with reasonable defaults.

  - delay default is 300ms as per Richard Terry's experience
  - delay should be tailored to network speed/user speed
  - is passed to when is up

  ### Ancestors

  - wx._core.Timer
  - wx._core.EvtHandler
  - wx._core.Object
  - wx._core.Trackable
  - sip.wrapper
  - sip.simplewrapper

  ### Methods

  `def Notify(self)`
    Expand source code

        def Notify(self):
                self.__callback(self.cookie)

    Notify()

    This member should be overridden by the user if the default constructor was used and SetOwner() wasn't called.

  `def Start(self, milliseconds=-1, oneShot=False)`
    Expand source code

        def Start(self, milliseconds=-1, oneShot=False):
                if milliseconds == -1:
                        milliseconds = self.__delay
                wx.Timer.Start(self, milliseconds=milliseconds, oneShot=oneShot)

    Start(milliseconds=-1, oneShot=TIMER_CONTINUOUS) -> bool

    (Re)starts the timer.

  `def set_cookie(self, cookie=None)`
    Expand source code

        def set_cookie(self, cookie=None):
                if cookie is None:
                        self.cookie = id(self)
                else:
                        self.cookie = cookie