AGW Logo

agw_title balloontip

BalloonTip is a class that allows you to display tooltips in a balloon style window.


description Description

BalloonTip is a class that allows you to display tooltips in a balloon style window (actually a frame), similarly to the windows XP balloon help. There is also an arrow that points to the center of the control designed as a “target” for the BalloonTip.

What it can do:

  • Set the balloon shape as a rectangle or a rounded rectangle;
  • Set an icon to the top-left of the BalloonTip frame;
  • Set a title at the top of the BalloonTip frame;
  • Automatic “best” placement of BalloonTip frame depending on the target control/window position;
  • Runtime customization of title/tip fonts and foreground colours;
  • Runtime change of BalloonTip frame shape;
  • Set the balloon background colour;
  • Possibility to set the delay after which the BalloonTip is displayed;
  • Possibility to set the delay after which the BalloonTip is destroyed;
  • Three different behaviors for the BalloonTip window (regardless the delay destruction time set):
    1. Destroy by leave: the BalloonTip is destroyed when the mouse leaves the target control/window;
    2. Destroy by click: the BalloonTip is destroyed when you click on any area of the target control/window;
    3. Destroy by button: the BalloonTip is destroyed when you click on the top-right close button;
  • Possibility to enable/disable globally the BalloonTip on you application;
  • Set the BalloonTip also for the taskbar icon.

usage Usage

Usage example:

import wx
import wx.lib.agw.balloontip as BT

class MyFrame(wx.Frame):

    def __init__(self, parent):

        wx.Frame.__init(self, parent, -1, "BalloonTip Demo")

        panel = wx.Panel(self)

        # Let's suppose that in your application you have a wx.TextCtrl defined as:
        mytextctrl = wx.TextCtrl(panel, -1, "I am a textctrl", pos=(100, 100))

        # You can define your BalloonTip as follows:
        tipballoon = BT.BalloonTip(topicon=None, toptitle="textctrl",
                                   message="this is a textctrl",
                                   shape=BT.BT_ROUNDED,
                                   tipstyle=BT.BT_LEAVE)

        # Set the BalloonTip target
        tipballoon.SetTarget(mytextctrl)
        # Set the BalloonTip background colour
        tipballoon.SetBalloonColour(wx.WHITE)
        # Set the font for the balloon title
        tipballoon.SetTitleFont(wx.Font(9, wx.SWISS, wx.NORMAL, wx.BOLD, False))
        # Set the colour for the balloon title
        tipballoon.SetTitleColour(wx.BLACK)
        # Leave the message font as default
        tipballoon.SetMessageFont()
        # Set the message (tip) foreground colour
        tipballoon.SetMessageColour(wx.LIGHT_GREY)
        # Set the start delay for the BalloonTip
        tipballoon.SetStartDelay(1000)
        # Set the time after which the BalloonTip is destroyed
        tipballoon.SetEndDelay(3000)

# our normal wxApp-derived class, as usual

app = wx.PySimpleApp()

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

app.MainLoop()

This code snippet can be downloaded, see this example script.

Note

Some of the AGW snippets of code in the documentation use images and external files (to create bitmaps or access external data). As these files are not provided in these snippets, you should make the approriate modifications to the code to actually run it.


styles Window Styles

This class supports the following window styles:


Window styles for balloontip
Window Styles Hex Value Description
BT_ROUNDED 0x1 BalloonTip will have a rounded rectangular shape.
BT_RECTANGLE 0x2 BalloonTip will have a rectangular shape.
BT_LEAVE 0x3 BalloonTip will be destroyed when the user moves the mouse outside the target window.
BT_CLICK 0x4 BalloonTip will be destroyed when the user click on BalloonTip.
BT_BUTTON 0x5 BalloonTip will be destroyed when the user click on the close button.

events Events Processing

No custom events are available for this class.


license License And Version

BalloonTip is distributed under the wxPython license.

Latest revision: Andrea Gavana @ 17 Aug 2011, 15.00 GMT

Version 0.2

Module author: Andrea Gavana <andrea.gavana@gmail.com>


hierarchy Inheritance Diagram

Inheritance diagram for module: balloontip

Inheritance diagram of balloontip.BalloonFrame, balloontip.BalloonTip


svn_main SVN Revisions

A graphical representation of the SVN commits in the last year.

Click on any date in the picture to jump to that particular revision page, containing information about committers, log messages and SVN diffs.

balloontip

Revision Graph For balloontip


2to3 Python 3 Issues (via 2to3)

No issues have been detected by 2to3.py.