An info bar is a transient window shown at top or bottom of its parent window to display non-critical information to the user.
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.
InfoBar supports all the InfoBar generic implementation functionalities, and in addition it using meth:~InfoBar.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)
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.AddF(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()
No particular window styles are available for this class.
This class processes the following events:
Event Name | Description |
---|---|
EVT_BUTTON | Process a wxEVT_COMMAND_BUTTON_CLICKED event, when the button is clicked. |
InfoBar control is distributed under the wxPython license.
Latest Revision: Andrea Gavana @ 22 Mar 2012, 21.00 GMT
Version 0.2
GetCloseButtonBitmap | For platforms supporting it (namely wxMSW and wxMAC), this method uses RendererNative |
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 |
For platforms supporting it (namely wxMSW and wxMAC), this method uses RendererNative to draw a natively-looking close button on the InfoBar itself.
Parameters: |
|
---|