FlatMenu
is a generic menu implementation.
FlatMenu
, like the name implies, it is a generic menu implementation.
I tried to provide a full functionality for menus, menubar and toolbar.
FlatMenu
supports the following features:
FlatMenu
;StatusBar
(if present);FileHistory
implementation;FlatMenu
;ToolBar
methods AddCheckTool/AddRadioTool (thanks to Vladiuz).Usage example:
import wx
import wx.lib.agw.flatmenu as FM
class MyFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, -1, "FlatMenu Demo")
self.CreateMenu()
panel = wx.Panel(self, -1)
btn = wx.Button(panel, -1, "Hello", (15, 12), (100, 120))
main_sizer = wx.BoxSizer(wx.VERTICAL)
main_sizer.Add(self.menubar, 0, wx.EXPAND)
main_sizer.Add(panel, 1, wx.EXPAND)
self.SetSizer(main_sizer)
main_sizer.Layout()
def CreateMenu(self):
self.menubar = FM.FlatMenuBar(self, -1)
f_menu = FM.FlatMenu()
e_menu = FM.FlatMenu()
v_menu = FM.FlatMenu()
t_menu = FM.FlatMenu()
w_menu = FM.FlatMenu()
# Append the menu items to the menus
f_menu.Append(-1, "Simple Ctrl+N", "Text", None)
e_menu.Append(-1, "FlatMenu", "Text", None)
v_menu.Append(-1, "Example", "Text", None)
t_menu.Append(-1, "Hello", "Text", None)
w_menu.Append(-1, "World", "Text", None)
# Append menus to the menubar
self.menubar.Append(f_menu, "&File")
self.menubar.Append(e_menu, "&Edit")
self.menubar.Append(v_menu, "&View")
self.menubar.Append(t_menu, "&Options")
self.menubar.Append(w_menu, "&Help")
# our normal wxApp-derived class, as usual
app = wx.App(0)
frame = MyFrame(None)
app.SetTopWindow(frame)
frame.Show()
app.MainLoop()
FlatMenu
has been tested on the following platforms:This class supports the following window styles:
Window Styles | Hex Value | Description |
---|---|---|
FM_OPT_IS_LCD |
0x1 | Use this style if your computer uses a LCD screen. |
FM_OPT_MINIBAR |
0x2 | Use this if you plan to use the toolbar only. |
FM_OPT_SHOW_CUSTOMIZE |
0x4 | Show “customize link” in the More menu, you will need to write your own handler. See demo. |
FM_OPT_SHOW_TOOLBAR |
0x8 | Set this option is you are planning to use the toolbar. |
This class processes the following events:
Event Name | Description |
---|---|
EVT_FLAT_MENU_DISMISSED |
Used internally. |
EVT_FLAT_MENU_ITEM_MOUSE_OUT |
Fires an event when the mouse leaves a FlatMenuItem . |
EVT_FLAT_MENU_ITEM_MOUSE_OVER |
Fires an event when the mouse enters a FlatMenuItem . |
EVT_FLAT_MENU_SELECTED |
Fires the EVT_MENU event for FlatMenu . |
FlatMenu
is distributed under the wxPython license.
Latest Revision: Andrea Gavana @ 27 Dec 2012, 21.00 GMT
Version 1.0
ConvertToMonochrome |
Converts a bitmap to monochrome colour. |
GetAccelIndex |
Returns the mnemonic index of the label and the label stripped of the ampersand mnemonic |
GetMRUEntryLabel |
Returns the string used for the MRU list items in the menu. |
FileHistory |
The FileHistory encapsulates a user interface convenience, the list of most |
FlatMenu |
A Flat popup menu generic implementation. |
FlatMenuBar |
Implements the generic owner-drawn menu bar for FlatMenu . |
FlatMenuBase |
Base class for generic flat menu derived from PopupWindow . |
FlatMenuButton |
A nice small class that functions like wx.BitmapButton , the reason I did |
FlatMenuEvent |
Event class that supports the FlatMenu -compatible event called |
FlatMenuItem |
A class that represents an item in a menu. |
FlatMenuItemGroup |
A class that manages a group of radio menu items. |
FlatToolbarItem |
This class represents a toolbar item. |
FMRenderer |
Base class for the FlatMenu renderers. This class implements the common |
FMRendererMgr |
This class represents a manager that handles all the renderers defined. |
FMRendererMSOffice2007 |
Windows Office 2007 style. |
FMRendererVista |
Windows Vista-like style. |
FMRendererXP |
Xp-Style renderer. |
FocusHandler |
A focus event handler. |
mcPopupWindow |
Since Max OS does not support PopupWindow , this is an alternative. |
MenuEntryInfo |
Internal class which holds information about a menu. |
MenuKbdRedirector |
A keyboard event handler. |
ShadowPopupWindow |
Base class for generic FlatMenu derived from PopupWindow . |
StatusBarTimer |
Timer used for deleting StatusBar long help after _DELAY seconds. |
ToolBarItem |
A simple class that holds information about a toolbar item. |
ConvertToMonochrome
(bmp)¶Converts a bitmap to monochrome colour.
Parameters: | bmp – a valid wx.Bitmap object. |
---|
GetAccelIndex
(label)¶Returns the mnemonic index of the label and the label stripped of the ampersand mnemonic (e.g. ‘lab&el’ ==> will result in 3 and labelOnly = label).
Parameters: | label (string) – a string possibly containining an ampersand. |
---|
GetMRUEntryLabel
(n, path)¶Returns the string used for the MRU list items in the menu.
Parameters: |
|
---|
Note
The index n is 0-based, as usual, but the strings start from 1.