How to hide a window and show another window
-
Hi,
I'm having this error after creating an account for a user with a default password. After the default password is set a new window pops up asking the user to set new password and a confirm the password entered. After user enters a new password and confirms it. I want the loign page to show but I'm having this error messagefrom Login import LoginWindow
ImportError: cannot import name 'LoginWindow' from partially initialized module 'Login' (most likely due to a circular import) Below is what I tried after importing the login screen.from PyQt5 import QtCore, QtGui, QtWidgets from mainmenu import MainWindow from credentials import login_credentials import sqlite3 from Login import LoginWindow self.hide() loginwindow=LoginWindow() loginwindow.show()
-
@LT-K101
OK now that you have sorted theimport
statement.So you have a Python file with a top-level statement
self.hide()
as you show, nothing else in the file other than you show, and this work as Python code? Could you explain how that works, please, I am intrigued/wish to learn?
-
@JonB There is an sql query which after execution it hides the current window and show the login window
cur.execute(''' UPDATE users SET user_password ='" + encrytpass + "',access_status='existing' WHERE id_no ='"+username2+"' ''') con.commit() QMessageBox.information(self, "Success", "Password Saved Successfully") self.hide() self.loginwindow = Login.LoginWindow() self.loginwindow.show()
-
@LT-K101 said in How to hide a window and show another window:
@JonB Sorry my bad. Is it possible to encrypt sql database before I make a .exe?
Hi,
How would you decrypt and use it afterwards ?
In any case, since you are not using Qt's SQL module, you should check pysqlcipher3,
On a side note, the way you are building your queries opens for SQL injection attacks.
-
@LT-K101 said in How to hide a window and show another window:
What is the best practice for building sql queries, I thought what I'm doing is the standard way of doing things. Please can you enlighten me more on this please. Thank you.
You are choosing to use Python library instead of Qt library for all your SQL access, so this is not a Qt question. Look up "SQL injection attack" for your Python SQL library, it perhaps will explain and tell you to use "bound variables" in your queries rather than your attempt to interpolate arbitrary string variables into your string.
-
@LT-K101 said in How to hide a window and show another window:
@JonB What I mean is how to protect my database file on a computer's C:// drive ?Because I don't want the database file to be tempered with by an authorized persons.
More or less, you cannot. You may be able to restrict who can connect via SQLite to it (e.g. by not divulging password), but (unless you take some network file protection measures under NTFS, unlikely) you cannot stop a local user from deleting/altering a file on
C:
.