<br><br><div class="gmail_quote">2009/1/15 Sandro Dutra <span dir="ltr"><<a href="mailto:hexodin@gmail.com">hexodin@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Sorry for the delay... it's the time, it's the time...<br><br>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:<br>
<br>---Pro2MainWindow Code---<br># -*- coding: utf-8 -*-<br><br>"""<br>Module implementing Pro2MainWindow.<br>"""<br><br>from PyQt4.QtGui import QMainWindow<br>from PyQt4.QtCore import pyqtSignature<br>
<br>from Ui_Pro2MainWindow import Ui_Pro2MainWindow<br><br>class Pro2MainWindow(QMainWindow, Ui_Pro2MainWindow):<br> """<br> Class documentation goes here.<br> """<br> def __init__(self, parent = None):<br>
"""<br> Constructor<br> """<br> QMainWindow.__init__(self, parent)<br> self.setupUi(self)<br><br>The setupUi, only call the definitions of the ui generated by QtDesigner, and here's the complete code for the login screen: <br>
# -*- coding: utf-8 -*-<br><br>"""<br>Module implementing DialogPro2Login.<br>"""<br><br>from PyQt4.QtGui import QDialog, QMessageBox, QApplication<br>from PyQt4.QtCore import pyqtSignature<br>
<br>from Ui_Pro2Login import Ui_DialogPro2Login<br>from Pro2MainWindow import Pro2MainWindow<br>from db.database import Pro2db<br><br>import MySQLdb, sys<br><br>class DialogPro2Login(QDialog, Ui_DialogPro2Login):<br> """<br>
Class documentation goes here.<br> """<br> def __init__(self, parent = None):<br> """<br> Constructor<br> """<br> QDialog.__init__(self, parent)<br>
self.setupUi(self)<br> <br> @pyqtSignature("")<div class="Ih2E3d"><br> def on_pushButton_enter_clicked(self):<br> user = self.lineEdit_user.text()<br> passw = self.lineEdit_passw.text()<br>
if user == "" or passw == "":<br>
QMessageBox.information(self, "ERRO", u"Por favor, entre com o usuário e senha.", "OK")<br> else:<br> try:<br></div> p2db = Pro2db(str(user), str(passw)) ### Here is where I want to call the mainwindow ####<br>
wndMain = Pro2MainWindow()<br> wndMain.exec_()<br> wndMain.showMaximized()<br> self.hide()<div class="Ih2E3d"><br>##############################<br> except MySQLdb.Error, error_code:<br>
if error_code[0] == 1045:<br> message = u"Acesso negado para o usuário: %s" %user<br> elif error_code[0] == 2003:<br> message = u"Não foi possível realizar a conexão."<br>
else:<br> message = u"Erro desconhecido.\nCódigo administrativo: %s - %s." %(error_code[0], error_code[1])<br> QMessageBox.information(self, "Falha no acesso", u"O servidor informa:\n%s" %message, "OK")<br>
<br></div> @pyqtSignature("")<br> def on_pushButton_exit_clicked(self):<br> self.close()<br><br>If you need more info tell me,<br>Thanks for the attention to a so noob problem.<br>Sandro Dutra - Brazil.<br>
<br><div class="gmail_quote">2009/1/14 Sergio Jovani <span dir="ltr"><<a href="mailto:lesergi@gmail.com" target="_blank">lesergi@gmail.com</a>></span><div><div></div><div class="Wj3C7c"><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
It would be good you post more code, at least, Pro2MainWindow class.<br>
<br>
2009/1/14 Sandro Dutra <<a href="mailto:hexodin@gmail.com" target="_blank">hexodin@gmail.com</a>>:<br>
<div><div></div><div>> I get a AttibuteError in mainWnd.exec_()<br>
><br>
> If necessary, I can upload the complete code.<br>
><br>
> Thanks in advance.<br>
><br>
> 2009/1/13 Sergio Jovani <<a href="mailto:lesergi@gmail.com" target="_blank">lesergi@gmail.com</a>><br>
>><br>
>> Hi,<br>
>><br>
>> This is a little piece of code, but you can try with:<br>
>><br>
>> mainWnd = Pro2MainWindow()<br>
>> mainWnd.exec_()<br>
>> mainWnd.showMaximized()<br>
>> self.hide()<br>
>><br>
>> 2009/1/13 Sandro Dutra <<a href="mailto:hexodin@gmail.com" target="_blank">hexodin@gmail.com</a>>:<br>
>> > I'm writing a solution using Python, Qt and MySQL, I create the login<br>
>> > screen<br>
>> > and set all the errors...<br>
>> ><br>
>> > The problem is: When the user do the correct login in MySQL, I want the<br>
>> > login screen to close, and the whole application show.<br>
>> ><br>
>> > The code when the button "Enter" is pressed:<br>
>> > ---------------------------<br>
>> > def on_pushButton_enter_clicked(self):<br>
>> > user = self.lineEdit_user.text()<br>
>> > passw = self.lineEdit_passw.text()<br>
>> > if user == "" or passw == "":<br>
>> > QMessageBox.information(self, "ERRO", u"Por favor, entre<br>
>> > com o<br>
>> > usuário e senha.", "OK")<br>
>> > else:<br>
>> > try: ############ If the login is made, the application is<br>
>> > launch and the login screen is closed.<br>
>> > p2db = Pro2db(str(user), str(passw))<br>
>> > mainWnd = Pro2MainWindow()<br>
>> > mainWnd.showMaximized()<br>
>> > self.close()<br>
>> > ###########################################<br>
>> > except MySQLdb.Error, error_code:<br>
>> > if error_code[0] == 1045:<br>
>> > message = u"Acesso negado para o usuário: %s" %user<br>
>> > elif error_code[0] == 2003:<br>
>> > message = u"Não foi possível realizar a conexão."<br>
>> > else:<br>
>> > message = u"Erro desconhecido.\nCódigo<br>
>> > administrativo:<br>
>> > %s - %s." %(error_code[0], error_code[1])<br>
>> > QMessageBox.information(self, "Falha no acesso", u"O<br>
>> > servidor informa:\n%s" %message, "OK")<br>
>> > ---------------------------<br>
>> ><br>
>> > Anyone can help?<br>
>> ><br>
>> > Thanks in advance,<br>
>> > Sandro Dutra,<br>
>> > Brazil.<br>
>> ><br>
>> > _______________________________________________<br>
>> > PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com" target="_blank">PyQt@riverbankcomputing.com</a><br>
>> > <a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br>
>> ><br>
><br>
><br>
</div></div></blockquote></div></div></div><br>
</blockquote></div><br>