I'm not able to modify an attribute of the first class (login_window) from the other (user_register_window)... My code is the following:
class login_window(QtGui.QWidget, Ui_login_form):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.setupUi(self)
self.register_window = None
self.login_btn.clicked.connect(self.login_func)
self.register_btn.clicked.connect(self.register_func)
usernames_list = c.execute("SELECT USERNAME FROM register_table").fetchall()
for data in usernames_list:
self.username_combo_field.addItems(data)
def register_func(self):
if self.register_window is None:
self.register_window = user_register_window(self)
self.register_btn.setEnabled(False)
self.login_btn.setEnabled(False)
self.register_window.show()
class user_register_window(QtGui.QDialog, Ui_register_form):
def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
self.setWindowFlags(self.windowFlags() | QtCore.Qt.CustomizeWindowHint)
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint)
self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowCloseButtonHint)
self.cancel_btn.clicked.connect(self.cancel_pressed)
def cancel_pressed(self):
user_register_window.close(self)
login_window.login_btn.setEnabled(True) #doesn't work
My login_window runs first, so when I click register_btn, "user_register_window" appears, with register_btn and login_btn disabled in login_window. So far everything works ok, my problem is when i close "user_register_window". When I press cancel_btn I would like to enable again "register_btn" and "login_btn".
I tried with the following code:
login_window.login_btn.setEnabled(True)
inside cancel_pressed function, but it doesn't work.
AttributeError: type object 'login_window' has no attribute 'login_btn'
Is there a way to do it?
Thanks a lot for your help!!!