Guest User

Untitled

a guest
Aug 20th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 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 ############ esta es la importación de la variable, la variable se encuentra señalada en la parte de abajo
  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. self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
  18. self.setAttribute(QtCore.Qt.WA_TranslucentBackground,True)
  19. self.setAttribute(QtCore.Qt.WA_NoSystemBackground,False)
  20.  
  21. self.closed.clicked.connect(lambda:self.close())
  22. self.mostrar_hora()
  23.  
  24. self.timer = QtCore.QTimer(self)
  25. self.timer.setInterval(1000)
  26. self.timer.timeout.connect(self.mostrar_hora)
  27. self.timer.start()
  28.  
  29. def mostrar_hora(self):
  30. self.hora.setText(QtCore.QDateTime.currentDateTime().toString("hh:mm:ss AP"))
  31.  
  32.  
  33.  
  34. class Dato(Principal):
  35. def __init__(self):
  36. Principal.__init__(self)
  37. self.b_login.clicked.connect(self.validate_User)
  38.  
  39. def validate_User(self):
  40. user = self.l_usuario.text()
  41.  
  42. if user == '':
  43. self.l_status.setText('No se ingreso un usuario')
  44. else:
  45. ref = db.reference("/usuarios/")
  46. res = ref.get()
  47.  
  48. for key in res.items():
  49. if key[0] == user:
  50. self.validate_password(user)
  51. def validate_password(self,user):
  52. password = self.l_password.text()
  53.  
  54. refp = db.reference("/usuarios/"+user)
  55. res = refp.get()
  56.  
  57. for key in res.items():
  58. if key[0] == 'password':
  59. if key[1] == password:
  60. self.other()
  61. self.l_status.setText("login")
  62. pass
  63. else:
  64. self.l_password.setText('')
  65. self.l_status.setText("Invalidate Password")
  66. elif key[0] == 'permisos':
  67. self.registro.acces = key[1]
  68. self.add.acces = key[1]
  69.  
  70.  
  71.  
  72. def other(self): ##############################
  73. user_name = self.l_usuario.text() #################### Esta es la variable
  74. self.close()
  75. self._Inicio.user.setText(self.l_usuario.text())
  76. self._Inicio.show()
  77.  
  78. def mousePressEvent(self,event):
  79. if event.button() == QtCore.Qt.LeftButton:
  80. self.dragPosition = event.globalPos() - self.frameGeometry().topLeft()
  81. event.accept()
  82. def mouseMoveEvent(self,event):
  83. if event.buttons() == QtCore.Qt.LeftButton:
  84. self.move(event.globalPos()-self.dragPosition)
  85. event.accept()
  86.  
  87. app = QApplication([])
  88. p = Dato()
  89. p.show()
  90. app.exec_()
  91.  
  92. from docx import Document
  93. from docx.shared import Inches, Pt
  94. from docx.enum.text import WD_PARAGRAPH_ALIGNMENT
  95. import time
  96. import getpass
  97. import os
  98.  
  99. user_name = '' ######### variable que toma el valor desde login
  100. print(user_name)
  101.  
  102. def imprimir_ticket(lista_items,totalt,cambiot,user_name1):
  103. print(user_name) ########## imprimo nuevamente la variable dentro de la función
  104. user = str(getpass.getuser())
  105.  
  106. time_one = str(time.strftime("%H%M%S"))
  107. fecha_one = str(time.strftime("%d-%m-%Y"))
  108. time_two = (str(time.strftime("%H:%M:%S")))
  109.  
  110. name = fecha_one + time_one
  111. name2 = 'Feacha: ' + fecha_one + time_two
  112.  
  113. path = 'C:/Users/'+user+'/Desktop/Comprobantes'
  114. res = 'C:/Users/'+user+'/Desktop/Comprobantes/'+name+'.docx'
  115.  
  116. t1 = '$ ' + str(totalt)
  117. c1 = '$ ' + str(cambiot)
  118. u = str(user_name)
  119.  
  120. doc = Document()
Add Comment
Please, Sign In to add comment