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:
Fires all the events (UI & Cmd);
Check items;
Separators;
Enabled / Disabled menu items;
Images on items;
Toolbar support, with images and separators;
Controls in toolbar (work in progress);
Toolbar tools tooltips (done: thanks to Peter Kort);
Accelerators for menus;
Accelerators for menubar;
Radio items in menus;
Integration with AUI;
Scrolling when menu is too big to fit the screen;
Menu navigation with keyboard;
Drop down arrow button to the right of the menu, it always contains the “Customize” option, which will popup an options dialog. The dialog has the following abilities:
Ability to add/remove menus;
Select different colour schemes for the menu bar / toolbar;
Control various options, such as: colour for highlight menu item, draw border around menus (classic look only);
Toolbar floating appearance.
Allows user to specify grey bitmap for disabled menus/toolbar tools;
If no grey bitmap is provided, it generates one from the existing bitmap;
Hidden toolbar items / menu bar items - will appear in a small popmenu to the right if they are hidden;
4 different colour schemes for the menu bar (more can easily added);
Scrolling is available if the menu height is greater than the screen height;
Context menus for menu items;
Show/hide the drop down arrow which allows the customization of FlatMenu
;
Multiple columns menu window;
Tooltips for menus and toolbar items on a StatusBar
(if present);
Transparency (alpha channel) for menu windows (for platforms supporting it);
FileHistory support through a pure-Python FileHistory
implementation;
Possibility to set a background bitmap for a FlatMenu
;
First attempt in adding controls to FlatToolbar;
Added a MiniBar (thanks to Vladiuz);
Added 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:Windows (Windows XP, Vista);
Linux Ubuntu (Dapper 6.06)
This class supports the following window styles:
Window Styles |
Hex Value |
Description |
---|---|---|
|
0x1 |
Use this style if your computer uses a LCD screen. |
|
0x2 |
Use this if you plan to use the toolbar only. |
|
0x4 |
Show “customize link” in the More menu, you will need to write your own handler. See demo. |
|
0x8 |
Set this option is you are planning to use the toolbar. |
This class processes the following events:
Event Name |
Description |
---|---|
|
Used internally. |
|
Fires an event when the mouse leaves a |
|
Fires an event when the mouse enters a |
|
Fires the |
FlatMenu
is distributed under the wxPython license.
Latest Revision: Andrea Gavana @ 27 Dec 2012, 21.00 GMT
Version 1.0
Converts a bitmap to monochrome colour. |
|
Returns the mnemonic index of the label and the label stripped of the ampersand mnemonic |
|
Returns the string used for the MRU list items in the menu. |
The |
|
A Flat popup menu generic implementation. |
|
Implements the generic owner-drawn menu bar for |
|
Base class for generic flat menu derived from |
|
A nice small class that functions like |
|
Event class that supports the |
|
A class that represents an item in a menu. |
|
A class that manages a group of radio menu items. |
|
This class represents a toolbar item. |
|
Base class for the |
|
This class represents a manager that handles all the renderers defined. |
|
Windows Office 2007 style. |
|
Windows Vista-like style. |
|
Xp-Style renderer. |
|
A focus event handler. |
|
Since Max OS does not support |
|
Internal class which holds information about a menu. |
|
A keyboard event handler. |
|
Base class for generic |
|
Timer used for deleting |
|
A simple class that holds information about a toolbar item. |
ConvertToMonochrome
(bmp)¶Converts a bitmap to monochrome colour.
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).
label (string) – a string possibly containing an ampersand.
GetMRUEntryLabel
(n, path)¶Returns the string used for the MRU list items in the menu.
n (integer) – the index of the file name in the MRU list;
path (string) – the full path of the file name.
Note
The index n is 0-based, as usual, but the strings start from 1.