Advertisement
Guest User

Untitled

a guest
Aug 26th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.95 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import sys
  5. import gspread
  6. from oauth2client.service_account import ServiceAccountCredentials
  7. from PySide import QtGui,QtCore
  8.  
  9. scope = ['https://spreadsheets.google.com/feeds']
  10. creds = ServiceAccountCredentials.from_json_keyfile_name('pass.json',scope)
  11. client = gspread.authorize(creds)
  12. sheet = client.open('login').sheet1
  13.  
  14.  
  15. class Example(QtGui.QWidget):
  16.     def __init__(self):
  17.         super(Example, self).__init__()
  18.  
  19.         self.initUI()
  20.  
  21.     def initUI(self):
  22.         username = QtGui.QLabel('Username')
  23.         password = QtGui.QLabel('Password')
  24.         review = QtGui.QPushButton('Login',self)
  25.         review.clicked.connect(self.buttonClicked())
  26.  
  27.         usernameEdit = QtGui.QLineEdit()
  28.         passwordEdit = QtGui.QLineEdit()
  29.  
  30.         task1 = QtGui.QLineEdit()
  31.         task2 = QtGui.QLineEdit()
  32.         button = QtGui.QPushButton()
  33.         grid = QtGui.QGridLayout()
  34.         grid.setSpacing(10)
  35.  
  36.         grid.addWidget(username, 1, 0)
  37.         grid.addWidget(usernameEdit, 1, 1)
  38.  
  39.         grid.addWidget(password, 2, 0)
  40.         grid.addWidget(passwordEdit, 2, 1)
  41.  
  42.         grid.addWidget(review, 3, 1)
  43.  
  44.         grid.addWidget(task1,4,0)
  45.         grid.addWidget(task2,4,1)
  46.         grid.addWidget(button,4,2)
  47.         self.setLayout(grid)
  48.  
  49.         self.setGeometry(300, 300, 350, 300)
  50.         self.setWindowTitle('Online Judge')
  51.         self.show()
  52.  
  53.     def buttonClicked(self):
  54.         print('isus')
  55.         for i in range(1, 6):
  56.  
  57.             try_username = sheet.cell(i, 1).value
  58.             try_password = sheet.cell(i, 2).value
  59.             print(try_username,usernameEdit, try_password, passwordEdit)
  60.             if(try_username == usernameEdit and try_password == passwordEdit ):
  61.  
  62.                 sheet.update_cell(i,3,'logged in')
  63.  
  64.  
  65. def main():
  66.     app = QtGui.QApplication(sys.argv)
  67.     ex = Example()
  68.     sys.exit(app.exec_())
  69.  
  70.  
  71. if __name__ == '__main__':
  72.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement