[PyQt] Problem calling a window

Sandro Dutra hexodin at gmail.com
Thu Jan 15 17:26:35 GMT 2009


Sorry for the delay... it's the time, it's the time...

I used Eric4 and QtDesigner, so the Pro2MainWindow it's only the window
without the widgets (I only want to test the call), here's the code:

---Pro2MainWindow Code---
# -*- coding: utf-8 -*-

"""
Module implementing Pro2MainWindow.
"""

from PyQt4.QtGui import QMainWindow
from PyQt4.QtCore import pyqtSignature

from Ui_Pro2MainWindow import Ui_Pro2MainWindow

class Pro2MainWindow(QMainWindow, Ui_Pro2MainWindow):
    """
    Class documentation goes here.
    """
    def __init__(self, parent = None):
        """
        Constructor
        """
        QMainWindow.__init__(self, parent)
        self.setupUi(self)

The setupUi, only call the definitions of the ui generated by QtDesigner,
and here's the complete code for the login screen:
# -*- coding: utf-8 -*-

"""
Module implementing DialogPro2Login.
"""

from PyQt4.QtGui import QDialog,  QMessageBox,  QApplication
from PyQt4.QtCore import pyqtSignature

from Ui_Pro2Login import Ui_DialogPro2Login
from Pro2MainWindow import Pro2MainWindow
from db.database import Pro2db

import MySQLdb,  sys

class DialogPro2Login(QDialog, Ui_DialogPro2Login):
    """
    Class documentation goes here.
    """
    def __init__(self, parent = None):
        """
        Constructor
        """
        QDialog.__init__(self, parent)
        self.setupUi(self)

    @pyqtSignature("")
    def on_pushButton_enter_clicked(self):
        user = self.lineEdit_user.text()
        passw = self.lineEdit_passw.text()
        if user == "" or passw == "":
            QMessageBox.information(self,  "ERRO",  u"Por favor, entre com o
usuário e senha.",  "OK")
        else:
            try:
                p2db = Pro2db(str(user),  str(passw)) ### Here is where I
want to call the mainwindow ####
                wndMain = Pro2MainWindow()
                wndMain.exec_()
                wndMain.showMaximized()
                self.hide()
##############################
            except MySQLdb.Error,  error_code:
                if error_code[0] == 1045:
                    message = u"Acesso negado para o usuário: %s" %user
                elif error_code[0] == 2003:
                    message = u"Não foi possível realizar a conexão."
                else:
                    message = u"Erro desconhecido.\nCódigo administrativo:
%s - %s." %(error_code[0],  error_code[1])
                QMessageBox.information(self, "Falha no acesso",  u"O
servidor informa:\n%s" %message,  "OK")

    @pyqtSignature("")
    def on_pushButton_exit_clicked(self):
        self.close()

If you need more info tell me,
Thanks for the attention to a so noob problem.
Sandro Dutra - Brazil.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090115/54bb0226/attachment.html


More information about the PyQt mailing list