Advertisement
Guest User

Database yaratmaq üçün...

a guest
Apr 23rd, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.27 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. # Form implementation generated from reading ui file 'login.ui'
  4. #
  5. # Created by: PyQt4 UI code generator 4.11.4
  6. #
  7. # WARNING! All changes made in this file will be lost!
  8.  
  9. from PyQt4 import QtCore, QtGui
  10. import sqlite3
  11. try:
  12.     _fromUtf8 = QtCore.QString.fromUtf8
  13. except AttributeError:
  14.     def _fromUtf8(s):
  15.         return s
  16.  
  17. try:
  18.     _encoding = QtGui.QApplication.UnicodeUTF8
  19.     def _translate(context, text, disambig):
  20.         return QtGui.QApplication.translate(context, text, disambig, _encoding)
  21. except AttributeError:
  22.     def _translate(context, text, disambig):
  23.         return QtGui.QApplication.translate(context, text, disambig)
  24.  
  25. class Ui_Dialog(object):
  26.     def login(self):
  27.         username = self.username_input.text()
  28.         password = self.pass_input.text()
  29. ###### Probemli yer ######
  30.         connect = sqlite3.connect("login.db")
  31.         result = connect.execute("SELECT * FROM users WHERE username = ? AND password = ?",[username,password])
  32. ###### Son ################
  33.         if(len(result.fetchall()) > 0):
  34.             print("Tapıldı ! ")
  35.             self.welcomeWindowShow()
  36.         else:
  37.             print("Tapılmadı !")
  38.             self.showMessageBox('İstifadəçi adı və ya şifrə yanlışdır!')
  39.         connection.close()
  40.        
  41.     def register(self):
  42.         print "SASd"
  43.     def setupUi(self, Dialog):
  44.         Dialog.setObjectName(_fromUtf8("Dialog"))
  45.         Dialog.resize(545, 360)
  46.         self.username_label = QtGui.QLabel(Dialog)
  47.         self.username_label.setGeometry(QtCore.QRect(0, 130, 171, 51))
  48.         font = QtGui.QFont()
  49.         font.setPointSize(15)
  50.         self.username_label.setFont(font)
  51.         self.username_label.setAlignment(QtCore.Qt.AlignCenter)
  52.         self.username_label.setObjectName(_fromUtf8("username_label"))
  53.         self.login_button = QtGui.QPushButton(Dialog)
  54.         self.login_button.setGeometry(QtCore.QRect(180, 260, 91, 31))
  55.         self.login_button.setObjectName(_fromUtf8("login_button"))
  56.         #
  57.         self.login_button.clicked.connect(self.login)
  58.        
  59.         self.username_input = QtGui.QLineEdit(Dialog)
  60.         self.username_input.setGeometry(QtCore.QRect(180, 140, 221, 31))
  61.         self.username_input.setInputMethodHints(QtCore.Qt.ImhNone)
  62.         self.username_input.setObjectName(_fromUtf8("username_input"))
  63.         self.pass_label = QtGui.QLabel(Dialog)
  64.         self.pass_label.setGeometry(QtCore.QRect(40, 190, 111, 51))
  65.         font = QtGui.QFont()
  66.         font.setPointSize(15)
  67.         self.pass_label.setFont(font)
  68.         self.pass_label.setAlignment(QtCore.Qt.AlignCenter)
  69.         self.pass_label.setObjectName(_fromUtf8("pass_label"))
  70.         self.pass_input = QtGui.QLineEdit(Dialog)
  71.         self.pass_input.setGeometry(QtCore.QRect(180, 200, 221, 31))
  72.         self.pass_input.setObjectName(_fromUtf8("pass_input"))
  73.         self.title = QtGui.QLabel(Dialog)
  74.         self.title.setGeometry(QtCore.QRect(80, 10, 341, 81))
  75.         font = QtGui.QFont()
  76.         font.setPointSize(40)
  77.         self.title.setFont(font)
  78.         self.title.setStyleSheet(_fromUtf8(""))
  79.         self.title.setAlignment(QtCore.Qt.AlignCenter)
  80.         self.title.setObjectName(_fromUtf8("title"))
  81.         self.register_button = QtGui.QPushButton(Dialog)
  82.         self.register_button.setGeometry(QtCore.QRect(290, 260, 121, 31))
  83.         self.register_button.setObjectName(_fromUtf8("register_button"))
  84.         #
  85.         self.register_button.clicked.connect(self.register)
  86.  
  87.         self.retranslateUi(Dialog)
  88.         QtCore.QMetaObject.connectSlotsByName(Dialog)
  89.  
  90.     def retranslateUi(self, Dialog):
  91.         Dialog.setWindowTitle(_translate("Dialog", "Daxil Ol", None))
  92.         self.username_label.setText(_translate("Dialog", "İstifadəçi adı", None))
  93.         self.login_button.setText(_translate("Dialog", "Daxil Ol", None))
  94.         self.pass_label.setText(_translate("Dialog", "Şifrə", None))
  95.         self.title.setText(_translate("Dialog", "Daxil ol", None))
  96.         self.register_button.setText(_translate("Dialog", "Qeydiyyatdan keç", None))
  97.  
  98.  
  99. if __name__ == "__main__":
  100.     import sys
  101.     app = QtGui.QApplication(sys.argv)
  102.     Dialog = QtGui.QDialog()
  103.     ui = Ui_Dialog()
  104.     ui.setupUi(Dialog)
  105.     Dialog.show()
  106.     sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement