Toolbars, Menubars & Statusbars


Toolbars and Menubars are features common to most GUIs, you'll be used to seeing them along the top of apps, such as MS Word.
Statusbars are also useful features, they allow you to show information about what's going on in a GUI, usually along the bottom of the app.

Toolbar


Toolbars (sometimes known as ribbons) appear across the top of a GUI.
They offer a series of buttons to click, which can be used to change settings/functionality in a GUI.

NB. Icons don't work in python 2.7, due to an issue showing PNG images.

Toolbar

tools = ["ABOUT", "REFRESH", "OPEN", "CLOSE", "SAVE",
        "NEW", "SETTINGS", "PRINT", "SEARCH", "UNDO",
        "REDO", "PREFERENCES", "HOME", "HELP", "CALENDAR",
        "WEB", "OFF"]

app.addToolbar(tools, tbFunc, findIcon=True)

Create Toolbars

Set Toolbars

ToolbarPinHidden

The toolbar will also gain an extra button (a pin) allowing the user to configure it to be pinned or not.

ToolbarPin


Advertisement why?



Adds a Menubar along the top of the GUI.

Menubars are made up of a series of menus, each containing a list of items:

Create Menus

MenuList

fileMenus = ["Open", "Save", "Save as...", "-", "Export", "Print", "-", "Close"]
app.addMenuList("File", fileMenus, menuPress) # create the File menu, with the list of items

MenuRB_CB

app.createMenu("Config")

for i in range(5):
    app.addMenuRadioButton("Config", "font", "1" + str(i), menuPress)

app.addMenuSeparator("Config")

for i in range(5):
    app.addMenuCheckBox("Config", "Size 1" + str(i), menuPress)

SubMenu

app.createMenu("Config")
app.addSubMenu("Config", "Font Size")
for i in range(5):
    app.addMenuRadioButton("Font Size", "font", "1" + str(i), menuPress)

Set Menus

Get Menus


Extra Features:

These options aren't available when you add a list of menu-items, only when you call the specific add function.


Platform Specific/Custom Menus

There are a few special menus available; pop-up menus, that appear when you right-click a widget and platform specific menus. To add items to these menus, use the menu names given below (eg. app.addMenuItem('EDIT', 'Name', func))

Right-click Menu

app.createRightClickMenu("Information", False)
app.addMenuList("Information", ["Information", "-", "Option 1", "Option 2", "Option 3"], infoMenu)
app.disableMenuItem("Information", "Information") # disable the title
app.addLabel("Press me")
app.setLabelRightClick("Press me", "Information")

Linux Menu

app.addMenuItem("appJar", "Help", app.appJarHelp)
app.addMenuItem("appJar", "About", app.appJarAbout)

Statusbar


Adds a statusbar along the bottom of the GUI. This can be used for easy debugging, as info for the user, or to show current settings.

Statusbar

app.addStatusbar(fields=3)
app.setStatusbar("Line: 20", 0)
app.setStatusbar("Column: 4", 1)
app.setStatusbar("Mode: Edit", 2)

Statusbar

app.addToolbar(tools, tbFunc, True)
app.addStatusbar(fields=3, side="RIGHT")
# NOTE: 0 is now on the right
app.setStatusbarWidth(50, 2)
app.setStatusbarBg("red", 2)
app.setStatusbarFg("white", 2)

Create Statusbars

Set Statusbars