class Ui_MainWindow(object): def openWindow(self): self.window = QtWidgets.QMainWindow() self.ui = Ui_OtherWindow() self.ui.setupUi(self.window) MainWindow.hide() self.window.show() def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(800, 600) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.btn_open = QtWidgets.QPushButton(self.centralwidget) self.btn_open.setGeometry(QtCore.QRect(330, 270, 112, 34)) self.btn_open.setObjectName("btn_open") self.btn_open.clicked.connect(self.openWindow) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 31)) self.menubar.setObjectName("menubar") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) self.btn_open.setText(_translate("MainWindow", "Open Window"))
class Ui_MainWindow(object): def OpenWindow(self): self.window = QMainWindow() self.ui = Ui_OtherWindow() self.ui.setupUi(self.window) self.window.show() def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(800, 600) self.centralwidget = QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.textBrowser = QTextBrowser(self.centralwidget) self.textBrowser.setGeometry(QtCore.QRect(40, 20, 256, 121)) self.textBrowser.setObjectName(_fromUtf8("textBrowser")) self.textBrowser_2 = QTextBrowser(self.centralwidget) self.textBrowser_2.setGeometry(QtCore.QRect(40, 200, 256, 121)) self.textBrowser_2.setObjectName(_fromUtf8("textBrowser_2")) self.pushButton = QPushButton(self.centralwidget) self.pushButton.setGeometry(QtCore.QRect(370, 230, 191, 27)) self.pushButton.setObjectName(_fromUtf8("pushButton")) self.pushButton.clicked.connect(self.active) self.pushButton_2 = QPushButton(self.centralwidget) self.pushButton_2.setGeometry(QtCore.QRect(350, 60, 211, 27)) self.pushButton_2.setObjectName(_fromUtf8("pushButton_2")) self.pushButton_2.clicked.connect(self.select) self.pushButton_3 = QPushButton(self.centralwidget) self.pushButton_3.setGeometry(QtCore.QRect(200, 420, 451, 27)) self.pushButton_3.setObjectName(_fromUtf8("pushButton_3")) self.pushButton_3.clicked.connect(self.OpenWindow) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 25)) self.menubar.setObjectName(_fromUtf8("menubar")) MainWindow.setMenuBar(self.menubar) self.statusbar = QStatusBar(MainWindow) self.statusbar.setObjectName(_fromUtf8("statusbar")) MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None)) self.pushButton.setText( _translate("MainWindow", "show active interface", None)) self.pushButton_2.setText( _translate("MainWindow", "show interface", None)) self.pushButton_3.setText(_translate("MainWindow", "start", None)) def select(self): x = ni.interfaces() s = get_connection_name(x) self.textBrowser.setText(str(s)) def active(self): x1 = conf.iface #s1=get_connection_name(x1) self.textBrowser_2.setText(str(x1))
class Ui_MainWindow(object): def openWindow(self): self.window = QtWidgets.QMainWindow() self.ui = Ui_OtherWindow() self.ui.setupUi(self.window) MainWindow.hide() self.window.show() def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(371, 297) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.btn_open = QtWidgets.QPushButton(self.centralwidget) self.btn_open.setGeometry(QtCore.QRect(110, 140, 141, 51)) self.btn_open.setObjectName("btn_open") self.btn_open.clicked.connect(self.openWindow) self.label = QtWidgets.QLabel(self.centralwidget) self.label.setGeometry(QtCore.QRect(70, 40, 211, 41)) font = QtGui.QFont() font.setPointSize(16) self.label.setFont(font) self.label.setObjectName("label") MainWindow.setCentralWidget(self.centralwidget) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) self.btn_open.setText(_translate("MainWindow", "Open Window")) self.label.setText(_translate("MainWindow", "Click To Open Window"))
class Ui_MainWindow(object): def openWind(self): self.wind = QtWidgets.QMainWindow() self.ui = Ui_OtherWind() self.ui.setupUi(self.wind) self.wind.show() def openWindow(self): self.window = QtWidgets.QMainWindow() self.ui = Ui_OtherWindow() self.ui.setupUi(self.window) self.window.show() def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.setStyleSheet(" background-color:rgb(0,85,127) ;") MainWindow.resize(507, 405) MainWindow.setWindowOpacity(1.0) MainWindow.setAutoFillBackground(True) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.pushButton = QtWidgets.QPushButton(self.centralwidget) self.pushButton.setEnabled(True) self.pushButton.setGeometry(QtCore.QRect(10, 10, 221, 50)) self.pushButton.setObjectName("pushButton") self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_2.setGeometry(QtCore.QRect(10, 70, 221, 50)) self.pushButton_2.setObjectName("pushButton_2") self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_3.setGeometry(QtCore.QRect(10, 130, 221, 50)) self.pushButton_3.setObjectName("pushButton_3") self.pushButton_4 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_4.setGeometry(QtCore.QRect(10, 190, 221, 50)) self.pushButton_4.setObjectName("pushButton_4") self.pushButton_5 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_5.setGeometry(QtCore.QRect(10, 250, 221, 50)) icon = QtGui.QIcon.fromTheme("\\") self.pushButton_5.setIcon(icon) self.pushButton_5.setObjectName("pushButton_5") self.openGLWidget = QtWidgets.QOpenGLWidget(self.centralwidget) self.openGLWidget.setGeometry(QtCore.QRect(-60, 470, 300, 200)) self.openGLWidget.setObjectName("openGLWidget") self.textBrowser = QtWidgets.QTextBrowser(self.centralwidget) self.textBrowser.setGeometry(QtCore.QRect(240, 10, 256, 331)) self.textBrowser.setObjectName("textBrowser") self.pushButton_6 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_6.setGeometry(QtCore.QRect(10, 310, 221, 50)) self.pushButton_6.setObjectName("pushButton_6") MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 507, 21)) self.menubar.setObjectName("menubar") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) self.pushButton.setText( _translate("MainWindow", "Color Thresholding using OpenCV")) self.pushButton_2.setText( _translate("MainWindow", "Shape detection using OpenCV")) self.pushButton_3.setText( _translate("MainWindow", "Detection using haar-cascade")) self.pushButton_4.setText( _translate("MainWindow", "Hough Lines detection")) self.pushButton_5.setText( _translate("MainWindow", "Filters in OpenCV and their effect on images")) self.textBrowser.setHtml( _translate( "MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n" "<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:20pt; font-weight:600; text-decoration: underline;\">Course Project</span></p>\n" "<p align=\"justify\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:18pt;\">This is our Course project for the subject Advanced Computer Programming it is based on the features of Computer Vision or OpenCV and how it makes our lives easier.</span></p>\n" "<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:16pt;\"><br /></p></body></html>" )) self.pushButton_6.setText( _translate("MainWindow", "Tracking using OpenCV")) self.pushButton.clicked.connect(self.on_click) self.pushButton_2.clicked.connect(self.on_click2) self.pushButton_3.clicked.connect(self.on_click3) self.pushButton_4.clicked.connect(self.on_click4) self.pushButton_5.clicked.connect(self.openWind) self.pushButton_6.clicked.connect(self.openWindow) self.pushButton.setStyleSheet(" background-color: rgb(150, 170, 245);") self.pushButton_3.setStyleSheet( " background-color: rgb(150, 170, 245);") self.pushButton_2.setStyleSheet( " background-color: rgb(150, 170, 245);") self.pushButton_4.setStyleSheet( " background-color: rgb(150, 170, 245);") self.pushButton_5.setStyleSheet( " background-color: rgb(150, 170, 245);") self.pushButton_6.setStyleSheet( " background-color: rgb(150, 170, 245);") def on_click(self): print("Starting Code for Color Thresholding") exec(open("ct.py").read()) def on_click2(self): print("Starting Shape Detection for the given Input image") exec(open("detect_shapes.py").read()) def on_click3(self): print("Starting Face Detection using Haar-Cascade") exec(open("face.py").read()) def on_click4(self): print("Starting Striaght line Detection using Hough-Lines") import cv2 as cv import numpy as np import matplotlib.pyplot as plt def do_canny(frame): gray = cv.cvtColor(frame, cv.COLOR_RGB2GRAY) blur = cv.GaussianBlur(gray, (5, 5), 0) canny = cv.Canny(blur, 50, 150) return canny def do_segment(frame): height = frame.shape[0] polygons = np.array([[(0, height), (800, height), (380, 290)]]) mask = np.zeros_like(frame) cv.fillPoly(mask, polygons, 255) segment = cv.bitwise_and(frame, mask) return segment def calculate_lines(frame, lines): left = [] right = [] for line in lines: # Reshapes line from 2D array to 1D array x1, y1, x2, y2 = line.reshape(4) # Fits a linear polynomial to the x and y coordinates and returns a vector of coefficients which describe the slope and y-intercept parameters = np.polyfit((x1, x2), (y1, y2), 1) slope = parameters[0] y_intercept = parameters[1] # If slope is negative, the line is to the left of the lane, and otherwise, the line is to the right of the lane if slope < 0: left.append((slope, y_intercept)) else: right.append((slope, y_intercept)) # Averages out all the values for left and right into a single slope and y-intercept value for each line left_avg = np.average(left, axis=0) right_avg = np.average(right, axis=0) # Calculates the x1, y1, x2, y2 coordinates for the left and right lines left_line = calculate_coordinates(frame, left_avg) right_line = calculate_coordinates(frame, right_avg) return np.array([left_line, right_line]) def calculate_coordinates(frame, parameters): slope, intercept = parameters # Sets initial y-coordinate as height from top down (bottom of the frame) y1 = frame.shape[0] # Sets final y-coordinate as 150 above the bottom of the frame y2 = int(y1 - 150) # Sets initial x-coordinate as (y1 - b) / m since y1 = mx1 + b x1 = int((y1 - intercept) / slope) # Sets final x-coordinate as (y2 - b) / m since y2 = mx2 + b x2 = int((y2 - intercept) / slope) return np.array([x1, y1, x2, y2]) def visualize_lines(frame, lines): # Creates an image filled with zero intensities with the same dimensions as the frame lines_visualize = np.zeros_like(frame) # Checks if any lines are detected if lines is not None: for x1, y1, x2, y2 in lines: # Draws lines between two coordinates with green color and 5 thickness cv.line(lines_visualize, (x1, y1), (x2, y2), (0, 255, 0), 5) return lines_visualize # The video feed is read in as a VideoCapture object cap = cv.VideoCapture("input.mp4") while (cap.isOpened()): # ret = a boolean return value from getting the frame, frame = the current frame being projected in the video ret, frame = cap.read() canny = do_canny(frame) cv.imshow("canny", canny) # plt.imshow(frame) # plt.show() segment = do_segment(canny) hough = cv.HoughLinesP(segment, 2, np.pi / 180, 100, np.array([]), minLineLength=100, maxLineGap=50) lines = calculate_lines(frame, hough) # Visualizes the lines lines_visualize = visualize_lines(frame, lines) cv.imshow("hough", lines_visualize) output = cv.addWeighted(frame, 0.9, lines_visualize, 1, 1) cv.imshow("output", output) if cv.waitKey(10) & 0xFF == ord('q'): break cap.release() cv.destroyAllWindows()
class Ui_MainWindow(object): def openWindow(self): self.window = QtWidgets.QMainWindow() self.ui = Ui_OtherWindow() self.ui.setupUi(self.window) #MainWindow.close() #close MainWindow when opening another window #self.window.show() def openA7SWindow(self): self.window2 = QtWidgets.QMainWindow() self.ui2 = Ui_A7S_window() self.ui2.setupUi(self.window2) #MainWindow.close() #close MainWindow when opening another window #self.window2.show() def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(656, 461) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") #self.centralwidget.setCurrentIndex(1) # self.buttonA7S = QtWidgets.QPushButton(self.centralwidget) self.buttonA7S.setGeometry(QtCore.QRect(200, 110, 231, 61)) self.buttonA7S.setObjectName("A7S") self.buttonA7S.clicked.connect(self.openA7SWindow) self.button1 = QtWidgets.QPushButton(self.centralwidget) self.button1.setGeometry(QtCore.QRect(200, 210, 231, 61)) self.button1.setObjectName("button1") self.button1.clicked.connect(self.openWindow) self.hsk = QtWidgets.QLabel(self.centralwidget) self.hsk.setGeometry(QtCore.QRect(10, 10, 101, 51)) self.hsk.setText("") self.hsk.setPixmap(QtGui.QPixmap("img/hochschulekempten.jpg")) self.hsk.setScaledContents(True) self.hsk.setObjectName("hsk") self.adrive = QtWidgets.QLabel(self.centralwidget) self.adrive.setGeometry(QtCore.QRect(10, 60, 101, 31)) self.adrive.setText("") self.adrive.setPixmap(QtGui.QPixmap("img/adrive.jpg")) self.adrive.setScaledContents(True) self.adrive.setObjectName("adrive") MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 656, 21)) self.menubar.setObjectName("menubar") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) self.buttonA7S.setText( _translate("MainWindow", "A7 Dietmannsried - Nesselwang")) self.button1.setText(_translate("MainWindow", "First Button!"))
class Ui_MainWindow(object): def __init__(self): self.textbox=None def openWindow(self): self.window = QtWidgets.QMainWindow() self.ui = Ui_OtherWindow(self.textbox) self.ui.setupUi(self.window) self.QMainWindow.hide() self.window.show() def setupUi(self, MainWindow): app = QtWidgets.QApplication(sys.argv) self.QMainWindow = QtWidgets.QWidget() self.QMainWindow.resize(500, 450) self.QMainWindow.setWindowTitle('Facial-Recognation') self.QMainWindow.setWindowIcon(QtGui.QIcon('the-flash-season-4-confirmed.jpg')) self.pushButton = QtWidgets.QPushButton("Sign In", self.QMainWindow) self.pushButton.resize(100, 60) self.pushButton.move(210, 100) self.pushButton.setToolTip('Click To Log In') self.pushButton.clicked.connect(self.loginForm) self.pushButton2 = QtWidgets.QPushButton("Connect To Your Work", self.QMainWindow) self.pushButton2.hide() self.pushButton2.resize(200, 60) self.pushButton2.move(210, 190) self.pushButton2.clicked.connect(self.openWindow) """ lable=QtWidgets.QLabel(QMainWindow,text='<h1>Enter Your password</h1> ') lable.move(210, 150) self.textbox1 = QtWidgets.QLineEdit(QMainWindow) self.textbox1.move(210, 190) self.textbox1.resize(200,30) self.pushButton = QtWidgets.QPushButton("Sign In", QMainWindow) self.pushButton.resize(100, 60) self.pushButton.move(210, 290) self.pushButton.setToolTip('Click To Log In') self.pushButton.clicked.connect(self.openWindow) """ self.QMainWindow.show() sys.exit(app.exec_()) def loginForm (self) : self.QMainWindow.hide() textbox , status = QtWidgets.QInputDialog.getText(None,'ID','Enter Your ID :') #print(textbox) textbox2 , ok2 = QtWidgets.QInputDialog.getText(None,'Password','Enter Your Password :',QtWidgets.QLineEdit.Password) print(textbox2) print(ok2) if ok2: print(B.login(textbox,textbox2)) if (B.login(textbox,textbox2)): #CA.GetAgentId(textbox) self.QMainWindow.show() self.pushButton.hide() self.pushButton2.show() else: self.QMainWindow.show()
class Ui_MainWindow(object): def openWindow(self): self.window = QtWidgets.QMainWindow() self.ui = Ui_OtherWindow() self.ui.setupUi(self.window) MainWindow.hide() self.window.show() def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(878, 698) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.pushButton = QtWidgets.QPushButton(self.centralwidget) self.pushButton.setGeometry(QtCore.QRect(270, 180, 301, 81)) font = QtGui.QFont() font.setPointSize(28) self.pushButton.setFont(font) self.pushButton.setObjectName("pushButton") self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_2.setGeometry(QtCore.QRect(270, 330, 301, 81)) font = QtGui.QFont() font.setPointSize(28) self.pushButton_2.setFont(font) self.pushButton_2.setObjectName("pushButton_2") self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_3.setGeometry(QtCore.QRect(270, 490, 151, 81)) font = QtGui.QFont() font.setPointSize(28) self.pushButton_3.setFont(font) self.pushButton_3.setObjectName("pushButton_3") self.pushButton_4 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_4.setGeometry(QtCore.QRect(430, 490, 140, 81)) font = QtGui.QFont() font.setPointSize(28) self.pushButton_4.setFont(font) self.pushButton_4.setObjectName("pushButton_4") self.label = QtWidgets.QLabel(self.centralwidget) image = QtGui.QImage('C:/Users/yetski/Pictures/apesback.jpg') sImage = image.scaled(QtCore.QSize(878, 698)) palette = QtGui.QPalette() palette.setBrush(10, QtGui.QBrush(sImage)) MainWindow.setPalette(palette) self.label_2 = QtWidgets.QLabel(self.centralwidget) self.label_2.setGeometry(QtCore.QRect(216, 12, 411, 151)) self.label_2.setText("") self.label_2.setObjectName("label_2") pixmap = QtGui.QPixmap('A.P.E.S..png') self.label_2.setPixmap(pixmap) self.label.setGeometry(QtCore.QRect(0, 0, 881, 671)) self.label.setText("") self.label.setObjectName("label") self.label.raise_() self.pushButton.raise_() self.pushButton_2.raise_() self.pushButton_3.raise_() self.pushButton_4.raise_() self.label_2.raise_() # self.pushButton.clicked.connect(self.record) icon = QtGui.QIcon() icon.addFile('C:/Users/yetski/Pictures/ape.png', QtCore.QSize(64, 64)) MainWindow.setWindowIcon(icon) MainWindow.setCentralWidget(self.centralwidget) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) self.pushButton.clicked.connect(self.openWindow) self.label = QtWidgets.QLabel(self.centralwidget) self.label.setGeometry(QtCore.QRect(70, 40, 211, 41)) font = QtGui.QFont() font.setPointSize(16) self.label.setFont(font) self.label.setObjectName("label") MainWindow.setCentralWidget(self.centralwidget) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): '''_translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) self.btn_open.setText(_translate("MainWindow", "Open Window")) self.label.setText(_translate("MainWindow", "Click To Open Window"))''' _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) self.pushButton.setText(_translate("MainWindow", "New Sound")) self.pushButton_2.setText(_translate("MainWindow", "Load Sound")) self.pushButton_3.setText(_translate("MainWindow", "Settings")) self.pushButton_4.setText(_translate("MainWindow", "Quit"))
class Ui_MainWindow(object): def openWindow(self): self.window = QtWidgets.QMainWindow() self.ui = Ui_OtherWindow() self.ui.setupUi(self.window) self.window.show() def openWindow2(self, ind): self.window = QtWidgets.QMainWindow() print('here') self.ui = Ui_OtherWindow2() self.ui.setupUi(self.window, ind) self.window.show() def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(521, 374) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.title = QtWidgets.QLabel(self.centralwidget) self.title.setGeometry(QtCore.QRect(90, 10, 400, 21)) font = QtGui.QFont() font.setFamily("PMingLiU-ExtB") font.setPointSize(22) self.title.setFont(font) self.title.setLayoutDirection(QtCore.Qt.LeftToRight) self.title.setObjectName("title") self.logoLabel = QtWidgets.QLabel(self.centralwidget) self.logoLabel.setGeometry(QtCore.QRect(200, 50, 111, 101)) self.logoLabel.setAutoFillBackground(False) self.logoLabel.setText("") self.logoLabel.setObjectName("logoLabel") self.lineEdit = QtWidgets.QLineEdit(self.centralwidget) self.lineEdit.setGeometry(QtCore.QRect(160, 180, 201, 20)) self.lineEdit.setObjectName("lineEdit") self.pushButton = QtWidgets.QPushButton(self.centralwidget) self.pushButton.setGeometry(QtCore.QRect(220, 220, 75, 23)) self.pushButton.setObjectName("pushButton") MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 521, 21)) self.menubar.setObjectName("menubar") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) fileName = 'C:/Users/Aditya/Desktop/MovieDB/logo.jpg' pixmap = QtGui.QPixmap(fileName) pixmap = pixmap.scaled(self.logoLabel.width(), self.logoLabel.height(), QtCore.Qt.KeepAspectRatio) self.logoLabel.setPixmap(pixmap) self.logoLabel.setAlignment(QtCore.Qt.AlignCenter) self.pushButton.clicked.connect(self.search) MainWindow.setWindowIcon(QtGui.QIcon('wb.png')) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle( _translate("MainWindow", "Warner Bros Movie DataBase")) self.title.setText( _translate("MainWindow", "Warner Bros Movie DataBase")) self.pushButton.setText(_translate("MainWindow", "GO!")) def search(self): print(self.lineEdit.text()) text = self.lineEdit.text() if text: text = text.strip() text = text.upper() print(text) conn = sqlite3.connect('temp2.db') c = conn.cursor() c.execute("""Select * from MOVIE""") res = c.fetchall() movie_names = [] print(res) for i in range(len(res)): movie_names.append(res[i][2]) print(movie_names) key_words = text.split() max_movie = movie_names[0] maxx = 0 for movie in movie_names: count = 0 for key_word in key_words: movie_words = movie.split() for movie_word in movie_words: if movie_word == key_word: count += 1 if count > maxx: maxx = count max_movie = movie print(maxx) print(max_movie) if maxx == 0: #notfound print('Not Found') self.openWindow() else: for i in range(len(res)): if max_movie == res[i][2]: ind = i break print(ind) self.openWindow2(ind) #print_movie_info(argument is ind) ''' else: self.openWindow()
class Ui_MainWindow(object): def openWindow(self): self.window = QtWidgets.QMainWindow() self.ui = Ui_OtherWindow() self.ui.setupUi(self.window) self.window.show() def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(346, 256) MainWindow.setStyleSheet("background-color: rgb(85, 170, 255);") self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.gridLayout = QtWidgets.QGridLayout(self.centralwidget) self.gridLayout.setObjectName("gridLayout") self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") self.label = QtWidgets.QLabel(self.centralwidget) self.label.setObjectName("label") self.verticalLayout.addWidget(self.label) self.btn_open_01 = QtWidgets.QPushButton(self.centralwidget) self.btn_open_01.setStyleSheet("background-color: rgb(255, 85, 0);") self.btn_open_01.setObjectName("btn_open_01") self.btn_open_01.clicked.connect(self.openWindow) self.verticalLayout.addWidget(self.btn_open_01) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.btn_open_02 = QtWidgets.QPushButton(self.centralwidget) self.btn_open_02.setStyleSheet("background-color: rgb(255, 85, 0);") self.btn_open_02.setObjectName("btn_open_02") self.horizontalLayout.addWidget(self.btn_open_02) self.btn_open_03 = QtWidgets.QPushButton(self.centralwidget) self.btn_open_03.setStyleSheet("background-color: rgb(255, 85, 0);") self.btn_open_03.setObjectName("btn_open_03") self.horizontalLayout.addWidget(self.btn_open_03) self.verticalLayout.addLayout(self.horizontalLayout) self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1, 1) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 346, 21)) self.menubar.setObjectName("menubar") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle( _translate("MainWindow", "Programa principal")) self.label.setText( _translate( "MainWindow", "<html><head/><body><p align=\"center\"><span style=\" font-size:20pt;\">Te gusta</span></p><p align=\"center\"><span style=\" font-size:20pt;\">nuestro trabajo</span></p></body></html>" )) self.btn_open_01.setText(_translate("MainWindow", "Síguenos como")) self.btn_open_02.setText(_translate("MainWindow", "Productos")) self.btn_open_03.setText(_translate("MainWindow", "Servicios"))
class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(622, 512) MainWindow.setMinimumSize(QtCore.QSize(622, 512)) MainWindow.setMaximumSize(QtCore.QSize(622, 512)) self.label = QtWidgets.QLabel(MainWindow) self.label.setGeometry(QtCore.QRect(50, 10, 551, 51)) font = QtGui.QFont() font.setFamily("Noto Sans CJK SC") font.setPointSize(26) font.setBold(True) font.setWeight(75) self.label.setFont(font) self.label.setStyleSheet("border-color: rgb(0, 0, 128);") self.label.setObjectName("label") self.tabWidget = QtWidgets.QTabWidget(MainWindow) self.tabWidget.setGeometry(QtCore.QRect(0, 80, 621, 431)) font = QtGui.QFont() font.setPointSize(16) font.setBold(False) font.setWeight(50) self.tabWidget.setFont(font) self.tabWidget.setStyleSheet("") self.tabWidget.setObjectName("tabWidget") self.accTab = QtWidgets.QWidget() self.accTab.setObjectName("accTab") self.label_2 = QtWidgets.QLabel(self.accTab) self.label_2.setGeometry(QtCore.QRect(220, 10, 311, 51)) font = QtGui.QFont() font.setFamily("Noto Sans CJK SC") font.setPointSize(22) font.setBold(True) font.setWeight(75) self.label_2.setFont(font) self.label_2.setStyleSheet("") self.label_2.setObjectName("label_2") self.firstname = QtWidgets.QLineEdit(self.accTab) self.firstname.setGeometry(QtCore.QRect(100, 70, 201, 41)) self.firstname.setStyleSheet("font: 14pt \".SF NS Text\";\n" "") self.firstname.setObjectName("firstname") self.lastname = QtWidgets.QLineEdit(self.accTab) self.lastname.setGeometry(QtCore.QRect(320, 70, 191, 41)) self.lastname.setStyleSheet("\n" "border-color: rgb(25, 25, 25);") self.lastname.setObjectName("lastname") self.cr_username = QtWidgets.QLineEdit(self.accTab) self.cr_username.setGeometry(QtCore.QRect(100, 130, 351, 41)) self.cr_username.setObjectName("cr_username") self.cr_password = QtWidgets.QLineEdit(self.accTab) self.cr_password.setGeometry(QtCore.QRect(100, 180, 351, 41)) self.cr_password.setText("") self.cr_password.setObjectName("cr_password") self.cr_age = QtWidgets.QLineEdit(self.accTab) #self.cr_age.setGeometry(QtCore.QRect(100, 240, 101, 31)) self.cr_age.setGeometry(QtCore.QRect(0, 0, 0, 0)) self.cr_age.setMaxLength(2) self.cr_age.setObjectName("cr_age") self.male_radio = QtWidgets.QRadioButton(self.accTab) #self.male_radio.setGeometry(QtCore.QRect(310, 240, 115, 31)) self.male_radio.setGeometry(QtCore.QRect(0, 0, 0, 0)) self.male_radio.setObjectName("male_radio") self.female_radio = QtWidgets.QRadioButton(self.accTab) # self.female_radio.setGeometry(QtCore.QRect(410, 240, 115, 31)) self.female_radio.setGeometry(QtCore.QRect(0, 0, 0, 0)) self.female_radio.setObjectName("female_radio") self.label_4 = QtWidgets.QLabel(self.accTab) self.label_4.setGeometry(QtCore.QRect(220, 240, 81, 31)) self.label_4.setObjectName("label_4") self.createAccount = QtWidgets.QPushButton(self.accTab) self.createAccount.setGeometry(QtCore.QRect(100, 300, 231, 51)) font = QtGui.QFont() font.setPointSize(22) font.setBold(False) font.setWeight(50) self.createAccount.setFont(font) self.createAccount.setObjectName("createAccount") self.cr_clear = QtWidgets.QPushButton(self.accTab) self.cr_clear.setGeometry(QtCore.QRect(350, 300, 151, 51)) font = QtGui.QFont() font.setPointSize(22) font.setBold(False) font.setWeight(50) self.cr_clear.setFont(font) self.cr_clear.setObjectName("cr_clear") self.label_3 = QtWidgets.QLabel(self.accTab) self.label_3.setGeometry(QtCore.QRect(20, 10, 571, 371)) self.label_3.setStyleSheet( "background-image: url(:/newPrefix/dozen-white-eggs-wallpaper-3.jpg);" ) self.label_3.setText("") self.label_3.setObjectName("label_3") self.label_3.raise_() self.label_2.raise_() self.firstname.raise_() self.lastname.raise_() self.cr_username.raise_() self.cr_password.raise_() self.cr_age.raise_() self.male_radio.raise_() self.female_radio.raise_() self.label_4.raise_() self.createAccount.raise_() self.cr_clear.raise_() self.tabWidget.addTab(self.accTab, "") self.log = QtWidgets.QWidget() self.log.setObjectName("log") self.log_username = QtWidgets.QLineEdit(self.log) self.log_username.setGeometry(QtCore.QRect(110, 190, 401, 51)) self.log_username.setObjectName("log_username") self.log_password = QtWidgets.QLineEdit(self.log) self.log_password.setEchoMode(QtWidgets.QLineEdit.Password) self.log_password.setGeometry(QtCore.QRect(110, 260, 401, 51)) self.log_password.setObjectName("log_password") self.log_in = QtWidgets.QPushButton(self.log) self.log_in.setGeometry(QtCore.QRect(80, 330, 181, 51)) font = QtGui.QFont() font.setPointSize(22) self.log_in.setFont(font) self.log_in.setObjectName("log_in") self.log_clear = QtWidgets.QPushButton(self.log) self.log_clear.setGeometry(QtCore.QRect(340, 330, 191, 51)) font = QtGui.QFont() font.setPointSize(22) font.setBold(False) font.setItalic(False) font.setWeight(50) self.log_clear.setFont(font) self.log_clear.setObjectName("log_clear") self.icon = QtWidgets.QLabel(self.log) self.icon.setGeometry(QtCore.QRect(210, 0, 191, 181)) self.icon.setStyleSheet("image: url(:/newPrefix/logo.jpg);") self.icon.setText("") self.icon.setObjectName("icon") self.label_5 = QtWidgets.QLabel(self.log) self.label_5.setGeometry(QtCore.QRect(20, 10, 571, 371)) self.label_5.setStyleSheet( "background-image: url(:/newPrefix/dozen-white-eggs-wallpaper-3.jpg);" ) self.label_5.setText("") self.label_5.setObjectName("label_5") self.label_5.raise_() self.log_username.raise_() self.log_password.raise_() self.log_in.raise_() self.log_clear.raise_() self.icon.raise_() self.tabWidget.addTab(self.log, "") self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle( _translate( "MainWindow", "Login and Register Form - EggIE(2019ver1.0) Created by: Danielle Mark O. Quijano" )) self.label.setText( _translate("MainWindow", "Internal and External Egg Detection System")) self.label_2.setText(_translate("MainWindow", "Create Account ")) self.firstname.setPlaceholderText( _translate("MainWindow", "First Name")) self.lastname.setPlaceholderText(_translate("MainWindow", "Last Name")) self.cr_username.setPlaceholderText( _translate("MainWindow", "Type a username...")) self.cr_password.setPlaceholderText( _translate("MainWindow", "Type a password...")) # self.cr_age.setPlaceholderText(_translate("MainWindow", "Age....")) # self.male_radio.setText(_translate("MainWindow", "Male")) #self.female_radio.setText(_translate("MainWindow", "Female")) #self.label_4.setText(_translate("MainWindow", "Gender: ")) self.createAccount.setText(_translate("MainWindow", "Create Account")) self.cr_clear.setText(_translate("MainWindow", "Clear")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.accTab), _translate("MainWindow", "Create Account")) self.log_username.setPlaceholderText( _translate("MainWindow", "Type username here ....")) self.log_password.setPlaceholderText( _translate("MainWindow", "Type password here ....")) self.log_in.setText(_translate("MainWindow", "Log In")) self.log_clear.setText(_translate("MainWindow", "Clear")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.log), _translate("MainWindow", "Log In")) ##########CLICKING############# self.cr_clear.clicked.connect(self.clear1) self.log_clear.clicked.connect(self.clear2) self.createAccount.clicked.connect(self.create_account) self.log_in.clicked.connect(self.login) ################################ def clear1(self): self.firstname.setText('') self.lastname.setText('') self.cr_username.setText('') self.cr_password.setText('') self.cr_age.setText('') mixer.init() mixer.music.load("trainedvoice_dataset/Clear.mp3") mixer.music.play() def clear2(self): self.log_username.setText('') self.log_password.setText('') mixer.init() mixer.music.load("trainedvoice_dataset/Clearlog.mp3") mixer.music.play() def login(self): with sqlite3.connect('users.db') as db: c = db.cursor() username = str(self.log_username.text()) password = str(self.log_password.text()) c.execute('SELECT * FROM users WHERE username = ? and password = ?', (username, password)) data = c.fetchone() db.commit() if data != None: info = ''' Name = %s , Age = %s, Gender = %s, Username = %s, You are Loged In. ''' % (data[0], str(data[1]), data[4], data[2]) mixer.init() mixer.music.load("trainedvoice_dataset/login.mp3") mixer.music.play() QMessageBox.information(MainWindow, "Loged In", info) #sys.exit() self.window = QtWidgets.QMainWindow() self.ui = Ui_OtherWindow() self.ui.setupUi(self.window) MainWindow.hide() self.window.show() mixer.init() mixer.music.load("trainedvoice_dataset/welcome.mp3") mixer.music.play() else: mixer.init() mixer.music.load("trainedvoice_dataset/invalidaccount.mp3") mixer.music.play() QMessageBox.critical(MainWindow, "Error", 'No Account With That Username And Password') def create_account(self): try: gender = None name = str(self.firstname.text() + ' ' + self.lastname.text()) age = int(self.cr_age.text()) username = str(self.cr_username.text()) password = str(self.cr_password.text()) if self.male_radio.isChecked(): gender = 'Male' if self.female_radio.isChecked(): gender = 'Female' with sqlite3.connect('users.db') as db: c = db.cursor() c.execute('INSERT INTO users VALUES(?,?,?,?,?)', (name, age, username, password, gender)) db.commit() c.execute('SELECT * FROM users') db.commit() c.close() db.close() mixer.init() mixer.music.load("trainedvoice_dataset/Register.mp3") mixer.music.play() QMessageBox.information(MainWindow, "Success!!", 'Account Created Successfully.') self.clear1() except: mixer.init() mixer.music.load("trainedvoice_dataset/error_reg.mp3") mixer.music.play() QMessageBox.critical( MainWindow, "Error", 'Error !!! Check Entries Again .Make Sure No Filed Is Empty.') pass
class Ui_MainWindow(object): def openWindow(self): self.window = QtWidgets.QMainWindow() self.ui = Ui_OtherWindow() self.ui.setupUi(self.window) self.window.show() def openWindow1(self): self.window = QtWidgets.QMainWindow() self.ui = Ui_OtherWindow1() self.ui.setupUi(self.window) self.window.show() def openWindow2(self): self.window = QtWidgets.QMainWindow() self.ui = Ui_OtherWindow2() self.ui.setupUi(self.window) self.window.show() def openWindow3(self): self.window = QtWidgets.QMainWindow() self.ui = Ui_OtherWindow3() self.ui.setupUi(self.window) self.window.show() def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(663, 806) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.pushButton = QtWidgets.QPushButton(self.centralwidget) self.pushButton.setGeometry(QtCore.QRect(110, 310, 151, 51)) self.pushButton.setObjectName("pushButton") self.pushButton.clicked.connect(self.openWindow) self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_3.setGeometry(QtCore.QRect(110, 660, 161, 51)) self.pushButton_3.setObjectName("pushButton_3") self.pushButton_3.clicked.connect(self.openWindow2) self.pushButton_4 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_4.setGeometry(QtCore.QRect(360, 310, 151, 51)) self.pushButton_4.setObjectName("pushButton_4") self.pushButton_4.clicked.connect(self.openWindow1) self.pushButton_5 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_5.setGeometry(QtCore.QRect(350, 660, 181, 51)) self.pushButton_5.setObjectName("pushButton_5") self.pushButton_5.clicked.connect(self.openWindow3) self.label_2 = QtWidgets.QLabel(self.centralwidget) self.label_2.setGeometry(QtCore.QRect(360, 40, 151, 241)) self.label_2.setText("") self.label_2.setPixmap(QtGui.QPixmap("aaa.png")) self.label_2.setScaledContents(True) self.label_2.setObjectName("label_2") self.label_3 = QtWidgets.QLabel(self.centralwidget) self.label_3.setGeometry(QtCore.QRect(110, 420, 151, 201)) self.label_3.setText("") self.label_3.setPixmap(QtGui.QPixmap("g.jpg")) self.label_3.setScaledContents(True) self.label_3.setObjectName("label_3") self.label_4 = QtWidgets.QLabel(self.centralwidget) self.label_4.setGeometry(QtCore.QRect(360, 400, 171, 231)) self.label_4.setText("") self.label_4.setPixmap(QtGui.QPixmap("f.jpg")) self.label_4.setScaledContents(True) self.label_4.setObjectName("label_4") self.label = QtWidgets.QLabel(self.centralwidget) self.label.setGeometry(QtCore.QRect(110, 40, 161, 241)) self.label.setText("") self.label.setPixmap(QtGui.QPixmap("wewe.png")) self.label.setScaledContents(True) self.label.setObjectName("label") MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 663, 26)) self.menubar.setObjectName("menubar") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) self.pushButton.setText(_translate("MainWindow", "Frozen")) self.pushButton_3.setText(_translate("MainWindow", "Kimetsu no yaiba")) self.pushButton_4.setText(_translate("MainWindow", "Iron man")) self.pushButton_5.setText(_translate("MainWindow", "Soul"))