phoenix_title wx.lib.agw.infobar.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.

This is the main class implementation, plainly translated from C++.


class_hierarchy Class Hierarchy

Inheritance diagram for class InfoBar:

appearance Control Appearance


wxMSW

wxMSW

wxMAC

wxMAC

wxGTK

wxGTK


super_classes Known Superclasses

wx.Control


method_summary Methods Summary

__init__

Default class constructor.

AddButton

Adds a button to be shown in the info bar.

Dismiss

Hides the InfoBar window.

DoHide

Hides this InfoBar with whatever hiding effect has been chosen.

DoShow

Shows this InfoBar with whatever showing effect has been chosen.

GetBarPlacement

Determines the placement of the bar from its position in the containing

GetDefaultBorder

Returns the default border style for InfoBar.

GetEffectDuration

Return the effect animation duration currently used, in milliseconds.

GetHideEffect

Return the effect currently used for hiding the bar.

GetShowEffect

Return the effect currently used for showing the bar.

Init

Common initialization code.

OnButton

Default event handler for the Close button in InfoBar.

RemoveButton

Remove a button previously added by AddButton.

SetEffectDuration

Sets the duration of the animation used when showing or hiding the bar.

SetFont

Overridden base class methods changes the font of the text message.

SetShowHideEffects

Set the effects to use when showing and hiding the bar.

ShowMessage

Show a message in the bar.

UpdateParent

Updates the parent layout appearance, but only if this InfoBar parent is not managed


api Class API

class InfoBar(wx.Control)

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

This is the main class implementation, plainly translated from C++.


Methods

__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, name='InfoBar')

Default class constructor.

Parameters:
  • parent – parent window. Must not be None;

  • id (integer) – window identifier. A value of -1 indicates a default value;

  • pos (tuple or wx.Point) – the control position. A value of (-1, -1) indicates a default position, chosen by either the windowing system or wxPython, depending on platform;

  • size (tuple or wx.Size) – the control size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxPython, depending on platform;

  • style (integer) – the InfoBar style (unused at present);

  • name (string) – the control name.



AddButton(self, btnid, label='', bitmap=wx.NullBitmap)

Adds a button to be shown in the info bar.

The button added by this method will be shown to the right of the text (in LTR layout), with each successive button being added to the right of the previous one. If any buttons are added to the info bar using this method, the default Close button is not shown as it is assumed that the extra buttons already allow the user to close it.

Clicking the button will generate a normal wx.wxEVT_COMMAND_BUTTON_CLICKED event which can be handled as usual. The default handler in InfoBar itself closes the window whenever a button in it is clicked so if you wish the info bar to be hidden when the button is clicked, simply call event.Skip() in the button handler to let the base class handler do it (calling Dismiss explicitly works too, of course). On the other hand, if you don’t skip the event, the info bar will remain opened so make sure to do it for at least some buttons to allow the user to close it.

Parameters:
  • btnid (integer) – id of the button. It will be used in the button message clicking this button will generate;

  • label (string) – the label of the button. It may only be empty if btnid is one of the stock ids in which case the corresponding stock label will be used;

  • bitmap – if not equal to NullBitmap, a valid wx.Bitmap image to show beside the button text.

Note

Notice that the generic InfoBar implementation handles the button events itself and so they are not propagated to the info bar parent and you need to either inherit from InfoBar and handle them in your derived class or use self.Bind(…) to handle the button events in the parent frame.



Dismiss(self)

Hides the InfoBar window.

This method hides the window and lays out the parent window to account for its disappearance (unlike a simple Hide()), but only if this InfoBar parent is not managed by framemanager or AuiManager.



DoHide(self)

Hides this InfoBar with whatever hiding effect has been chosen.



DoShow(self)

Shows this InfoBar with whatever showing effect has been chosen.



GetBarPlacement(self)

Determines the placement of the bar from its position in the containing sizer.

Returns:

One of these integer bits:

Placement Flag

Hex Value

Description

BarPlacement_Unknown

0x0

Unknown placement of InfoBar (not good).

BarPlacement_Top

0x1

InfoBar is placed at the top of its parent.

BarPlacement_Bottom

0x2

InfoBar is placed at the bottom of its parent.



GetDefaultBorder(self)

Returns the default border style for InfoBar.



GetEffectDuration(self)

Return the effect animation duration currently used, in milliseconds.



GetHideEffect(self)

Return the effect currently used for hiding the bar.

Returns:

One of the following integer bits:

ShowEffect Flag

Hex Value

Description

wx.SHOW_EFFECT_NONE

