Guest User

Untitled

a guest
Aug 24th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. from PyQt5.QtWidgets import QMainWindow, QApplication
  2. from PyQt5 import uic, QtCore, Qt
  3. from Inicio import Inicio
  4. from Firebase_load import *
  5. from Registro import Image
  6. from add_users import Usuarios
  7. from es import user_name_1
  8.  
  9. class Principal(QMainWindow):
  10. def __init__(self):
  11. QMainWindow.__init__(self)
  12. uic.loadUi("Login.ui",self)
  13. self._Inicio = Inicio()
  14. self.registro = Image()
  15. self.add = Usuarios()
  16.  
  17.  
  18. self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
  19. self.setAttribute(QtCore.Qt.WA_TranslucentBackground,True)
  20. self.setAttribute(QtCore.Qt.WA_NoSystemBackground,False)
  21.  
  22. self.closed.clicked.connect(lambda:self.close())
  23. self.mostrar_hora()
  24.  
  25. self.combo_login ############### Widget
  26.  
  27. self.timer = QtCore.QTimer(self)
  28. self.timer.setInterval(1000)
  29. self.timer.timeout.connect(self.mostrar_hora)
  30. self.timer.start()
  31.  
  32. def mostrar_hora(self):
  33. self.hora.setText(QtCore.QDateTime.currentDateTime().toString("hh:mm:ss AP"))
  34.  
  35.  
  36.  
  37. class Dato(Principal):
  38. def __init__(self):
  39. Principal.__init__(self)
  40. self.b_login.clicked.connect(self.validate_User)
  41.  
  42. def validate_User(self):
  43.  
  44. user = self.l_usuario.text()
  45.  
  46. if user == '':
  47. self.l_status.setText('No se ingreso un usuario')
  48. else:
  49. ref = db.reference("/usuarios/")
  50. res = ref.get()
  51.  
  52. for key in res.items():
  53. if key[0] == user:
  54. self.validate_password(user)
  55. def validate_password(self,user):
  56. password = self.l_password.text()
  57.  
  58. refp = db.reference("/usuarios/"+user)
  59. res = refp.get()
  60.  
  61. for key in res.items():
  62. if key[0] == 'password':
  63. if key[1] == password:
  64. self.other()
  65. self.l_status.setText("login")
  66. pass
  67. else:
  68. self.l_password.setText('')
  69. self.l_status.setText("Invalidate Password")
  70. elif key[0] == 'permisos':
  71. self.registro.acces = int(key[1])
  72. self.add.acces = int(key[1])
  73.  
  74.  
  75.  
  76. def other(self):
  77.  
  78. self.close()
  79. user_name_1(self.l_usuario.text())
  80. self._Inicio.user_online_on(self.l_usuario.text(),self.combo_login.currentText())
  81. self._Inicio.user.setText(self.l_usuario.text())
  82. self._Inicio.show()
  83.  
  84. def mousePressEvent(self,event):
  85. if event.button() == QtCore.Qt.LeftButton:
  86. self.dragPosition = event.globalPos() - self.frameGeometry().topLeft()
  87. event.accept()
  88. def mouseMoveEvent(self,event):
  89. if event.buttons() == QtCore.Qt.LeftButton:
  90. self.move(event.globalPos()-self.dragPosition)
  91. event.accept()
  92.  
  93. app = QApplication([])
  94. p = Dato()
  95. p.show()
  96. app.exec_()
Add Comment
Please, Sign In to add comment