Package gui :: Package components :: Module menu
[hide private]
[frames] | no frames]

Source Code for Module gui.components.menu

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2009 Michael Bieri                                            # 
 4  # Copyright (C) 2010-2011 Edward d'Auvergne                                   # 
 5  #                                                                             # 
 6  # This file is part of the program relax (http://www.nmr-relax.com).          # 
 7  #                                                                             # 
 8  # This program is free software: you can redistribute it and/or modify        # 
 9  # it under the terms of the GNU General Public License as published by        # 
10  # the Free Software Foundation, either version 3 of the License, or           # 
11  # (at your option) any later version.                                         # 
12  #                                                                             # 
13  # This program is distributed in the hope that it will be useful,             # 
14  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
16  # GNU General Public License for more details.                                # 
17  #                                                                             # 
18  # You should have received a copy of the GNU General Public License           # 
19  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
20  #                                                                             # 
21  ############################################################################### 
22   
23  # Module docstring. 
24  """Module for the main relax menu bar.""" 
25   
26  # Python module imports. 
27  import wx 
28   
29   
30 -def build_menu_item(menu, parent=None, id=None, text='', tooltip='', icon=None, fn=None):
31 """Construct and return the menu sub-item. 32 33 @param menu: The menu object to place this entry in. 34 @type menu: wx.Menu instance 35 @keyword id: The element identification number. 36 @type id: int 37 @keyword text: The text for the menu entry. 38 @type text: None or str 39 @keyword tooltip: A tool tip. 40 @type tooltip: str 41 @keyword icon: The bitmap icon path. 42 @type icon: None or str 43 @keyword fn: The function to bind to the menu entry. 44 @type fn: class method 45 @return: The initialised wx.MenuItem() instance. 46 @rtype: wx.MenuItem() instance 47 """ 48 49 # A new ID if necessary. 50 if id == None: 51 id = wx.NewId() 52 53 # Initialise the GUI element. 54 element = wx.MenuItem(menu, id, text, tooltip) 55 56 # Set the icon. 57 if icon: 58 element.SetBitmap(wx.Bitmap(icon)) 59 60 # Bind the menu entry. 61 if fn and parent: 62 parent.Bind(wx.EVT_MENU, fn, id=id) 63 64 # Return the element. 65 return element
66