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.                                     # 
 7  #                                                                             # 
 8  # relax 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 2 of the License, or           # 
11  # (at your option) any later version.                                         # 
12  #                                                                             # 
13  # relax 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 relax; if not, write to the Free Software                        # 
20  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
21  #                                                                             # 
22  ############################################################################### 
23   
24  # Module docstring. 
25  """Module for the main relax menu bar.""" 
26   
27  # Python module imports. 
28  import wx 
29   
30   
31 -def build_menu_item(menu, parent=None, id=None, text='', tooltip='', icon=None, fn=None):
32 """Construct and return the menu sub-item. 33 34 @param menu: The menu object to place this entry in. 35 @type menu: wx.Menu instance 36 @keyword id: The element identification number. 37 @type id: int 38 @keyword text: The text for the menu entry. 39 @type text: None or str 40 @keyword tooltip: A tool tip. 41 @type tooltip: str 42 @keyword icon: The bitmap icon path. 43 @type icon: None or str 44 @keyword fn: The function to bind to the menu entry. 45 @type fn: class method 46 @return: The initialised wx.MenuItem() instance. 47 @rtype: wx.MenuItem() instance 48 """ 49 50 # A new ID if necessary. 51 if id == None: 52 id = wx.NewId() 53 54 # Initialise the GUI element. 55 element = wx.MenuItem(menu, id, text, tooltip) 56 57 # Set the icon. 58 if icon: 59 element.SetBitmap(wx.Bitmap(icon)) 60 61 # Bind the menu entry. 62 if fn and parent: 63 parent.Bind(wx.EVT_MENU, fn, id=id) 64 65 # Return the element. 66 return element
67