Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- import sys
- import gspread
- from oauth2client.service_account import ServiceAccountCredentials
- from PySide import QtGui,QtCore
- scope = ['https://spreadsheets.google.com/feeds']
- creds = ServiceAccountCredentials.from_json_keyfile_name('pass.json',scope)
- client = gspread.authorize(creds)
- sheet = client.open('login').sheet1
- class Example(QtGui.QWidget):
- def __init__(self):
- super(Example, self).__init__()
- self.initUI()
- def initUI(self):
- username = QtGui.QLabel('Username')
- password = QtGui.QLabel('Password')
- review = QtGui.QPushButton('Login',self)
- review.clicked.connect(self.buttonClicked())
- usernameEdit = QtGui.QLineEdit()
- passwordEdit = QtGui.QLineEdit()
- task1 = QtGui.QLineEdit()
- task2 = QtGui.QLineEdit()
- button = QtGui.QPushButton()
- grid = QtGui.QGridLayout()
- grid.setSpacing(10)
- grid.addWidget(username, 1, 0)
- grid.addWidget(usernameEdit, 1, 1)
- grid.addWidget(password, 2, 0)
- grid.addWidget(passwordEdit, 2, 1)
- grid.addWidget(review, 3, 1)
- grid.addWidget(task1,4,0)
- grid.addWidget(task2,4,1)
- grid.addWidget(button,4,2)
- self.setLayout(grid)
- self.setGeometry(300, 300, 350, 300)
- self.setWindowTitle('Online Judge')
- self.show()
- def buttonClicked(self):
- print('isus')
- for i in range(1, 6):
- try_username = sheet.cell(i, 1).value
- try_password = sheet.cell(i, 2).value
- print(try_username,usernameEdit, try_password, passwordEdit)
- if(try_username == usernameEdit and try_password == passwordEdit ):
- sheet.update_cell(i,3,'logged in')
- def main():
- app = QtGui.QApplication(sys.argv)
- ex = Example()
- sys.exit(app.exec_())
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement