Phoenix Logo

phoenix_title wx.lib.agw.infobar

An info bar is a transient window shown at top or bottom of its parent window to display non-critical information to the user.

Description

An info bar is a transient window shown at top or bottom of its parent window to display non-critical information to the user.

Note

The Python implementation of InfoBar is a direct translation of the generic C++ implementation of InfoBar.

This class provides another way to show messages to the user, intermediate between message boxes and status bar messages. The message boxes are modal and thus interrupt the users work flow and should be used sparingly for this reason. However status bar messages are often too easy not to notice at all. An info bar provides a way to present the messages which has a much higher chance to be noticed by the user but without being annoying.

Info bar may show an icon (on the left), text message and, optionally, buttons allowing the user to react to the information presented. It always has a close button at the right allowing the user to dismiss it so it isn’t necessary to provide a button just to close it.

InfoBar calls its parent Layout() method (if its parent is not managed by framemanager or AuiManager) and assumes that it will change the parent layout appropriately depending on whether the info bar itself is shown or hidden. Usually this is achieved by simply using a sizer for the parent window layout and adding wxInfoBar to this sizer as one of the items. Considering the usual placement of the info bars, normally this sizer should be a vertical BoxSizer and the bar its first or last element.

Base Functionalities

InfoBar supports all the InfoBar generic implementation functionalities, and in addition it using AddButton it is possible to add a button with a bitmap (and not only a plain Button).

For example:

info = InfoBar(parent)
bitmap = wx.Bitmap('nice_bitmap.png', wx.BITMAP_TYPE_PNG)

info.AddButton(wx.NewId(), 'New Button', bitmap)

Usage

The simplest possible example of using this class would be:

import wx
import wx.lib.agw.infobar as IB

class MyFrame(wx.Frame):

    def __init__(self, parent):

        wx.Frame.__init__(self, parent, -1, 'InfoBar Demo')

        self._infoBar = IB.InfoBar(self)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self._infoBar, wx.SizerFlags().Expand())

        panel = wx.Panel(self)
        sizer.Add(panel, 1, wx.EXPAND)

        # ... Add other frame controls to the sizer ...
        self.SetSizer(sizer)

        wx.CallLater(2000, self.SomeMethod)


    def SomeMethod(self):

        self._infoBar.ShowMessage("Something happened", wx.ICON_INFORMATION)


# our normal wxApp-derived class, as usual

app = wx.App(0)

frame = MyFrame(None)
app.SetTopWindow(frame)
frame.Show()

app.MainLoop()

Supported Platforms

InfoBar has been tested on the following platforms:
  • Windows (Vista/7).

Window Styles

No particular window styles are available for this class.

Events Processing

This class processes the following events:

Event Name Description
wx.EVT_BUTTON Process a wx.wxEVT_COMMAND_BUTTON_CLICKED event, when the button is clicked.

License And Version

InfoBar control is distributed under the wxPython license.

Latest Revision: Andrea Gavana @ 27 Dec 2012, 21.00 GMT

Version 0.3

function_summary Functions Summary

GetCloseButtonBitmap For platforms supporting it (namely wxMSW and wxMAC), this method uses RendererNative

class_summary Classes Summary

AutoWrapStaticText A simple class derived from lib.stattext that implements auto-wrapping
InfoBar An info bar is a transient window shown at top or bottom of its parent window to display

Functions



GetCloseButtonBitmap(win, size, colBg, flags=0)

For platforms supporting it (namely wxMSW and wxMAC), this method uses RendererNative to draw a natively-looking close button on the InfoBar itself.

Parameters:
  • win – the window in which we wish to draw the close button (an instance of InfoBar);
  • size (tuple) – the close button size, a tuple of (width, height) dimensions in pixels;
  • colBg – the background colour of the parent window, an instance of wx.Colour;
  • flags (integer) – may have the wx.CONTROL_PRESSED, wx.CONTROL_CURRENT or wx.CONTROL_ISDEFAULT bit set.