events.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. """!
  2. @package core.events
  3. @brief General events
  4. Put here only truly general events. Once you find that your event can be
  5. generated in more than one class, put your event here. Otherwise,
  6. leave it in your class file. Events are expected to be grass/gis related.
  7. General notice:
  8. Command events are propagated to parent windows. However, they do not propagate
  9. beyond dialogs. Events do not propagate at all.
  10. Command events works only with windows, not EvtHandlers, so for other objects
  11. than windows you need to have extra parameter - guiparent - which can be used
  12. for creating command events.
  13. \code
  14. mapEvent = gMapCreated(self._guiparent.GetId(), ...)
  15. wx.PostEvent(self._guiparent, mapEvent)
  16. \endcode
  17. @todo naming conventions for events
  18. (C) 2012 by the GRASS Development Team
  19. This program is free software under the GNU General Public License
  20. (>=v2). Read the file COPYING that comes with GRASS for details.
  21. @author Vaclav Petras <wenzeslaus gmail.com>
  22. """
  23. from wx.lib.newevent import NewCommandEvent
  24. from wx.lib.newevent import NewEvent
  25. # Notification event intended to update statusbar.
  26. # The message attribute contains the text of the message (plain text)
  27. gShowNotification, EVT_SHOW_NOTIFICATION = NewCommandEvent()
  28. # Occurs event when some map is created or updated by a module.
  29. # attributes: name: map name, ltype: map type,
  30. # add: if map should be added to layer tree (questionable attribute)
  31. gMapCreated, EVT_MAP_CREATED = NewCommandEvent()
  32. gZoomChanged, EVT_ZOOM_CHANGED = NewEvent()
  33. # Post it to BufferedWindow instance, which you want to update.
  34. # For relevant attributes for the event see
  35. # mapdisp.mapwindow.BufferedWindow UpdateMap method arguments.
  36. # If event does not contain attribute corresponding to argument with default
  37. # value, the default value will be used.
  38. # Arguments with no default value must be among event attributes
  39. # in order to be the event processed.
  40. # TODO implement to NVIZ GLWindow
  41. # TODO change direct calling of UpdateMap method to posting this event
  42. gUpdateMap, EVT_UPDATE_MAP = NewEvent()