Package gui :: Module icons
[hide private]
[frames] | no frames]

Source Code for Module gui.icons

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2011 Edward d'Auvergne                                        # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program is free software: you can redistribute it and/or modify        # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation, either version 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program is distributed in the hope that it will be useful,             # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # Module docstring. 
 23  """All of the icons for relax.""" 
 24   
 25  # Python module imports. 
 26  from os import sep 
 27  import sys 
 28  import wx 
 29   
 30  # relax module imports. 
 31  from status import Status; status = Status() 
 32   
 33   
34 -class Relax_icons(wx.IconBundle):
35 """The icon bundle class of the main relax icons.""" 36
37 - def setup(self):
38 """Set up the icons after the main app is created.""" 39 40 # This is disabled on Macs. 41 if not 'darwin' in sys.platform: 42 self.AddIconFromFile(status.install_path + sep + 'graphics' + sep + 'ulysses.ico', wx.BITMAP_TYPE_ANY)
43 44
45 -class Relax_task_bar_icon(wx.TaskBarIcon):
46 """The icon for the Mac OS X task bar.""" 47 48 # Set up some ID numbers for the menu entries. 49 TBMENU_RESTORE = wx.NewId() 50 TBMENU_CLOSE = wx.NewId() 51
52 - def __init__(self, gui):
53 """Set up the task bar icon. 54 55 @param gui: The GUI object. 56 @type gui: wx.Frame instance 57 """ 58 59 # Store the args. 60 self.gui = gui 61 62 # Initilise the base class. 63 wx.TaskBarIcon.__init__(self) 64 65 # Set the task bar icon. 66 self.SetIcon(wx.Icon(status.install_path + sep + 'graphics' + sep + 'ulysses_shadowless_trans_128x128.png', wx.BITMAP_TYPE_ANY)) 67 68 # Bind mouse events. 69 self.Bind(wx.EVT_TASKBAR_LEFT_DCLICK, self.restore)
70 71
72 - def CreatePopupMenu(self):
73 """Create and return the task bar menu. 74 75 @return: The pop up menu. 76 @rtype: wx.Menu instance 77 """ 78 79 # Initialise the menu. 80 popup = wx.Menu() 81 82 # Add some menu entries. 83 popup.Append(self.TBMENU_RESTORE, "Restore relax") 84 popup.Append(self.TBMENU_CLOSE, "Exit relax") 85 86 # Bind the menu events. 87 self.Bind(wx.EVT_MENU, self.restore, id=self.TBMENU_RESTORE) 88 self.Bind(wx.EVT_MENU, self.exit, id=self.TBMENU_CLOSE) 89 90 # Return the menu. 91 return popup
92 93
94 - def exit(self, event):
95 """Exit relax from the task bar. 96 97 @param event: The wx event. 98 @type event: wx event 99 """ 100 101 # Exit relax. 102 wx.CallAfter(self.gui.exit_gui)
103 104
105 - def restore(self, event):
106 """Restore relax from the task bar. 107 108 @param event: The wx event. 109 @type event: wx event 110 """ 111 112 # Show relax. 113 if status.show_gui and not self.gui.IsShown(): 114 self.gui.Show(True) 115 116 # De-iconise relax. 117 if self.gui.IsIconized(): 118 self.gui.Iconize(False) 119 120 # Raise relax to the top of the window hierarchy. 121 self.gui.Raise()
122 123 124 # Set up the main set of icons for relax. 125 relax_icons = Relax_icons() 126