0x0

No effect, equivalent to normal Show() or Hide() call.

wx.SHOW_EFFECT_SLIDE_TO_TOP

0x7

Slide the InfoBar window to the top.

wx.SHOW_EFFECT_SLIDE_TO_BOTTOM

0x8

Slide the InfoBar window to the bottom.



GetShowEffect(self)

Return the effect currently used for showing the bar.

Returns:

One of the following integer bits:

ShowEffect Flag

Hex Value

Description

wx.SHOW_EFFECT_NONE

0x0

No effect, equivalent to normal Show() or Hide() call.

wx.SHOW_EFFECT_SLIDE_TO_TOP

0x7

Slide the InfoBar window to the top.

wx.SHOW_EFFECT_SLIDE_TO_BOTTOM

0x8

Slide the InfoBar window to the bottom.



Init(self)

Common initialization code.



OnButton(self, event)

Default event handler for the Close button in InfoBar.

Parameters:

event – a CommandEvent to be processed.

Note

Notice that the generic InfoBar implementation handles the button events itself and so they are not propagated to the info bar parent and you need to either inherit from InfoBar and handle them in your derived class or use self.Bind(…) to handle the button events in the parent frame.



RemoveButton(self, btnid)

Remove a button previously added by AddButton.

Parameters:

btnid (integer) – id of the button to remove. If more than one button with the same id is used in the InfoBar (which is in any case not recommended), the last, i.e. most recently added, button with this id is removed.



SetEffectDuration(self, duration)

Sets the duration of the animation used when showing or hiding the bar.

By default, 500ms duration is used.

Parameters:

duration (integer) – duration of the animation, in milliseconds.



SetFont(self, font)

Overridden base class methods changes the font of the text message.

InfoBar overrides this method to use the font passed to it for its text message part. By default a larger and bold version of the standard font is used.

Parameters:

font – a valid instance of wx.Font.

Note

Reimplemented from wx.Window.



SetShowHideEffects(self, showEffect, hideEffect)

Set the effects to use when showing and hiding the bar.

Either or both of the parameters can be set to wx.SHOW_EFFECT_NONE to disable using effects entirely.

By default, the info bar uses wx.SHOW_EFFECT_SLIDE_TO_BOTTOM effect for showing itself and wx.SHOW_EFFECT_SLIDE_TO_TOP for hiding if it is the first element of the containing sizer and reverse effects if it’s the last one. If it is neither the first nor the last element, no effect is used to avoid the use of an inappropriate one and this function must be called if an effect is desired.

Parameters:
  • showEffect (integer) – the effect to use when showing the bar;

  • hideEffect (integer) – the effect to use when hiding the bar.

The showEffect and hideEffect parameters can take one of the following bit:

ShowEffect Flag

Description

SHOW_EFFECT_NONE

No effect, equivalent to normal Show() or Hide() call.

SHOW_EFFECT_ROLL_TO_LEFT

Roll window to the left.

SHOW_EFFECT_ROLL_TO_RIGHT

Roll window to the right.

SHOW_EFFECT_ROLL_TO_TOP

Roll window to the top.

SHOW_EFFECT_ROLL_TO_BOTTOM

Roll window to the bottom.

SHOW_EFFECT_SLIDE_TO_LEFT

Slide window to the left.

SHOW_EFFECT_SLIDE_TO_RIGHT

Slide window to the right.

SHOW_EFFECT_SLIDE_TO_TOP

Slide window to the top.

SHOW_EFFECT_SLIDE_TO_BOTTOM

Slide window to the bottom.

SHOW_EFFECT_BLEND

Fade in or out effect.

SHOW_EFFECT_EXPAND

Expanding or collapsing effect.



ShowMessage(self, msg, flags=wx.ICON_INFORMATION)

Show a message in the bar.

If the bar is currently hidden, it will be shown. Otherwise its message will be updated in place.

Parameters:
  • msg (string) – the text of the message;

  • flags (integer) –

    one of wx.ICON_NONE, wx.ICON_INFORMATION (default), wx.ICON_QUESTION, wx.ICON_WARNING or wx.ICON_ERROR values.

    Note

    These flags have the same meaning as in MessageDialog for the generic version, i.e. show (or not, in case of wx.ICON_NONE) the corresponding icon in the bar but can be interpreted by the native versions. For example, the GTK+ native implementation doesn’t show icons at all but uses this parameter to select the appropriate background colour for the notification.



UpdateParent(self)

Updates the parent layout appearance, but only if this InfoBar parent is not managed by framemanager or AuiManager.