1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 """Module for the main relax menu bar."""
25
26
27 import wx
28
29
30 import dep_check
31
32
34 """Construct and return the menu sub-item.
35
36 @param menu: The menu object to place this entry in.
37 @type menu: wx.Menu instance
38 @keyword id: The element identification number.
39 @type id: int
40 @keyword text: The text for the menu entry.
41 @type text: None or str
42 @keyword tooltip: A tool tip.
43 @type tooltip: str
44 @keyword icon: The bitmap icon path.
45 @type icon: None or str
46 @keyword fn: The function to bind to the menu entry.
47 @type fn: class method
48 @keyword append: A flag which if true will cause the element to be appended to the given menu.
49 @type append: bool
50 @return: The initialised wx.MenuItem() instance.
51 @rtype: wx.MenuItem() instance
52 """
53
54
55 element = wx.MenuItem(menu, id, text, tooltip)
56
57
58 if icon:
59 element.SetBitmap(wx.Bitmap(icon))
60
61
62 if fn and parent:
63 parent.Bind(wx.EVT_MENU, fn, id=id)
64
65
66 if append:
67 if dep_check.wx_classic:
68 menu.AppendItem(element)
69 else:
70 menu.Append(element)
71
72
73 return element
74