Skip to content

Instantly share code, notes, and snippets.

@Kristian-Roopnarine
Created September 30, 2019 23:37
Show Gist options
  • Save Kristian-Roopnarine/6e2db92a6faa52be86d05c2f63822991 to your computer and use it in GitHub Desktop.
Save Kristian-Roopnarine/6e2db92a6faa52be86d05c2f63822991 to your computer and use it in GitHub Desktop.
class PassGUI(QtWidgets.QWidget):
def __init__(self):
super().__init__() #call the constructor of QtWidgets
self.init_ui() #constructor for our UI
def init_ui(self): #everything inside the window
self.setGeometry(50,50,600,150)
font = QtGui.QFont()
font.setPointSize(16)
#create username field
self.usernameEdit = QtWidgets.QLineEdit()
self.usernameLabel = QtWidgets.QLabel('Username')
self.usernameLabel.setFont(font)
self.usernameEdit.move(150,20)
#create password field
self.passwordEdit = QtWidgets.QLineEdit()
self.passwordLabel = QtWidgets.QLabel('Password')
self.passwordLabel.setFont(font)
#create website/app field
self.websiteEdit = QtWidgets.QLineEdit()
self.websiteLabel = QtWidgets.QLabel('Website/App')
self.websiteLabel.setFont(font)
self.submit = QtWidgets.QPushButton('Submit')
#lay out the username fields
h_box_username = QtWidgets.QHBoxLayout()
h_box_username.addStretch()
h_box_username.addWidget(self.usernameEdit)
h_box_username.addWidget(self.usernameLabel)
h_box_username.addStretch()
#layout the password fields
h_box_password = QtWidgets.QHBoxLayout()
h_box_password.addStretch()
h_box_password.addWidget(self.passwordEdit)
h_box_password.addWidget(self.passwordLabel)
h_box_password.addStretch()
#layout the website fields
h_box_website = QtWidgets.QHBoxLayout()
h_box_website.addStretch()
h_box_website.addWidget(self.websiteEdit)
h_box_website.addWidget(self.websiteLabel)
h_box_website.addStretch()
h_box_submit = QtWidgets.QHBoxLayout()
h_box_submit.addStretch()
h_box_submit.addWidget(self.submit)
h_box_submit.addStretch()
#create vertical alignment for inputs
v_box_input = QtWidgets.QVBoxLayout()
v_box_input.addLayout(h_box_username)
v_box_input.addLayout(h_box_password)
v_box_input.addLayout(h_box_website)
v_box_input.addLayout(h_box_submit)
self.setLayout(v_box_input)
self.setWindowTitle('Passwords')
information = self.read_passwords('passwords.json')
self.convert_to_labels(information,v_box_input)
self.submit.clicked.connect(lambda:self.btn_click(v_box_input,information))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment