<filename>bin/Python27/Lib/site-packages/vitables/vtsplash.py
#!/usr/bin/env python2
# -*- coding: utf-8 -*-

#       Copyright (C) 2005-2007 <NAME>. All rights reserved
#       Copyright (C) 2008-2013 <NAME>. All rights reserved
#
#       This program is free software: you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation, either version 3 of the License, or
#       (at your option) any later version.
#
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#
#       You should have received a copy of the GNU General Public License
#       along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#       Author:  <NAME> - <EMAIL>

"""
Here is defined the VTSplash class. It displays the splash screen during the
``ViTables`` startup and shows the advance of the startup sequence.
"""

__docformat__ = 'restructuredtext'

import time

from PyQt4 import QtCore, QtGui

class VTSplash(QtGui.QSplashScreen):
    """
    The application splash screen.

    :Parameter png: the pixmap image displayed as a splash screen.
    """

    def __init__(self, png):
        """
        Initialize the application.

        Create a splash screen and ties it to a painter which will
        be in charge of displaying the needed messages.
        """

        super(VTSplash, self).__init__(png)


    def drawContents(self, painter):
        """Draw the contents of the splash screen using the given painter.

        This is an overloaded method. It draws contents with the origin
        translated by a certain offset.

        :Parameter painter: the painter used to draw the splash screen
        """

        painter.setPen(QtGui.QColor(QtCore.Qt.white))
        font = painter.font()
        font.setBold(True)
        painter.setFont(font)
        painter.drawText(10, 215, self.msg)


    def drawMessage(self, msg):
        """
        Draw the message text onto the splash screen.

        :Parameter msg: the message to be displayed
        """

        QtGui.qApp.processEvents()
        self.msg = msg
        self.showMessage(self.msg)
        time.sleep(0.500)
        self.clearMessage()
