[PyQt] About the StatusBar

Sandro Dutra hexodin at gmail.com
Tue Feb 10 16:41:31 GMT 2009


Using QtDesigner and Eric4, I create a statusBar using the command "Create
Status Bar" on the popup menu, but I can't stylize the statusBar that I want
to show and the default statusBar is not funny/beautiful itself, I make a
code that imitates the look and fell I want to see... this is the code:
==================
from PyQt4.QtGui import QMainWindow,  QMessageBox,  QIcon,  QLabel,  QFrame,
QApplication
from PyQt4.QtCore import pyqtSignature,  QRect,  Qt


from Ui_Pro2MainWindow import Ui_Pro2MainWindow
from Pro2Calc import Pro2CalcDialog
from Pro2Search import Pro2SearchDialog
from Pro2PasswChange import Pro2PasswChangeDialog
from db.database import Pro2db


class Pro2MainWindow(QMainWindow, Ui_Pro2MainWindow):
    """
    Class documentation goes here.
    """
    def __init__(self, user,  passw,  parent = None):
        """
        Constructor
        """
        QMainWindow.__init__(self, parent)
        self.setupUi(self)
        self.setWindowIcon(QIcon(":images/images/mochila.png"))

        # user and password and the connection of the MySQL database
        self.user = user
        self.passw = passw
        self.pro2db = Pro2db(str(self.user),  str(self.passw))

        # Here I use a QLabel to get user information from the database and
stylize
        infoLabel = QLabel(self.statusBar)
        infoLabel.setAlignment(Qt.AlignHCenter)
        infoLabel.setFrameStyle(QFrame.Panel | QFrame.Sunken)

        # Here I used the QApplication to hold the screen size and give a
size to the statusBar
        desktop = QApplication.desktop()
        resolution = desktop.screenGeometry()
        infoLabel.setFixedWidth(resolution.width())

        # Here the information is in statusBar
        if user != 'root':
            userInfo = self.pro2db.getUserInfo(user)
            message = "[<b>MATRÍCULA</b>: %s] | [<b>SERVIDOR</b>: %s] |
[<b>SETOR</b>: %s]" % (userInfo[0],  userInfo[1],  userInfo[2])
            self.statusBar.addPermanentWidget(infoLabel.setText(message))
        else:
            self.statusBar.addPermanentWidget(infoLabel.setText(u"USUÁRIO:
ADMINISTRADOR"))
==================

My question is: There's a way more simple than this? Using only the
QtDesigner, for example to create this look & fell to a statusBar...

Best Regards,
Sandro Dutra,
Brazil;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090210/8082e218/attachment.html


More information about the PyQt mailing list