Guest User

Untitled

a guest
Oct 17th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.94 KB | None | 0 0
  1. from PyQt5.QtWidgets import QMainWindow, QApplication
  2. from PyQt5 import QtCore
  3. from PyQt5 import uic
  4. from PyQt5.Qt import QMovie
  5. from FirebaseLogin import *
  6. from contraInicio import ContraInicioC
  7. from Principal import PrincipalC
  8. from MostrarDatosTabla import mostararDatos
  9. from CrearFirebase import crear_tabla
  10. from sucursalInicio import sucursal
  11. import sqlite3
  12. import threading
  13.  
  14. class LoginC(QMainWindow):
  15. def __init__(self):
  16. QMainWindow.__init__(self)
  17. uic.loadUi("Interfaz/Login.ui",self)
  18.  
  19. self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
  20. self.l_permiso.setAttribute(QtCore.Qt.WA_NoMousePropagation)
  21. self.l_sucursal.setAttribute(QtCore.Qt.WA_NoMousePropagation)
  22.  
  23. self.l_close.clicked.connect(self.close)
  24.  
  25.  
  26.  
  27. self.contraseña = ContraInicioC()
  28. self.principal = PrincipalC()
  29. self.l_entrar.clicked.connect(self.setDataPrincipal)
  30. self.l_permiso.currentIndexChanged.connect(lambda:self.cambioPermiso(self.l_permiso.currentText()))
  31. self.l_permiso.setCurrentText("Caja")
  32. self.suc = sucursal
  33. self.l_sucursal.setCurrentText(self.suc)
  34. #self.principal.pc_fecha.setDate(QtCore.QDate.currentDate())
  35.  
  36.  
  37.  
  38. @QtCore.pyqtSlot(str)
  39. def cambioPermiso(self,permiso):
  40. if permiso == "Administrador":
  41.  
  42. self.l_sucursal.setEnabled(True)
  43. else:
  44.  
  45. self.l_sucursal.setEnabled(False)
  46.  
  47. def setDataPrincipal(self):
  48. t = threading.Thread(target=self.anima)
  49. t.start()
  50.  
  51. self.estado = 0
  52. fechaActual = QtCore.QDate.currentDate().toPyDate()
  53.  
  54. ref = db.reference("/"+str(fechaActual))
  55. ret = ref.get()
  56.  
  57. if ret == None:
  58. print("creada")
  59. crear_tabla(str(fechaActual))
  60. self.estado = 0
  61. if self.l_permiso.currentIndex()==1:
  62. self.principal.pc_sucursal.setEnabled(False)
  63. self.principal.pc_fecha.setDate(QtCore.QDate.currentDate())
  64. self.principal.pc_sucursal.setCurrentText(self.l_sucursal.currentText())
  65. self.principal.show()
  66.  
  67. else:
  68. print("value")
  69. #self.contraseña.datos(self.l_permiso.currentText(), "Matutino", self.l_sucursal.currentText(),self.estado,self.principal.p_referencia)
  70. self.contraseña.permiso = self.l_permiso.currentText()
  71. self.contraseña.turno = "Matutino"
  72. self.contraseña.sucursal = self.l_sucursal.currentText()
  73. self.contraseña.estado = self.estado
  74. self.contraseña.referencia = self.principal.p_referencia
  75. self.contraseña.show()
  76. else:
  77. self.estado =1
  78. print("actualizada")
  79. #mostararDatos(str(fechaActual),self.l_sucursal.currentText(),"Matutino",self.principal.saldo,self.principal.tablaM,self.principal.inventario,self.principal.p_referencia)
  80.  
  81. if self.l_permiso.currentIndex()==1:
  82. self.principal.pc_sucursal.setEnabled(False)
  83. self.principal.pc_fecha.setDate(QtCore.QDate.currentDate())
  84. self.principal.pc_sucursal.setCurrentText(self.l_sucursal.currentText())
  85. self.principal.show()
  86.  
  87. else:
  88.  
  89. #self.contraseña.datos(self.l_permiso.currentText(), "Matutino", self.l_sucursal.currentText(),self.estado,self.principal.p_referencia)
  90. self.contraseña.permiso = self.l_permiso.currentText()
  91. self.contraseña.turno = "Matutino"
  92. self.contraseña.sucursal = self.l_sucursal.currentText()
  93. self.contraseña.estado = self.estado
  94. self.contraseña.referencia = self.principal.p_referencia
  95. self.contraseña.show()
  96.  
  97.  
  98. self.principal.o_sucursal.setText(self.l_sucursal.currentText())
  99. self.principal.o_turno.setText("Matutino")
  100. self.principal.o_permiso.setText(self.l_permiso.currentText())
  101. #self.principal.pc_sucursal.setCurrentText(self.l_sucursal.currentText())
  102. #self.principal.pc_fecha.setDate(QtCore.QDate.currentDate())
  103. self.close()
  104.  
  105. def mousePressEvent(self,event):
  106.  
  107. if event.button() == QtCore.Qt.LeftButton:
  108. self.dragPosition = event.globalPos() - self.frameGeometry().topLeft()
  109. event.accept()
  110.  
  111.  
  112. def mouseMoveEvent(self,event):
  113. if event.buttons() == QtCore.Qt.LeftButton:
  114. self.move(event.globalPos() - self.dragPosition)
  115. event.accept()
  116. def anima(self):
  117. self.movie = QMovie("uno.gif")
  118. self.label.setMovie(self.movie)
  119. self.movie.start()
  120.  
  121. app = QApplication([])
  122. l = LoginC()
  123. l.show()
  124. app.exec_()
  125.  
  126. <?xml version="1.0" encoding="UTF-8"?>
  127. <ui version="4.0">
  128. <class>MainWindow</class>
  129. <widget class="QMainWindow" name="MainWindow">
  130. <property name="geometry">
  131. <rect>
  132. <x>0</x>
  133. <y>0</y>
  134. <width>650</width>
  135. <height>370</height>
  136. </rect>
  137. </property>
  138. <property name="windowTitle">
  139. <string>MainWindow</string>
  140. </property>
  141. <widget class="QWidget" name="centralwidget">
  142. <widget class="QLabel" name="label">
  143. <property name="geometry">
  144. <rect>
  145. <x>0</x>
  146. <y>0</y>
  147. <width>650</width>
  148. <height>370</height>
  149. </rect>
  150. </property>
  151. <property name="text">
  152. <string/>
  153. </property>
  154. </widget>
  155. <widget class="QPushButton" name="l_close">
  156. <property name="geometry">
  157. <rect>
  158. <x>620</x>
  159. <y>0</y>
  160. <width>31</width>
  161. <height>23</height>
  162. </rect>
  163. </property>
  164. <property name="font">
  165. <font>
  166. <pointsize>9</pointsize>
  167. <weight>75</weight>
  168. <bold>true</bold>
  169. </font>
  170. </property>
  171. <property name="styleSheet">
  172. <string notr="true">QPushButton#l_close{
  173. background:none;
  174. border:0px;
  175. color:grey;
  176. }
  177. QPushButton#l_close:hover{
  178. color:red;
  179. }</string>
  180. </property>
  181. <property name="text">
  182. <string>X</string>
  183. </property>
  184. </widget>
  185. <widget class="QLabel" name="lsucursal">
  186. <property name="geometry">
  187. <rect>
  188. <x>380</x>
  189. <y>330</y>
  190. <width>51</width>
  191. <height>22</height>
  192. </rect>
  193. </property>
  194. <property name="styleSheet">
  195. <string notr="true">color:grey;
  196. background:none;</string>
  197. </property>
  198. <property name="text">
  199. <string>Sucursal:</string>
  200. </property>
  201. </widget>
  202. <widget class="QLabel" name="la">
  203. <property name="geometry">
  204. <rect>
  205. <x>220</x>
  206. <y>330</y>
  207. <width>51</width>
  208. <height>22</height>
  209. </rect>
  210. </property>
  211. <property name="styleSheet">
  212. <string notr="true">color:grey;
  213. background:none;</string>
  214. </property>
  215. <property name="text">
  216. <string>Permisos</string>
  217. </property>
  218. </widget>
  219. <widget class="QComboBox" name="l_permiso">
  220. <property name="geometry">
  221. <rect>
  222. <x>268</x>
  223. <y>330</y>
  224. <width>91</width>
  225. <height>22</height>
  226. </rect>
  227. </property>
  228. <property name="styleSheet">
  229. <string notr="true">QComboBox#l_permiso{
  230. background:none;
  231. border:0px;
  232. border-bottom: 1px solid lightblue;
  233. color:#05839C;
  234. }
  235.  
  236.  
  237. QComboBox QAbstractItemView
  238. {
  239. border:0px;
  240. background:white;
  241. color: grey;
  242.  
  243. }
  244. QComboBox#l_permiso::drop-down
  245. {
  246. subcontrol-origin: padding;
  247. subcontrol-position: top right;
  248. width: 15px;
  249. color: white;
  250. border-left-width: 0px;
  251. border-left-color: darkgray;
  252. border-left-style: solid; /* just a single line */
  253. border-top-right-radius: 3px; /* same radius as the QComboBox */
  254. border-bottom-right-radius: 3px;
  255. padding-left: 10px;
  256. }</string>
  257. </property>
  258. <item>
  259. <property name="text">
  260. <string>Administrador</string>
  261. </property>
  262. </item>
  263. <item>
  264. <property name="text">
  265. <string>Caja</string>
  266. </property>
  267. </item>
  268. </widget>
  269. <widget class="QComboBox" name="l_sucursal">
  270. <property name="enabled">
  271. <bool>false</bool>
  272. </property>
  273. <property name="geometry">
  274. <rect>
  275. <x>440</x>
  276. <y>330</y>
  277. <width>69</width>
  278. <height>22</height>
  279. </rect>
  280. </property>
  281. <property name="styleSheet">
  282. <string notr="true">QComboBox#l_sucursal{
  283. background:none;
  284. border:0px;
  285. border-bottom: 1px solid lightblue;
  286. color:#05839C;
  287. }
  288.  
  289.  
  290. QComboBox QAbstractItemView
  291. {
  292. border:0px;
  293. background:white;
  294. color: grey;
  295.  
  296. }
  297. QComboBox#l_sucursal::drop-down
  298. {
  299. subcontrol-origin: padding;
  300. subcontrol-position: top right;
  301. width: 15px;
  302. color: white;
  303. border-left-width: 0px;
  304. border-left-color: darkgray;
  305. border-left-style: solid; /* just a single line */
  306. border-top-right-radius: 3px; /* same radius as the QComboBox */
  307. border-bottom-right-radius: 3px;
  308. padding-left: 10px;
  309. }</string>
  310. </property>
  311. <item>
  312. <property name="text">
  313. <string>Exxe 1</string>
  314. </property>
  315. </item>
  316. <item>
  317. <property name="text">
  318. <string>Exxe 3</string>
  319. </property>
  320. </item>
  321. </widget>
  322. <widget class="QPushButton" name="l_entrar">
  323. <property name="geometry">
  324. <rect>
  325. <x>550</x>
  326. <y>330</y>
  327. <width>75</width>
  328. <height>22</height>
  329. </rect>
  330. </property>
  331. <property name="styleSheet">
  332. <string notr="true">QPushButton#l_entrar{
  333. background:#41CD52;
  334. border:0px;
  335. color:white;
  336. }
  337. QPushButton#l_entrar:pressed{
  338. border-bottom:2px solid green;
  339. }
  340. </string>
  341. </property>
  342. <property name="text">
  343. <string>Entrar</string>
  344. </property>
  345. </widget>
  346. </widget>
  347. </widget>
  348. <resources/>
  349. <connections/>
  350. </ui>
  351.  
  352. t = threading.Thread(target=self.anima)
  353. t.start()
  354.  
  355. self.anima()
  356.  
  357. from PyQt5.QtWidgets import QMainWindow, QApplication
  358. from PyQt5 import QtCore
  359. from PyQt5 import uic
  360. from PyQt5.Qt import QMovie
  361.  
  362. class LoginC(QMainWindow):
  363. def __init__(self):
  364. QMainWindow.__init__(self)
  365. self.ui = uic.loadUi("main.ui",self) //Cambia esto por tu ubicacion del .ui
  366.  
  367. self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
  368. self.ui.l_permiso.setAttribute(QtCore.Qt.WA_NoMousePropagation)
  369. self.ui.l_sucursal.setAttribute(QtCore.Qt.WA_NoMousePropagation)
  370.  
  371. self.ui.l_entrar.clicked.connect(self.anima)
  372. self.ui.l_close.clicked.connect(self.close)
  373.  
  374. def anima(self):
  375. self.movie = QMovie("uno.gif")
  376. self.label.setMovie(self.movie)
  377. self.movie.start()
  378.  
  379. app = QApplication([])
  380. l = LoginC()
  381. l.show()
  382. app.exec_()
Add Comment
Please, Sign In to add comment